diff --git a/packages/shared-libs/src/lib/date-string-converter.ts b/packages/shared-libs/src/lib/date-string-converter.ts index c442bef9..307abe7c 100644 --- a/packages/shared-libs/src/lib/date-string-converter.ts +++ b/packages/shared-libs/src/lib/date-string-converter.ts @@ -1,4 +1,4 @@ -import { addDays, lastDayOfMonth, setHours, subDays } from 'date-fns' +import { addDays, lastDayOfMonth, setHours, subDays, subMonths } from 'date-fns' export const extractDueDate = ({ dateOperator, @@ -157,6 +157,13 @@ export const fromDateStringToDateObject = ( } } + if (['prev-week'].includes(dateStr)) { + const [mon, sat] = getMondayNSaturdayInWeek(subDays(new Date(), 7)) + + config.startDate = mon + config.endDate = sat + } + if (['month', 'this-month'].includes(dateStr)) { const [firstDate, lastDate] = getStartNEndDateOfMonth(new Date()) @@ -179,26 +186,13 @@ export const fromDateStringToDateObject = ( } if (['prev-month'].includes(dateStr)) { - const date = new Date() - const lastDateOfPrevMonth = new Date( - date.getFullYear(), - date.getMonth(), - 1, - 0, - 0, - 0 - ) - lastDateOfPrevMonth.setDate(lastDateOfPrevMonth.getDate() - 1) - - config.startDate = new Date( - date.getFullYear(), - date.getMonth() - 1, - 1, - 0, - 0, - 0 - ) - config.endDate = lastDateOfPrevMonth + const date = subMonths(new Date(), 1) + const [firstDate, lastDate] = getStartNEndDateOfMonth(date) + + to00h00m(firstDate) + to23h59m(lastDate) + config.startDate = firstDate + config.endDate = lastDate } return config diff --git a/packages/ui-app/app/_features/TaskFilter/index.tsx b/packages/ui-app/app/_features/TaskFilter/index.tsx index 80bfdb5d..6659b46c 100644 --- a/packages/ui-app/app/_features/TaskFilter/index.tsx +++ b/packages/ui-app/app/_features/TaskFilter/index.tsx @@ -98,21 +98,21 @@ export default function TaskFilter({ ) : ( <> - {date && showOperator.includes(date) && ( - { - setFilterValue('dateOperator', val) - }} - className="w-[100px] mr-1" - width={100} - options={[ - { id: '=', title: 'Equal' }, - { id: '>', title: 'After' }, - { id: '<', title: 'Before' } - ]} - /> - )} + {/* {date && showOperator.includes(date) && ( */} + {/* { */} + {/* setFilterValue('dateOperator', val) */} + {/* }} */} + {/* className="w-[100px] mr-1" */} + {/* width={100} */} + {/* options={[ */} + {/* { id: '=', title: 'Equal' }, */} + {/* { id: '>', title: 'After' }, */} + {/* { id: '<', title: 'Before' } */} + {/* ]} */} + {/* /> */} + {/* )} */}