mirror of
https://github.com/documenso/documenso.git
synced 2026-07-09 20:45:00 +10:00
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:
@@ -1,8 +1,7 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { plural } from '@lingui/core/macro';
|
||||
import { Plural, useLingui } from '@lingui/react/macro';
|
||||
import { Trans } from '@lingui/react/macro';
|
||||
import { Plural, Trans, useLingui } from '@lingui/react/macro';
|
||||
import { DocumentStatus } from '@prisma/client';
|
||||
import type * as DialogPrimitive from '@radix-ui/react-dialog';
|
||||
import { match } from 'ts-pattern';
|
||||
@@ -40,8 +39,6 @@ export type EnvelopesBulkDownloadDialogProps = {
|
||||
onSuccess?: (successfulEnvelopeIds: string[]) => void;
|
||||
} & Omit<DialogPrimitive.DialogProps, 'children'>;
|
||||
|
||||
type DownloadVersion = 'signed' | 'original';
|
||||
|
||||
export const EnvelopesBulkDownloadDialog = ({
|
||||
envelopes,
|
||||
open,
|
||||
@@ -52,7 +49,7 @@ export const EnvelopesBulkDownloadDialog = ({
|
||||
const { t } = useLingui();
|
||||
const { toast } = useToast();
|
||||
|
||||
const [versionMap, setVersionMap] = useState<Record<string, DownloadVersion>>({});
|
||||
const [versionMap, setVersionMap] = useState<Record<string, 'signed' | 'original'>>({});
|
||||
const [progress, setProgress] = useState(0);
|
||||
const [isDownloading, setIsDownloading] = useState(false);
|
||||
|
||||
@@ -74,7 +71,6 @@ export const EnvelopesBulkDownloadDialog = ({
|
||||
),
|
||||
);
|
||||
setProgress(0);
|
||||
// Only reset selections/progress when the dialog transitions to open.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [open]);
|
||||
|
||||
@@ -105,10 +101,7 @@ export const EnvelopesBulkDownloadDialog = ({
|
||||
}
|
||||
|
||||
try {
|
||||
const downloadVersion: DownloadVersion =
|
||||
versionMap[envelope.id] === 'signed' && envelope.status === DocumentStatus.COMPLETED
|
||||
? 'signed'
|
||||
: 'original';
|
||||
const downloadVersion = versionMap[envelope.id] ?? 'original';
|
||||
|
||||
const { data: envelopeItems } = await trpcUtils.envelope.item.getManyByToken.fetch({
|
||||
envelopeId: envelope.id,
|
||||
@@ -225,11 +218,12 @@ export const EnvelopesBulkDownloadDialog = ({
|
||||
{isCompleted && (
|
||||
<Select
|
||||
value={versionMap[envelope.id] ?? 'signed'}
|
||||
onValueChange={(value) => {
|
||||
if (value === 'signed' || value === 'original') {
|
||||
setVersionMap((prev) => ({ ...prev, [envelope.id]: value }));
|
||||
}
|
||||
}}
|
||||
onValueChange={(value) =>
|
||||
setVersionMap((prev) => ({
|
||||
...prev,
|
||||
[envelope.id]: value as 'signed' | 'original',
|
||||
}))
|
||||
}
|
||||
>
|
||||
<SelectTrigger className="w-[120px] flex-shrink-0">
|
||||
<SelectValue />
|
||||
|
||||
@@ -102,13 +102,9 @@ export const EnvelopesTableBulkActionBar = ({
|
||||
size="sm"
|
||||
onClick={onClearSelection}
|
||||
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" />
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="pointer-fine:hidden -translate-1/2 absolute left-1/2 top-1/2 size-[max(100%,3rem)]"
|
||||
/>
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user