fixed update employee with password change

This commit is contained in:
Sockenklaus
2021-11-04 15:05:21 +01:00
parent b41ff6515d
commit dc298c9ab2
2 changed files with 17 additions and 12 deletions

View File

@@ -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)
}
}