Skip to content

Commit

Permalink
fix: typing yang rumit
Browse files Browse the repository at this point in the history
  • Loading branch information
reacto11mecha committed Jun 16, 2024
1 parent 89e770a commit 515eab3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/api/src/router/admin.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
12 changes: 6 additions & 6 deletions packages/settings/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 2 additions & 8 deletions packages/validators/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
}),
})
Expand Down

0 comments on commit 515eab3

Please sign in to comment.