From 515eab31f4cbe4ecc343083dcb20ee70d89ebf65 Mon Sep 17 00:00:00 2001 From: Ezra Khairan Permana Date: Sun, 16 Jun 2024 07:49:56 +0700 Subject: [PATCH] fix: typing yang rumit --- packages/api/src/router/admin.ts | 1 + packages/settings/src/index.ts | 12 ++++++------ packages/validators/src/settings.ts | 10 ++-------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/api/src/router/admin.ts b/packages/api/src/router/admin.ts index 51f6297f..f0f61672 100644 --- a/packages/api/src/router/admin.ts +++ b/packages/api/src/router/admin.ts @@ -1,4 +1,5 @@ import type { TRPCRouterRecord } from "@trpc/server"; +import { TRPCError } from "@trpc/server"; import { and, eq, not, schema, sql } from "@sora-vp/db"; import { admin } from "@sora-vp/validators"; diff --git a/packages/settings/src/index.ts b/packages/settings/src/index.ts index 8e2a6725..ecde1382 100644 --- a/packages/settings/src/index.ts +++ b/packages/settings/src/index.ts @@ -7,14 +7,14 @@ const getTimePermission = () => { const currentTime = new Date().getTime(); const currentTimeIsBiggerThanStart = - currentSettings.startTime && - currentSettings.startTime ? - currentTime >= currentSettings.startTime.getTime() : false; + currentSettings.startTime && currentSettings.startTime + ? currentTime >= currentSettings.startTime.getTime() + : false; const currentTimeIsSmallerThanEnd = - currentSettings.startTime && - currentSettings.endTime ? - currentTime <= currentSettings.endTime.getTime() : false; + currentSettings.startTime && currentSettings.endTime + ? currentTime <= currentSettings.endTime.getTime() + : false; return { isPermittedByTime: diff --git a/packages/validators/src/settings.ts b/packages/validators/src/settings.ts index 12b265ee..89603a04 100644 --- a/packages/validators/src/settings.ts +++ b/packages/validators/src/settings.ts @@ -18,18 +18,12 @@ const SharedDuration = z .object({ startTime: z.date({ errorMap: (issue, { defaultError }) => ({ - message: - issue.code === "invalid_type" - ? startTimeError - : defaultError, + message: issue.code === "invalid_type" ? startTimeError : defaultError, }), }), endTime: z.date({ errorMap: (issue, { defaultError }) => ({ - message: - issue.code === "invalid_type" - ? endTimeError - : defaultError, + message: issue.code === "invalid_type" ? endTimeError : defaultError, }), }), })