diff --git a/packages/api/v1/implementation.ts b/packages/api/v1/implementation.ts index 6c34fd4d7..b0f2ce150 100644 --- a/packages/api/v1/implementation.ts +++ b/packages/api/v1/implementation.ts @@ -244,18 +244,10 @@ export const ApiContractV1Implementation = createNextRoute(ApiContractV1, { } const dateFormat = body.meta.dateFormat - ? DATE_FORMATS.find((format) => format.label === body.meta.dateFormat) + ? DATE_FORMATS.find((format) => format.value === body.meta.dateFormat) : DATE_FORMATS.find((format) => format.value === DEFAULT_DOCUMENT_DATE_FORMAT); - const timezone = body.meta.timezone - ? TIME_ZONES.find((tz) => tz === body.meta.timezone) - : DEFAULT_DOCUMENT_TIME_ZONE; - const isDateFormatValid = body.meta.dateFormat - ? DATE_FORMATS.some((format) => format.label === dateFormat?.label) - : true; - const isTimeZoneValid = body.meta.timezone ? TIME_ZONES.includes(String(timezone)) : true; - - if (!isDateFormatValid) { + if (body.meta.dateFormat && !dateFormat) { return { status: 400, body: { @@ -264,6 +256,12 @@ export const ApiContractV1Implementation = createNextRoute(ApiContractV1, { }; } + const timezone = body.meta.timezone + ? TIME_ZONES.find((tz) => tz === body.meta.timezone) + : DEFAULT_DOCUMENT_TIME_ZONE; + + const isTimeZoneValid = body.meta.timezone ? TIME_ZONES.includes(String(timezone)) : true; + if (!isTimeZoneValid) { return { status: 400,