diff --git a/src/utils/Out/outGoingDataFilter.ts b/src/utils/Out/outGoingDataFilter.ts index df592a0..63e1518 100644 --- a/src/utils/Out/outGoingDataFilter.ts +++ b/src/utils/Out/outGoingDataFilter.ts @@ -1,5 +1,5 @@ -import { changeRoom } from "utils/Member/changeGrade"; -import { OutResponse } from "types/Out/out.type"; +import { changeRoom } from 'utils/Member/changeGrade'; +import { OutResponse } from 'types/Out/out.type'; export const outGoingDataFilter = ( OffBasePass: OutResponse | undefined, @@ -7,21 +7,28 @@ export const outGoingDataFilter = ( selectGrade: number, selectApproval: string | undefined, selectMealDemand: number, - selectRoom: string, + selectRoom: string ) => { const sortedData = OffBasePass?.data .filter((pass) => pass.student.name.includes(studentName)) .filter((data) => data.student.grade === selectGrade || selectGrade === 0) - .filter((data) => data.status === selectApproval || selectApproval === "") + .filter((data) => data.status === selectApproval || selectApproval === '') .filter((data) => data.student?.room === changeRoom(selectRoom) || changeRoom(selectRoom) === 0) .filter( (data) => selectMealDemand === 0 || (selectMealDemand === 1 && data.dinnerOrNot) || (selectMealDemand === 2 && !data.dinnerOrNot) || - selectMealDemand === -1, + selectMealDemand === -1 ) .sort((a, b) => { + if (a.status === 'PENDING' && b.status !== 'PENDING') { + return -1; + } + if (a.status !== 'PENDING' && b.status === 'PENDING') { + return 1; + } + if (a.student.grade === b.student.grade) { if (a.student.room === b.student.room) { return a.student.number - b.student.number; @@ -30,6 +37,5 @@ export const outGoingDataFilter = ( } return a.student.grade - b.student.grade; }); - return sortedData; }; diff --git a/src/utils/Out/outSleepingDataFilter.ts b/src/utils/Out/outSleepingDataFilter.ts index 470f0b0..2f4785c 100644 --- a/src/utils/Out/outSleepingDataFilter.ts +++ b/src/utils/Out/outSleepingDataFilter.ts @@ -1,19 +1,26 @@ -import { OutResponse } from "types/Out/out.type"; -import { changeRoom } from "utils/Member/changeGrade"; +import { OutResponse } from 'types/Out/out.type'; +import { changeRoom } from 'utils/Member/changeGrade'; export const outSleepingDataFilter = ( OffBaseLeave: OutResponse | undefined, studentName: string, selectGrade: number, selectApproval: string | undefined, - selectRoom: string, + selectRoom: string ) => { return OffBaseLeave?.data .filter((pass) => pass.student.name.includes(studentName)) .filter((data) => data.student.grade === selectGrade || selectGrade === 0) - .filter((data) => data.status === selectApproval || selectApproval === "") + .filter((data) => data.status === selectApproval || selectApproval === '') .filter((data) => data.student?.room === changeRoom(selectRoom) || changeRoom(selectRoom) === 0) .sort((a, b) => { + if (a.status === 'PENDING' && b.status !== 'PENDING') { + return -1; + } + if (a.status !== 'PENDING' && b.status === 'PENDING') { + return 1; + } + if (a.student.grade === b.student.grade) { if (a.student.room === b.student.room) { return a.student.number - b.student.number;