From 026dbe6f9b9d108bcbe3e4d082fbede652405fcd Mon Sep 17 00:00:00 2001 From: bipproduction Date: Tue, 21 Oct 2025 16:28:47 +0800 Subject: [PATCH] tambahan --- src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx | 10 +++++++++- src/server/routes/wa_hook_route.ts | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx b/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx index dd52f51..f8f2a41 100644 --- a/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx +++ b/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx @@ -1,8 +1,9 @@ import apiFetch from "@/lib/apiFetch"; -import { Card, Pagination, Skeleton, Stack, Text, Title } from "@mantine/core"; +import { Button, Card, Pagination, Skeleton, Stack, Text, Title } from "@mantine/core"; import { useLocalStorage, useShallowEffect } from "@mantine/hooks"; import dayjs from "dayjs"; import useSWR from "swr"; +import { showNotification } from "@mantine/notifications"; export default function WaHookHome() { const [page, setPage] = useLocalStorage({ @@ -24,11 +25,18 @@ export default function WaHookHome() { setPage(data?.data?.list?.length || 1) }, []) + async function reset() { + await apiFetch["wa-hook"].reset.post() + mutate() + showNotification({ title: "Success", message: "WhatsApp Hook reset", color: "green" }) + } + if (isLoading) return if (error) return
Error: {error.message}
return ( WaHookHome + {data?.data?.list.map((item) => ( diff --git a/src/server/routes/wa_hook_route.ts b/src/server/routes/wa_hook_route.ts index 8bd4766..c3d0cb3 100644 --- a/src/server/routes/wa_hook_route.ts +++ b/src/server/routes/wa_hook_route.ts @@ -2,6 +2,7 @@ import Elysia, { t } from "elysia"; import { prisma } from "../lib/prisma"; import type { WAHookMessage } from "types/wa_messages"; import _ from "lodash"; +import dayjs from "dayjs"; async function fetchWithTimeout(input: RequestInfo, init: RequestInit, timeoutMs = 120_000) { const controller = new AbortController() @@ -165,6 +166,18 @@ const WaHookRoute = new Elysia({ summary: "List WhatsApp Hook", description: "List semua WhatsApp Hook", } + }) + .post("/reset", async () => { + await prisma.waHook.deleteMany() + return { + success: true, + message: "WhatsApp Hook reset" + }; + }, { + detail: { + summary: "Reset WhatsApp Hook", + description: "Reset semua WhatsApp Hook", + } }); export default WaHookRoute;