import { useLingui } from '@lingui/react'; import type { DocumentMeta, Signature, TemplateMeta } from '@prisma/client'; import { FieldType } from '@prisma/client'; import { ChevronDown } from 'lucide-react'; import { DEFAULT_DOCUMENT_DATE_FORMAT, convertToLocalSystemFormat, } from '@documenso/lib/constants/date-formats'; import type { TFieldMetaSchema } from '@documenso/lib/types/field-meta'; import { fromCheckboxValue } from '@documenso/lib/universal/field-checkbox'; import { cn } from '../../lib/utils'; import { Checkbox } from '../checkbox'; import { Label } from '../label'; import { RadioGroup, RadioGroupItem } from '../radio-group'; import { FRIENDLY_FIELD_TYPE } from './types'; type FieldIconProps = { /** * Loose field type since this is used for partial fields. */ field: { inserted?: boolean; customText?: string; type: FieldType; fieldMeta?: TFieldMetaSchema | null; signature?: Signature | null; }; documentMeta?: DocumentMeta | TemplateMeta; }; /** * Renders the content inside field containers prior to sealing. */ export const FieldContent = ({ field, documentMeta }: FieldIconProps) => { const { _ } = useLingui(); const { type, fieldMeta } = field; // Only render checkbox if values exist, otherwise render the empty checkbox field content. if ( field.type === FieldType.CHECKBOX && field.fieldMeta?.type === 'checkbox' && field.fieldMeta.values && field.fieldMeta.values.length > 0 ) { let checkedValues: string[] = []; try { checkedValues = fromCheckboxValue(field.customText ?? ''); } catch (err) { // Do nothing. console.error(err); } return (
Select