patch date filter

This commit is contained in:
Maidul Islam
2024-06-14 20:57:10 -04:00
parent a332019c25
commit ae177343d5
3 changed files with 7 additions and 4 deletions
+2 -1
View File
@@ -143,7 +143,8 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
actorAuthMethod: req.permission.authMethod, actorAuthMethod: req.permission.authMethod,
projectId: req.params.workspaceId, projectId: req.params.workspaceId,
...req.query, ...req.query,
startDate: req.query.endDate || getLastMidnightDateISO(), endDate: req.query.endDate,
startDate: req.query.startDate || getLastMidnightDateISO(),
auditLogActor: req.query.actor, auditLogActor: req.query.actor,
actor: req.permission.type actor: req.permission.type
}); });
@@ -179,8 +179,9 @@ export const LogsFilter = ({ control, reset }: Props) => {
<FormControl label="End date" errorText={error?.message} isError={Boolean(error)}> <FormControl label="End date" errorText={error?.message} isError={Boolean(error)}>
<DatePicker <DatePicker
value={field.value || undefined} value={field.value || undefined}
onChange={(date) => { onChange={(pickedDate) => {
onChange(date); pickedDate?.setHours(23, 59, 59, 999); // we choose the end of today not the start of it (going off of aws cloud watch)
onChange(pickedDate);
setIsEndDatePickerOpen(false); setIsEndDatePickerOpen(false);
}} }}
popUpProps={{ popUpProps={{
@@ -23,7 +23,8 @@ export const LogsSection = () => {
defaultValues: { defaultValues: {
page: 1, page: 1,
perPage: 10, perPage: 10,
startDate: new Date(new Date().setDate(new Date().getDate() - 1)) startDate: new Date(new Date().setDate(new Date().getDate() - 1)), // day before today
endDate: new Date(new Date(Date.now()).setHours(23, 59, 59, 999)) // end of today
} }
}); });