2024-05-07 17:22:24 +07:00
|
|
|
'use client';
|
|
|
|
|
2024-05-10 19:45:19 +07:00
|
|
|
import React, { forwardRef } from 'react';
|
2024-05-07 17:22:24 +07:00
|
|
|
|
2024-08-27 20:34:39 +09:00
|
|
|
import { Trans } from '@lingui/macro';
|
2024-05-07 17:22:24 +07:00
|
|
|
import type { SelectProps } from '@radix-ui/react-select';
|
|
|
|
import { InfoIcon } from 'lucide-react';
|
|
|
|
|
|
|
|
import { RecipientRole } from '@documenso/prisma/client';
|
|
|
|
import { ROLE_ICONS } from '@documenso/ui/primitives/recipient-role-icons';
|
|
|
|
import { Select, SelectContent, SelectItem, SelectTrigger } from '@documenso/ui/primitives/select';
|
|
|
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@documenso/ui/primitives/tooltip';
|
|
|
|
|
2024-06-02 15:49:09 +10:00
|
|
|
export type RecipientRoleSelectProps = SelectProps & {
|
|
|
|
hideCCRecipients?: boolean;
|
|
|
|
};
|
2024-05-07 17:22:24 +07:00
|
|
|
|
2024-06-02 15:49:09 +10:00
|
|
|
export const RecipientRoleSelect = forwardRef<HTMLButtonElement, RecipientRoleSelectProps>(
|
|
|
|
({ hideCCRecipients, ...props }, ref) => (
|
|
|
|
<Select {...props}>
|
2024-09-16 12:36:45 +00:00
|
|
|
<SelectTrigger ref={ref} className="bg-background w-[50px] p-2">
|
2024-06-02 15:49:09 +10:00
|
|
|
{/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */}
|
|
|
|
{ROLE_ICONS[props.value as RecipientRole]}
|
|
|
|
</SelectTrigger>
|
2024-05-07 17:22:24 +07:00
|
|
|
|
2024-06-02 15:49:09 +10:00
|
|
|
<SelectContent align="end">
|
|
|
|
<SelectItem value={RecipientRole.SIGNER}>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<div className="flex w-[150px] items-center">
|
|
|
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.SIGNER]}</span>
|
2024-08-27 20:34:39 +09:00
|
|
|
<Trans>Needs to sign</Trans>
|
2024-06-02 15:49:09 +10:00
|
|
|
</div>
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger>
|
|
|
|
<InfoIcon className="h-4 w-4" />
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
2024-08-27 20:34:39 +09:00
|
|
|
<p>
|
|
|
|
<Trans>
|
|
|
|
The recipient is required to sign the document for it to be completed.
|
|
|
|
</Trans>
|
|
|
|
</p>
|
2024-06-02 15:49:09 +10:00
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
2024-05-07 17:22:24 +07:00
|
|
|
</div>
|
2024-06-02 15:49:09 +10:00
|
|
|
</SelectItem>
|
2024-05-07 17:22:24 +07:00
|
|
|
|
2024-06-02 15:49:09 +10:00
|
|
|
<SelectItem value={RecipientRole.APPROVER}>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<div className="flex w-[150px] items-center">
|
|
|
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.APPROVER]}</span>
|
2024-08-27 20:34:39 +09:00
|
|
|
<Trans>Needs to approve</Trans>
|
2024-06-02 15:49:09 +10:00
|
|
|
</div>
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger>
|
|
|
|
<InfoIcon className="h-4 w-4" />
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
2024-08-27 20:34:39 +09:00
|
|
|
<p>
|
|
|
|
<Trans>
|
|
|
|
The recipient is required to approve the document for it to be completed.
|
|
|
|
</Trans>
|
|
|
|
</p>
|
2024-06-02 15:49:09 +10:00
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
2024-05-07 17:22:24 +07:00
|
|
|
</div>
|
2024-06-02 15:49:09 +10:00
|
|
|
</SelectItem>
|
2024-05-07 17:22:24 +07:00
|
|
|
|
2024-06-02 15:49:09 +10:00
|
|
|
<SelectItem value={RecipientRole.VIEWER}>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<div className="flex w-[150px] items-center">
|
|
|
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.VIEWER]}</span>
|
2024-08-27 20:34:39 +09:00
|
|
|
<Trans>Needs to view</Trans>
|
2024-06-02 15:49:09 +10:00
|
|
|
</div>
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger>
|
|
|
|
<InfoIcon className="h-4 w-4" />
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
2024-08-27 20:34:39 +09:00
|
|
|
<p>
|
|
|
|
<Trans>
|
|
|
|
The recipient is required to view the document for it to be completed.
|
|
|
|
</Trans>
|
|
|
|
</p>
|
2024-06-02 15:49:09 +10:00
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
2024-05-07 17:22:24 +07:00
|
|
|
</div>
|
2024-06-02 15:49:09 +10:00
|
|
|
</SelectItem>
|
2024-05-07 17:22:24 +07:00
|
|
|
|
2024-06-02 15:49:09 +10:00
|
|
|
{!hideCCRecipients && (
|
|
|
|
<SelectItem value={RecipientRole.CC}>
|
|
|
|
<div className="flex items-center">
|
|
|
|
<div className="flex w-[150px] items-center">
|
|
|
|
<span className="mr-2">{ROLE_ICONS[RecipientRole.CC]}</span>
|
2024-08-27 20:34:39 +09:00
|
|
|
<Trans>Receives copy</Trans>
|
2024-06-02 15:49:09 +10:00
|
|
|
</div>
|
|
|
|
<Tooltip>
|
|
|
|
<TooltipTrigger>
|
|
|
|
<InfoIcon className="h-4 w-4" />
|
|
|
|
</TooltipTrigger>
|
|
|
|
<TooltipContent className="text-foreground z-9999 max-w-md p-4">
|
|
|
|
<p>
|
2024-08-27 20:34:39 +09:00
|
|
|
<Trans>
|
|
|
|
The recipient is not required to take any action and receives a copy of the
|
|
|
|
document after it is completed.
|
|
|
|
</Trans>
|
2024-06-02 15:49:09 +10:00
|
|
|
</p>
|
|
|
|
</TooltipContent>
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</SelectItem>
|
|
|
|
)}
|
|
|
|
</SelectContent>
|
|
|
|
</Select>
|
|
|
|
),
|
|
|
|
);
|
2024-05-10 19:45:19 +07:00
|
|
|
|
|
|
|
RecipientRoleSelect.displayName = 'RecipientRoleSelect';
|