import { DOCUMENT_VISIBILITY } from '@documenso/lib/constants/document-visibility'; import { type TDocumentEmailSettings, ZDocumentEmailSettingsSchema } from '@documenso/lib/types/document-email'; import type { MessageDescriptor } from '@lingui/core'; import { msg } from '@lingui/core/macro'; import { useLingui } from '@lingui/react'; import { Trans } from '@lingui/react/macro'; import type { OrganisationGlobalSettings, TeamGlobalSettings } from '@prisma/client'; import { DetailsCard, DetailsValue } from '~/components/general/admin-details'; const EMAIL_SETTINGS_LABELS: Record = { recipientSigningRequest: msg`Recipient signing request`, recipientRemoved: msg`Recipient removed`, recipientSigned: msg`Recipient signed`, documentPending: msg`Document pending`, documentCompleted: msg`Document completed`, documentDeleted: msg`Document deleted`, ownerDocumentCompleted: msg`Owner document completed`, ownerRecipientExpired: msg`Owner recipient expired`, ownerDocumentCreated: msg`Owner document created`, }; const emailSettingsKeys = Object.keys(EMAIL_SETTINGS_LABELS) as (keyof TDocumentEmailSettings)[]; type AdminGlobalSettingsSectionProps = { settings: TeamGlobalSettings | OrganisationGlobalSettings | null; isTeam?: boolean; }; export const AdminGlobalSettingsSection = ({ settings, isTeam = false }: AdminGlobalSettingsSectionProps) => { const { _ } = useLingui(); const notSetLabel = isTeam ? Inherited : Not set; if (!settings) { return null; } const textValue = (value: string | null | undefined) => { if (value === null || value === undefined) { return notSetLabel; } return value; }; const brandingTextValue = (value: string | null | undefined) => { if (value === null || value === undefined || value.trim() === '') { return notSetLabel; } return value; }; const booleanValue = (value: boolean | null | undefined) => { if (value === null || value === undefined) { return notSetLabel; } return value ? Enabled : Disabled; }; const parsedEmailSettings = ZDocumentEmailSettingsSchema.safeParse(settings.emailDocumentSettings); return (
Document visibility}> {settings.documentVisibility != null ? _(DOCUMENT_VISIBILITY[settings.documentVisibility].value) : notSetLabel} Document language}> {textValue(settings.documentLanguage)} Document timezone}> {textValue(settings.documentTimezone)} Date format}> {textValue(settings.documentDateFormat)} Include sender details}> {booleanValue(settings.includeSenderDetails)} Include signing certificate}> {booleanValue(settings.includeSigningCertificate)} Include audit log}> {booleanValue(settings.includeAuditLog)} Delegate document ownership}> {booleanValue(settings.delegateDocumentOwnership)} Typed signature}> {booleanValue(settings.typedSignatureEnabled)} Upload signature}> {booleanValue(settings.uploadSignatureEnabled)} Draw signature}> {booleanValue(settings.drawSignatureEnabled)} Branding}> {booleanValue(settings.brandingEnabled)} Branding logo}> {brandingTextValue(settings.brandingLogo)} Branding URL}> {brandingTextValue(settings.brandingUrl)} Branding company details}> {brandingTextValue(settings.brandingCompanyDetails)} Email reply-to}> {textValue(settings.emailReplyTo)} {isTeam && parsedEmailSettings.success && ( Email document settings}>
{emailSettingsKeys.map((key) => (
{_(EMAIL_SETTINGS_LABELS[key])} {parsedEmailSettings.data[key] ? On : Off}
))}
)} AI features}> {booleanValue(settings.aiFeaturesEnabled)}
); };