Skip to content

Commit

Permalink
fix: memperbaiki typing di server
Browse files Browse the repository at this point in the history
  • Loading branch information
reacto11mecha committed Jul 1, 2024
1 parent 5b732d2 commit 578c150
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
6 changes: 1 addition & 5 deletions apps/clients/attendance/src/context/server-setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,7 @@ export const ServerSettingProvider = ({
ᮞᮧᮛ
</h1>

<Loader
size={58}
absoluteStrokeWidth
className="animate-pulse animate-spin"
/>
<Loader size={58} absoluteStrokeWidth className="animate-spin" />
</motion.div>
<div className="absolute bottom-4 right-4">
<small className="font-sundanese font-mono">v{APP_VERSION}</small>
Expand Down
1 change: 1 addition & 0 deletions apps/clients/attendance/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"noFallthroughCasesInSwitch": true,

/* Absolute Import */
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
Expand Down
2 changes: 1 addition & 1 deletion apps/clients/chooser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Attendance Client</title>
<title>Chooser Client</title>
</head>
<body>
<div id="root"></div>
Expand Down
16 changes: 6 additions & 10 deletions apps/clients/chooser/src/context/server-setting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ISettingContext>(
Expand All @@ -32,7 +32,7 @@ export const ServerSettingProvider = ({
const propsValue = useMemo(() => {
if (!settingsQuery.data)
return {
canAttend: false,
canVote: false,
};

const result = settingsQuery.data;
Expand All @@ -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]);

Expand Down Expand Up @@ -149,11 +149,7 @@ export const ServerSettingProvider = ({
ᮞᮧᮛ
</h1>

<Loader
size={58}
absoluteStrokeWidth
className="animate-pulse animate-spin"
/>
<Loader size={58} absoluteStrokeWidth className="animate-spin" />
</motion.div>
<div className="absolute bottom-4 right-4">
<small className="font-sundanese font-mono">v{APP_VERSION}</small>
Expand Down
6 changes: 3 additions & 3 deletions apps/clients/chooser/src/routes/main-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="flex h-screen w-screen flex-col items-center justify-center gap-5 p-6">
<motion.h1
Expand All @@ -17,7 +17,7 @@ export default function MainPage() {
}}
className="scroll-m-20 border-b font-mono text-4xl font-extrabold tracking-tight text-red-600 drop-shadow-2xl lg:text-5xl"
>
Belum Bisa Absen!
Belum Bisa Memilih!
</motion.h1>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions apps/clients/chooser/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"noFallthroughCasesInSwitch": true,

/* Absolute Import */
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
Expand Down
12 changes: 9 additions & 3 deletions packages/api/src/router/client.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -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({
Expand Down

0 comments on commit 578c150

Please sign in to comment.