chore: deslop bulk download dialog and action bar

Merge duplicate lingui imports, drop redundant state-reset comment,
simplify Select onValueChange to match codebase style, and remove
broken tap-target span with invalid Tailwind 3.4 classes
(pointer-fine:, -translate-1/2).
This commit is contained in:
ephraimduncan
2026-04-20 18:57:43 +00:00
parent 5b64137237
commit 278dfa3d77
2 changed files with 10 additions and 20 deletions
@@ -1,8 +1,7 @@
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { plural } from '@lingui/core/macro'; import { plural } from '@lingui/core/macro';
import { Plural, useLingui } from '@lingui/react/macro'; import { Plural, Trans, useLingui } from '@lingui/react/macro';
import { Trans } from '@lingui/react/macro';
import { DocumentStatus } from '@prisma/client'; import { DocumentStatus } from '@prisma/client';
import type * as DialogPrimitive from '@radix-ui/react-dialog'; import type * as DialogPrimitive from '@radix-ui/react-dialog';
import { match } from 'ts-pattern'; import { match } from 'ts-pattern';
@@ -40,8 +39,6 @@ export type EnvelopesBulkDownloadDialogProps = {
onSuccess?: (successfulEnvelopeIds: string[]) => void; onSuccess?: (successfulEnvelopeIds: string[]) => void;
} & Omit<DialogPrimitive.DialogProps, 'children'>; } & Omit<DialogPrimitive.DialogProps, 'children'>;
type DownloadVersion = 'signed' | 'original';
export const EnvelopesBulkDownloadDialog = ({ export const EnvelopesBulkDownloadDialog = ({
envelopes, envelopes,
open, open,
@@ -52,7 +49,7 @@ export const EnvelopesBulkDownloadDialog = ({
const { t } = useLingui(); const { t } = useLingui();
const { toast } = useToast(); const { toast } = useToast();
const [versionMap, setVersionMap] = useState<Record<string, DownloadVersion>>({}); const [versionMap, setVersionMap] = useState<Record<string, 'signed' | 'original'>>({});
const [progress, setProgress] = useState(0); const [progress, setProgress] = useState(0);
const [isDownloading, setIsDownloading] = useState(false); const [isDownloading, setIsDownloading] = useState(false);
@@ -74,7 +71,6 @@ export const EnvelopesBulkDownloadDialog = ({
), ),
); );
setProgress(0); setProgress(0);
// Only reset selections/progress when the dialog transitions to open.
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]); }, [open]);
@@ -105,10 +101,7 @@ export const EnvelopesBulkDownloadDialog = ({
} }
try { try {
const downloadVersion: DownloadVersion = const downloadVersion = versionMap[envelope.id] ?? 'original';
versionMap[envelope.id] === 'signed' && envelope.status === DocumentStatus.COMPLETED
? 'signed'
: 'original';
const { data: envelopeItems } = await trpcUtils.envelope.item.getManyByToken.fetch({ const { data: envelopeItems } = await trpcUtils.envelope.item.getManyByToken.fetch({
envelopeId: envelope.id, envelopeId: envelope.id,
@@ -225,11 +218,12 @@ export const EnvelopesBulkDownloadDialog = ({
{isCompleted && ( {isCompleted && (
<Select <Select
value={versionMap[envelope.id] ?? 'signed'} value={versionMap[envelope.id] ?? 'signed'}
onValueChange={(value) => { onValueChange={(value) =>
if (value === 'signed' || value === 'original') { setVersionMap((prev) => ({
setVersionMap((prev) => ({ ...prev, [envelope.id]: value })); ...prev,
} [envelope.id]: value as 'signed' | 'original',
}} }))
}
> >
<SelectTrigger className="w-[120px] flex-shrink-0"> <SelectTrigger className="w-[120px] flex-shrink-0">
<SelectValue /> <SelectValue />
@@ -102,13 +102,9 @@ export const EnvelopesTableBulkActionBar = ({
size="sm" size="sm"
onClick={onClearSelection} onClick={onClearSelection}
aria-label={t`Clear selection`} aria-label={t`Clear selection`}
className="relative h-8 w-8 p-0" className="h-8 w-8 p-0"
> >
<XIcon className="size-4 shrink-0" /> <XIcon className="size-4 shrink-0" />
<span
aria-hidden="true"
className="pointer-fine:hidden -translate-1/2 absolute left-1/2 top-1/2 size-[max(100%,3rem)]"
/>
</Button> </Button>
</div> </div>
); );