fix: dateformat api bug (#1238)

Fixes support for date formats when using the API
This commit is contained in:
Catalin Pit
2024-07-30 08:13:22 +02:00
committed by GitHub
parent f31caaab08
commit 4b485268ca
3 changed files with 75 additions and 7 deletions

View File

@ -1,5 +1,9 @@
import { extendZodWithOpenApi } from '@anatine/zod-openapi';
import { z } from 'zod';
import { DATE_FORMATS, DEFAULT_DOCUMENT_DATE_FORMAT } from '@documenso/lib/constants/date-formats';
import '@documenso/lib/constants/time-zones';
import { DEFAULT_DOCUMENT_TIME_ZONE, TIME_ZONES } from '@documenso/lib/constants/time-zones';
import { ZUrlSchema } from '@documenso/lib/schemas/common';
import {
DocumentDataType,
@ -11,6 +15,8 @@ import {
TemplateType,
} from '@documenso/prisma/client';
extendZodWithOpenApi(z);
export const ZNoBodyMutationSchema = null;
/**
@ -97,8 +103,19 @@ export const ZCreateDocumentMutationSchema = z.object({
.object({
subject: z.string(),
message: z.string(),
timezone: z.string(),
dateFormat: z.string(),
timezone: z.string().default(DEFAULT_DOCUMENT_TIME_ZONE).openapi({
description:
'The timezone of the date. Must be one of the options listed in the list below.',
enum: TIME_ZONES,
}),
dateFormat: z
.string()
.default(DEFAULT_DOCUMENT_DATE_FORMAT)
.openapi({
description:
'The format of the date. Must be one of the options listed in the list below.',
enum: DATE_FORMATS.map((format) => format.value),
}),
redirectUrl: z.string(),
})
.partial(),