fix: date filter for deleted documents

This commit is contained in:
Ephraim Atta-Duncan
2024-06-13 07:22:01 +00:00
committed by Mythie
parent 73e375938c
commit a9adc36732
2 changed files with 18 additions and 6 deletions

View File

@ -92,7 +92,13 @@ export const DocumentsDataTable = ({
{ {
header: 'Status', header: 'Status',
accessorKey: 'status', accessorKey: 'status',
cell: ({ row }) => <DocumentStatus status={row.getValue('status')} />, cell: ({ row }) => {
const status = row.original.deletedAt
? ExtendedDocumentStatus.BIN
: (row.getValue('status') as ExtendedDocumentStatus);
return <DocumentStatus status={status} />;
},
size: 140, size: 140,
}, },
{ {

View File

@ -167,6 +167,12 @@ export const findDocuments = async ({
}; };
} }
if (status === ExtendedDocumentStatus.BIN) {
whereClause.deletedAt = {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(),
};
}
if (senderIds && senderIds.length > 0) { if (senderIds && senderIds.length > 0) {
whereClause.userId = { whereClause.userId = {
in: senderIds, in: senderIds,
@ -309,7 +315,7 @@ const findDocumentsFilter = (status: ExtendedDocumentStatus, user: User) => {
teamId: null, teamId: null,
status: ExtendedDocumentStatus.COMPLETED, status: ExtendedDocumentStatus.COMPLETED,
deletedAt: { deletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), not: null,
}, },
}, },
{ {
@ -318,7 +324,7 @@ const findDocumentsFilter = (status: ExtendedDocumentStatus, user: User) => {
some: { some: {
email: user.email, email: user.email,
documentDeletedAt: { documentDeletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), not: null,
}, },
}, },
}, },
@ -510,7 +516,7 @@ const findTeamDocumentsFilter = (
{ {
teamId: team.id, teamId: team.id,
deletedAt: { deletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), not: null,
}, },
}, },
], ],
@ -523,7 +529,7 @@ const findTeamDocumentsFilter = (
email: teamEmail, email: teamEmail,
}, },
deletedAt: { deletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), not: null,
}, },
}, },
{ {
@ -531,7 +537,7 @@ const findTeamDocumentsFilter = (
some: { some: {
email: teamEmail, email: teamEmail,
documentDeletedAt: { documentDeletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(), not: null,
}, },
}, },
}, },