added input masks to EmployeeDetails, started implementing Employees/Index. Updated to Vue 3.2.21
This commit is contained in:
@@ -11,7 +11,7 @@ type ResultData = {
|
||||
phone: string | undefined,
|
||||
mobile: string | undefined,
|
||||
email: string | undefined,
|
||||
contractHours: number | undefined,
|
||||
contractHours: number,
|
||||
isActive: boolean,
|
||||
username: string | undefined,
|
||||
role: string
|
||||
@@ -34,7 +34,7 @@ export const useEmployee = defineStore({
|
||||
phone: '',
|
||||
mobile: '',
|
||||
email: '',
|
||||
contractHours: NaN,
|
||||
contractHours: 0,
|
||||
isActive: false,
|
||||
username: '',
|
||||
password: '',
|
||||
@@ -50,7 +50,7 @@ export const useEmployee = defineStore({
|
||||
phone: '',
|
||||
mobile: '',
|
||||
email: '',
|
||||
contractHours: NaN,
|
||||
contractHours: 0,
|
||||
isActive: false,
|
||||
username: '',
|
||||
password: '',
|
||||
@@ -60,15 +60,24 @@ export const useEmployee = defineStore({
|
||||
},
|
||||
|
||||
actions: {
|
||||
assignTruthyValues(target: Object, source: Object) {
|
||||
for (const key in source) {
|
||||
if (source[key]) {
|
||||
target[key] = source[key]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async fetchFromApi(id: string | string[]) {
|
||||
this.$reset()
|
||||
|
||||
try {
|
||||
const data : ResultData = await <ResultData>(await axios.get('employees/'+id, {
|
||||
headers: user.header
|
||||
})).data
|
||||
|
||||
Object.assign(this.clean.employee, data)
|
||||
Object.assign(this.employee, data)
|
||||
this.assignTruthyValues(this.employee, data)
|
||||
this.assignTruthyValues(this.clean.employee, data)
|
||||
}
|
||||
catch(err){
|
||||
if(err instanceof Error) notifications.add('danger', err.message, -1)
|
||||
@@ -99,8 +108,6 @@ export const useEmployee = defineStore({
|
||||
}
|
||||
)
|
||||
|
||||
console.log(result)
|
||||
|
||||
this.employee.password = ''
|
||||
this.employee.passwordConfirm = ''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user