Skip to content

Commit

Permalink
Merge pull request #16 from graywenn/fix/attendance
Browse files Browse the repository at this point in the history
fix attendance update issues
  • Loading branch information
greywen authored Aug 1, 2022
2 parents 2f65f63 + 56382c9 commit 46b8852
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 46b8852

Please sign in to comment.