mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
93 lines
2.4 KiB
TypeScript
93 lines
2.4 KiB
TypeScript
import { msg } from '@lingui/core/macro';
|
|
import { useLingui } from '@lingui/react';
|
|
import { Trans } from '@lingui/react/macro';
|
|
|
|
import type { TDuplicateTemplateMutationSchema } from '@hanzo/esign-trpc/server/template-router/schema';
|
|
import { useZapMutation } from '@hanzo/esign-trpc/zap/react';
|
|
import { Button } from '@hanzo/esign-ui/primitives/button';
|
|
import {
|
|
Dialog,
|
|
DialogContent,
|
|
DialogDescription,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogTitle,
|
|
} from '@hanzo/esign-ui/primitives/dialog';
|
|
import { useToast } from '@hanzo/esign-ui/primitives/use-toast';
|
|
|
|
type TemplateDuplicateDialogProps = {
|
|
id: number;
|
|
open: boolean;
|
|
onOpenChange: (_open: boolean) => void;
|
|
};
|
|
|
|
export const TemplateDuplicateDialog = ({
|
|
id,
|
|
open,
|
|
onOpenChange,
|
|
}: TemplateDuplicateDialogProps) => {
|
|
const { _ } = useLingui();
|
|
const { toast } = useToast();
|
|
|
|
const { mutateAsync: duplicateTemplate, isPending } = useZapMutation<
|
|
unknown,
|
|
TDuplicateTemplateMutationSchema
|
|
>('template.duplicateTemplate', {
|
|
onSuccess: () => {
|
|
toast({
|
|
title: _(msg`Template duplicated`),
|
|
description: _(msg`Your template has been duplicated successfully.`),
|
|
duration: 5000,
|
|
});
|
|
|
|
onOpenChange(false);
|
|
},
|
|
onError: () => {
|
|
toast({
|
|
title: _(msg`Error`),
|
|
description: _(msg`An error occurred while duplicating template.`),
|
|
variant: 'destructive',
|
|
});
|
|
},
|
|
});
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={(value) => !isPending && onOpenChange(value)}>
|
|
<DialogContent>
|
|
<DialogHeader>
|
|
<DialogTitle>
|
|
<Trans>Do you want to duplicate this template?</Trans>
|
|
</DialogTitle>
|
|
|
|
<DialogDescription className="pt-2">
|
|
<Trans>Your template will be duplicated.</Trans>
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
|
|
<DialogFooter>
|
|
<Button
|
|
type="button"
|
|
disabled={isPending}
|
|
variant="secondary"
|
|
onClick={() => onOpenChange(false)}
|
|
>
|
|
<Trans>Cancel</Trans>
|
|
</Button>
|
|
|
|
<Button
|
|
type="button"
|
|
loading={isPending}
|
|
onClick={async () =>
|
|
duplicateTemplate({
|
|
templateId: id,
|
|
})
|
|
}
|
|
>
|
|
<Trans>Duplicate</Trans>
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
);
|
|
};
|