Skip to content

Commit

Permalink
fix attendance update issues
Browse files Browse the repository at this point in the history
  • Loading branch information
greywen committed Aug 1, 2022
1 parent 2f65f63 commit 56382c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/controllers/attendance.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ export class AttendanceController {

@Put('/update/custom')
async updateCustomAttendance(@Body() updateDto: IAttendanceCustomUpdateDto) {
const date = moment().format('YYYY-MM');
const { userId, index, datas } = updateDto;
let attendances = await FileData.readCustomAttendances(date);
const { userId, index, datas, date } = updateDto;
const _date = moment(date).format('YYYY-MM');
let attendances = await FileData.readCustomAttendances(_date);
attendances = attendances.map((x: IUserAttendances) => {
if (x.id === userId) {
x.attendances[index] = datas;
}
return x;
});
const result = await FileData.writeCustomAttendances(date, attendances);
const result = await FileData.writeCustomAttendances(_date, attendances);
return result;
}
}
1 change: 1 addition & 0 deletions src/dtos/dingTlak/attendance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface IAttendanceCustomUpdateDto {
userId: string;
index: number;
datas: any[];
date: string;
}

0 comments on commit 56382c9

Please sign in to comment.