fixed update employee with password change
This commit is contained in:
@@ -67,9 +67,6 @@ export const useEmployee = defineStore({
|
||||
headers: user.header
|
||||
})).data
|
||||
|
||||
console.log(this.clean.employee)
|
||||
console.log(data)
|
||||
|
||||
Object.assign(this.clean.employee, data)
|
||||
Object.assign(this.employee, data)
|
||||
}
|
||||
@@ -87,20 +84,34 @@ export const useEmployee = defineStore({
|
||||
async persist() {
|
||||
try {
|
||||
let result
|
||||
let payload = Object.assign({}, this.employee)
|
||||
|
||||
if (this.employee.password === this.clean.employee.password) {
|
||||
payload.username = ''
|
||||
payload.password = ''
|
||||
}
|
||||
|
||||
result = await axios.patch(
|
||||
'employees/'+this.employee.id,
|
||||
this.employee,
|
||||
payload,
|
||||
{
|
||||
headers: user.header
|
||||
}
|
||||
)
|
||||
|
||||
console.log(result)
|
||||
|
||||
this.employee.password = ''
|
||||
this.employee.passwordConfirm = ''
|
||||
|
||||
Object.assign(this.clean.employee, this.employee)
|
||||
notifications.add('success', result.statusText)
|
||||
}
|
||||
catch(error) {
|
||||
if(error instanceof Error) notifications.add('danger', error.message, -1)
|
||||
if(error instanceof Error) {
|
||||
console.log(error)
|
||||
notifications.add('danger', error.message, -1)
|
||||
}
|
||||
else console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user