From 2c1a18bafc2758d77d927782683f23f6f7b67350 Mon Sep 17 00:00:00 2001
From: Ephraim Duncan <55143799+ephraimduncan@users.noreply.github.com>
Date: Wed, 9 Oct 2024 01:25:56 +0000
Subject: [PATCH] fix: stacked avatar colors (#1361)
---
.../avatar/stack-avatars-with-tooltip.tsx | 18 +++++----
.../(dashboard)/avatar/stack-avatars.tsx | 26 +++++++++----
packages/lib/client-only/recipient-type.ts | 38 ++++++++++++++++---
packages/lib/translations/de/web.po | 8 ++--
packages/lib/translations/en/web.po | 8 ++--
packages/lib/translations/fr/web.po | 8 ++--
6 files changed, 74 insertions(+), 32 deletions(-)
diff --git a/apps/web/src/components/(dashboard)/avatar/stack-avatars-with-tooltip.tsx b/apps/web/src/components/(dashboard)/avatar/stack-avatars-with-tooltip.tsx
index 76a80805f..c859c332a 100644
--- a/apps/web/src/components/(dashboard)/avatar/stack-avatars-with-tooltip.tsx
+++ b/apps/web/src/components/(dashboard)/avatar/stack-avatars-with-tooltip.tsx
@@ -1,9 +1,11 @@
'use client';
+import { useMemo } from 'react';
+
import { Trans } from '@lingui/macro';
import { useLingui } from '@lingui/react';
-import { getRecipientType } from '@documenso/lib/client-only/recipient-type';
+import { RecipientStatusType, getRecipientType } from '@documenso/lib/client-only/recipient-type';
import { RECIPIENT_ROLES_DESCRIPTION } from '@documenso/lib/constants/recipient-roles';
import { recipientAbbreviation } from '@documenso/lib/utils/recipient-formatter';
import type { DocumentStatus, Recipient } from '@documenso/prisma/client';
@@ -29,24 +31,26 @@ export const StackAvatarsWithTooltip = ({
const { _ } = useLingui();
const waitingRecipients = recipients.filter(
- (recipient) => getRecipientType(recipient) === 'waiting',
+ (recipient) => getRecipientType(recipient) === RecipientStatusType.WAITING,
);
const openedRecipients = recipients.filter(
- (recipient) => getRecipientType(recipient) === 'opened',
+ (recipient) => getRecipientType(recipient) === RecipientStatusType.OPENED,
);
const completedRecipients = recipients.filter(
- (recipient) => getRecipientType(recipient) === 'completed',
+ (recipient) => getRecipientType(recipient) === RecipientStatusType.COMPLETED,
);
const uncompletedRecipients = recipients.filter(
- (recipient) => getRecipientType(recipient) === 'unsigned',
+ (recipient) => getRecipientType(recipient) === RecipientStatusType.UNSIGNED,
);
+ const sortedRecipients = useMemo(() => recipients.sort((a, b) => a.id - b.id), [recipients]);
+
return (
{recipient.email}
{_(RECIPIENT_ROLES_DESCRIPTION[recipient.role].roleName)}
diff --git a/apps/web/src/components/(dashboard)/avatar/stack-avatars.tsx b/apps/web/src/components/(dashboard)/avatar/stack-avatars.tsx
index 69e7d1142..95621c760 100644
--- a/apps/web/src/components/(dashboard)/avatar/stack-avatars.tsx
+++ b/apps/web/src/components/(dashboard)/avatar/stack-avatars.tsx
@@ -1,6 +1,9 @@
import React from 'react';
-import { getRecipientType } from '@documenso/lib/client-only/recipient-type';
+import {
+ getExtraRecipientsType,
+ getRecipientType,
+} from '@documenso/lib/client-only/recipient-type';
import { recipientAbbreviation } from '@documenso/lib/utils/recipient-formatter';
import type { Recipient } from '@documenso/prisma/client';
@@ -13,20 +16,27 @@ export function StackAvatars({ recipients }: { recipients: Recipient[] }) {
const remainingItems = recipients.length - itemsToRender.length;
return itemsToRender.map((recipient: Recipient, index: number) => {
- const first = index === 0 ? true : false;
+ const first = index === 0;
- const lastItemText =
- index === itemsToRender.length - 1 && remainingItems > 0
- ? `+${remainingItems + 1}`
- : undefined;
+ if (index === 4 && remainingItems > 0) {
+ return (
+