import { Plural, Trans } from '@lingui/react/macro'; import { FolderType } from '@prisma/client'; import { ArrowRightIcon, FolderIcon, FolderPlusIcon, MoreVerticalIcon, PinIcon, SettingsIcon, TrashIcon, } from 'lucide-react'; import { Link } from 'react-router'; import { formatDocumentsPath, formatTemplatesPath } from '@documenso/lib/utils/teams'; import { trpc } from '@documenso/trpc/react'; import { type TFolderWithSubfolders } from '@documenso/trpc/server/folder-router/schema'; import { Button } from '@documenso/ui/primitives/button'; import { Card, CardContent } from '@documenso/ui/primitives/card'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '@documenso/ui/primitives/dropdown-menu'; import { useCurrentTeam } from '~/providers/team'; export type FolderCardProps = { folder: TFolderWithSubfolders; onMove: (folder: TFolderWithSubfolders) => void; onSettings: (folder: TFolderWithSubfolders) => void; onDelete: (folder: TFolderWithSubfolders) => void; }; export const FolderCard = ({ folder, onMove, onSettings, onDelete }: FolderCardProps) => { const team = useCurrentTeam(); const { mutateAsync: updateFolderMutation } = trpc.folder.updateFolder.useMutation(); const formatPath = () => { const rootPath = folder.type === FolderType.DOCUMENT ? formatDocumentsPath(team.url) : formatTemplatesPath(team.url); return `${rootPath}/f/${folder.id}`; }; const updateFolder = async ({ pinned }: { pinned: boolean }) => { await updateFolderMutation({ folderId: folder.id, data: { pinned, }, }); }; return ( {folder.name} {folder.pinned && } {folder.type === FolderType.TEMPLATE ? ( # template} other={# templates} /> ) : ( # document} other={# documents} /> )} • # folder} other={# folders} /> e.stopPropagation()} align="end"> onMove(folder)}> Move updateFolder({ pinned: !folder.pinned })}> {folder.pinned ? Unpin : Pin} onSettings(folder)}> Settings onDelete(folder)}> Delete ); }; export const FolderCardEmpty = ({ type }: { type: FolderType }) => { return ( Create folder {type === FolderType.DOCUMENT ? ( Organise your documents ) : ( Organise your templates )} ); };