Files
sign/apps/web/src/components/formatter/document-status.tsx

69 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-06-09 18:21:18 +10:00
import { HTMLAttributes } from 'react';
import { CheckCircle2, Clock, File } from 'lucide-react';
import type { LucideIcon } from 'lucide-react/dist/lucide-react';
2023-06-09 18:21:18 +10:00
2023-08-24 16:50:40 +10:00
import { ExtendedDocumentStatus } from '@documenso/prisma/types/extended-document-status';
import { SignatureIcon } from '@documenso/ui/icons/signature';
2023-06-09 18:21:18 +10:00
import { cn } from '@documenso/ui/lib/utils';
type FriendlyStatus = {
label: string;
2023-08-24 16:50:40 +10:00
icon?: LucideIcon;
2023-06-09 18:21:18 +10:00
color: string;
};
2023-08-24 16:50:40 +10:00
const FRIENDLY_STATUS_MAP: Record<ExtendedDocumentStatus, FriendlyStatus> = {
2023-06-09 18:21:18 +10:00
PENDING: {
label: 'Pending',
icon: Clock,
color: 'text-blue-600',
},
COMPLETED: {
label: 'Completed',
icon: CheckCircle2,
color: 'text-green-500',
},
2023-08-16 09:29:16 +02:00
DRAFT: {
label: 'Draft',
icon: File,
color: 'text-yellow-500',
},
2023-08-24 16:50:40 +10:00
INBOX: {
label: 'Inbox',
icon: SignatureIcon,
color: 'text-muted-foreground',
},
ALL: {
label: 'All',
color: 'text-muted-foreground',
},
2023-06-09 18:21:18 +10:00
};
export type DocumentStatusProps = HTMLAttributes<HTMLSpanElement> & {
2023-08-24 16:50:40 +10:00
status: ExtendedDocumentStatus;
inheritColor?: boolean;
2023-06-09 18:21:18 +10:00
};
export const DocumentStatus = ({
className,
status,
inheritColor,
...props
}: DocumentStatusProps) => {
2023-06-09 18:21:18 +10:00
const { label, icon: Icon, color } = FRIENDLY_STATUS_MAP[status];
return (
<span className={cn('flex items-center', className)} {...props}>
2023-08-24 16:50:40 +10:00
{Icon && (
<Icon
className={cn('mr-2 inline-block h-4 w-4', {
[color]: !inheritColor,
})}
/>
)}
2023-06-09 18:21:18 +10:00
{label}
</span>
);
};