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',
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,
},
{

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) {
whereClause.userId = {
in: senderIds,
@ -309,7 +315,7 @@ const findDocumentsFilter = (status: ExtendedDocumentStatus, user: User) => {
teamId: null,
status: ExtendedDocumentStatus.COMPLETED,
deletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(),
not: null,
},
},
{
@ -318,7 +324,7 @@ const findDocumentsFilter = (status: ExtendedDocumentStatus, user: User) => {
some: {
email: user.email,
documentDeletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(),
not: null,
},
},
},
@ -510,7 +516,7 @@ const findTeamDocumentsFilter = (
{
teamId: team.id,
deletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(),
not: null,
},
},
],
@ -523,7 +529,7 @@ const findTeamDocumentsFilter = (
email: teamEmail,
},
deletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(),
not: null,
},
},
{
@ -531,7 +537,7 @@ const findTeamDocumentsFilter = (
some: {
email: teamEmail,
documentDeletedAt: {
gte: DateTime.now().minus({ days: 30 }).startOf('day').toJSDate(),
not: null,
},
},
},