mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 08:42:12 +10:00
fix: additional backwards compat
This commit is contained in:
@ -12,6 +12,7 @@ import { DEFAULT_DOCUMENT_TIME_ZONE } from '../constants/time-zones';
|
||||
import type { TDocumentLite, TDocumentMany } from '../types/document';
|
||||
import { DEFAULT_DOCUMENT_EMAIL_SETTINGS } from '../types/document-email';
|
||||
import { mapSecondaryIdToDocumentId } from './envelope';
|
||||
import { mapRecipientToLegacyRecipient } from './recipients';
|
||||
|
||||
export const isDocumentCompleted = (document: Pick<Envelope, 'status'> | DocumentStatus) => {
|
||||
const status = typeof document === 'string' ? document : document.status;
|
||||
@ -84,6 +85,7 @@ export const mapEnvelopeToDocumentLite = (envelope: Envelope): TDocumentLite =>
|
||||
formValues: envelope.formValues,
|
||||
title: envelope.title,
|
||||
createdAt: envelope.createdAt,
|
||||
documentDataId: '', // Backwards compatibility.
|
||||
updatedAt: envelope.updatedAt,
|
||||
completedAt: envelope.completedAt,
|
||||
deletedAt: envelope.deletedAt,
|
||||
@ -122,6 +124,7 @@ export const mapEnvelopesToDocumentMany = (
|
||||
formValues: envelope.formValues,
|
||||
title: envelope.title,
|
||||
createdAt: envelope.createdAt,
|
||||
documentDataId: '', // Backwards compatibility.
|
||||
updatedAt: envelope.updatedAt,
|
||||
completedAt: envelope.completedAt,
|
||||
deletedAt: envelope.deletedAt,
|
||||
@ -138,6 +141,8 @@ export const mapEnvelopesToDocumentMany = (
|
||||
id: envelope.teamId,
|
||||
url: envelope.team.url,
|
||||
},
|
||||
recipients: envelope.recipients,
|
||||
recipients: envelope.recipients.map((recipient) =>
|
||||
mapRecipientToLegacyRecipient(recipient, envelope),
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
import type { Field } from '@prisma/client';
|
||||
import { type Envelope, type Field } from '@prisma/client';
|
||||
|
||||
import { extractLegacyIds } from '../universal/id';
|
||||
|
||||
/**
|
||||
* Sort the fields by the Y position on the document.
|
||||
@ -63,3 +65,15 @@ export const validateFieldsUninserted = (): boolean => {
|
||||
|
||||
return errorElements.length === 0;
|
||||
};
|
||||
|
||||
export const mapFieldToLegacyField = (
|
||||
field: Field,
|
||||
envelope: Pick<Envelope, 'type' | 'secondaryId'>,
|
||||
) => {
|
||||
const legacyId = extractLegacyIds(envelope);
|
||||
|
||||
return {
|
||||
...field,
|
||||
...legacyId,
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import type { Envelope } from '@prisma/client';
|
||||
import { type Field, type Recipient, RecipientRole, SigningStatus } from '@prisma/client';
|
||||
|
||||
import { NEXT_PUBLIC_WEBAPP_URL } from '../constants/app';
|
||||
import { extractLegacyIds } from '../universal/id';
|
||||
|
||||
export const formatSigningLink = (token: string) => `${NEXT_PUBLIC_WEBAPP_URL()}/sign/${token}`;
|
||||
|
||||
@ -44,3 +46,15 @@ export const canRecipientFieldsBeModified = (recipient: Recipient, fields: Field
|
||||
|
||||
return recipient.role !== RecipientRole.VIEWER && recipient.role !== RecipientRole.CC;
|
||||
};
|
||||
|
||||
export const mapRecipientToLegacyRecipient = (
|
||||
recipient: Recipient,
|
||||
envelope: Pick<Envelope, 'type' | 'secondaryId'>,
|
||||
) => {
|
||||
const legacyId = extractLegacyIds(envelope);
|
||||
|
||||
return {
|
||||
...recipient,
|
||||
...legacyId,
|
||||
};
|
||||
};
|
||||
|
||||
@ -65,5 +65,6 @@ export const mapEnvelopeToTemplateLite = (envelope: Envelope): TTemplateLite =>
|
||||
publicDescription: envelope.publicDescription,
|
||||
folderId: envelope.folderId,
|
||||
useLegacyFieldInsertion: envelope.useLegacyFieldInsertion,
|
||||
templateDocumentDataId: '',
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user