mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
20 lines
685 B
TypeScript
20 lines
685 B
TypeScript
import type { EnvelopeItem } from '@prisma/client';
|
|
|
|
import { NEXT_PUBLIC_WEBAPP_URL } from '../constants/app';
|
|
|
|
export type EnvelopeDownloadUrlOptions = {
|
|
envelopeItem: Pick<EnvelopeItem, 'id' | 'envelopeId'>;
|
|
token: string | undefined;
|
|
version: 'original' | 'signed';
|
|
};
|
|
|
|
export const getEnvelopeDownloadUrl = (options: EnvelopeDownloadUrlOptions) => {
|
|
const { envelopeItem, token, version } = options;
|
|
|
|
const { id, envelopeId } = envelopeItem;
|
|
|
|
return token
|
|
? `${NEXT_PUBLIC_WEBAPP_URL()}/api/files/token/${token}/envelopeItem/${id}/download/${version}`
|
|
: `${NEXT_PUBLIC_WEBAPP_URL()}/api/files/envelope/${envelopeId}/envelopeItem/${id}/download/${version}`;
|
|
};
|