From 578c150bce1f0faa4148e67c26549724b9e9128a Mon Sep 17 00:00:00 2001 From: Ezra Khairan Permana Date: Tue, 2 Jul 2024 04:29:34 +0700 Subject: [PATCH] fix: memperbaiki typing di server --- .../attendance/src/context/server-setting.tsx | 6 +----- apps/clients/attendance/tsconfig.app.json | 1 + apps/clients/chooser/index.html | 2 +- .../chooser/src/context/server-setting.tsx | 16 ++++++---------- apps/clients/chooser/src/routes/main-page.tsx | 6 +++--- apps/clients/chooser/tsconfig.app.json | 1 + packages/api/src/router/client.ts | 12 +++++++++--- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/apps/clients/attendance/src/context/server-setting.tsx b/apps/clients/attendance/src/context/server-setting.tsx index 887b90e..f17898f 100644 --- a/apps/clients/attendance/src/context/server-setting.tsx +++ b/apps/clients/attendance/src/context/server-setting.tsx @@ -149,11 +149,7 @@ export const ServerSettingProvider = ({ ᮞᮧᮛ - +
v{APP_VERSION} diff --git a/apps/clients/attendance/tsconfig.app.json b/apps/clients/attendance/tsconfig.app.json index 47c9833..c1adde8 100644 --- a/apps/clients/attendance/tsconfig.app.json +++ b/apps/clients/attendance/tsconfig.app.json @@ -24,6 +24,7 @@ "noFallthroughCasesInSwitch": true, /* Absolute Import */ + "baseUrl": "./", "paths": { "@/*": ["src/*"] } diff --git a/apps/clients/chooser/index.html b/apps/clients/chooser/index.html index 5dc81e1..fad2dab 100644 --- a/apps/clients/chooser/index.html +++ b/apps/clients/chooser/index.html @@ -4,7 +4,7 @@ - Attendance Client + Chooser Client
diff --git a/apps/clients/chooser/src/context/server-setting.tsx b/apps/clients/chooser/src/context/server-setting.tsx index 887b90e..fb7873b 100644 --- a/apps/clients/chooser/src/context/server-setting.tsx +++ b/apps/clients/chooser/src/context/server-setting.tsx @@ -6,7 +6,7 @@ import { Loader, RotateCcw } from "lucide-react"; import { Button } from "@sora-vp/ui/button"; interface ISettingContext { - canAttend: boolean; + canVote: boolean; } export const ServerSettingContext = createContext( @@ -32,7 +32,7 @@ export const ServerSettingProvider = ({ const propsValue = useMemo(() => { if (!settingsQuery.data) return { - canAttend: false, + canVote: false, }; const result = settingsQuery.data; @@ -42,13 +42,13 @@ export const ServerSettingProvider = ({ const currentTime = new Date().getTime(); - const canAttend = + const canVote = (waktuMulai as number) <= currentTime && (waktuSelesai as number) >= currentTime && - result.canAttend; + result.canVote; return { - canAttend, + canVote, }; }, [settingsQuery.data]); @@ -149,11 +149,7 @@ export const ServerSettingProvider = ({ ᮞᮧᮛ - +
v{APP_VERSION} diff --git a/apps/clients/chooser/src/routes/main-page.tsx b/apps/clients/chooser/src/routes/main-page.tsx index 838e1ee..3c51170 100644 --- a/apps/clients/chooser/src/routes/main-page.tsx +++ b/apps/clients/chooser/src/routes/main-page.tsx @@ -3,9 +3,9 @@ import { useServerSetting } from "@/context/server-setting"; import { motion } from "framer-motion"; export default function MainPage() { - const { canAttend } = useServerSetting(); + const { canVote } = useServerSetting(); - if (!canAttend) + if (!canVote) return (
- Belum Bisa Absen! + Belum Bisa Memilih!
); diff --git a/apps/clients/chooser/tsconfig.app.json b/apps/clients/chooser/tsconfig.app.json index 47c9833..c1adde8 100644 --- a/apps/clients/chooser/tsconfig.app.json +++ b/apps/clients/chooser/tsconfig.app.json @@ -24,6 +24,7 @@ "noFallthroughCasesInSwitch": true, /* Absolute Import */ + "baseUrl": "./", "paths": { "@/*": ["src/*"] } diff --git a/packages/api/src/router/client.ts b/packages/api/src/router/client.ts index a6dd3a3..95153f5 100644 --- a/packages/api/src/router/client.ts +++ b/packages/api/src/router/client.ts @@ -1,7 +1,7 @@ import type { TRPCRouterRecord } from "@trpc/server"; import { TRPCError } from "@trpc/server"; -import { and, eq, not, schema, sql } from "@sora-vp/db"; +import { eq, schema, sql } from "@sora-vp/db"; import settings, { canAttendNow } from "@sora-vp/settings"; import { participant } from "@sora-vp/validators"; @@ -28,8 +28,14 @@ export const clientRouter = { SELECT * FROM ${schema.participants} WHERE ${schema.participants.qrId} = ${input} FOR UPDATE `); - const participantContainer = participantRawQuery.at(0)!; - const participant = participantContainer.at(0)!; + const participantContainer = participantRawQuery.at(0) as unknown as { + name: string; + already_attended: boolean; + qr_id: string; + sub_part: string; + }[]; + + const participant = participantContainer.at(0); if (!participant) throw new TRPCError({