chore: implemented feedback

This commit is contained in:
Catalin Pit
2023-09-08 12:39:13 +03:00
committed by Mythie
parent 766fc6410b
commit a94b80d07d
2 changed files with 18 additions and 11 deletions

View File

@ -37,9 +37,9 @@ type TCardData = {
| 'NOT_SIGNED' | 'NOT_SIGNED'
| 'SENT' | 'SENT'
| 'NOT_SENT'; | 'NOT_SENT';
}[]; };
const CARD_DATA: TCardData = [ const CARD_DATA: TCardData[] = [
{ {
icon: UserSquare2, icon: UserSquare2,
title: 'Total recipients in the database', title: 'Total recipients in the database',

View File

@ -7,14 +7,21 @@ export const getRecipientsStats = async () => {
_count: true, _count: true,
}); });
return { const stats = {
TOTAL_RECIPIENTS: results.length, TOTAL_RECIPIENTS: 0,
[ReadStatus.OPENED]: results.filter((r) => r.readStatus === 'OPENED')?.[0]?._count ?? 0, [ReadStatus.OPENED]: 0,
[ReadStatus.NOT_OPENED]: results.filter((r) => r.readStatus === 'NOT_OPENED')?.[0]?._count ?? 0, [ReadStatus.NOT_OPENED]: 0,
[SigningStatus.SIGNED]: results.filter((r) => r.signingStatus === 'SIGNED')?.[0]?._count ?? 0, [SigningStatus.SIGNED]: 0,
[SigningStatus.NOT_SIGNED]: [SigningStatus.NOT_SIGNED]: 0,
results.filter((r) => r.signingStatus === 'NOT_SIGNED')?.[0]?._count ?? 0, [SendStatus.SENT]: 0,
[SendStatus.SENT]: results.filter((r) => r.sendStatus === 'SENT')?.[0]?._count ?? 0, [SendStatus.NOT_SENT]: 0,
[SendStatus.NOT_SENT]: results.filter((r) => r.sendStatus === 'NOT_SENT')?.[0]?._count ?? 0,
}; };
results.forEach((result) => {
const { readStatus, signingStatus, sendStatus, _count } = result;
stats[readStatus] += _count;
stats[signingStatus] += _count;
stats[sendStatus] += _count;
stats.TOTAL_RECIPIENTS += _count;
});
return stats;
}; };