From ecfe9c57defdb6c674571850995851fc64e8fed1 Mon Sep 17 00:00:00 2001 From: bipproduction Date: Tue, 21 Oct 2025 16:42:08 +0800 Subject: [PATCH] tambahan --- .../sq/dashboard/wa-hook/wa_hook_home.tsx | 130 +++++++++++++----- 1 file changed, 92 insertions(+), 38 deletions(-) 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 dd61f46..2e818ed 100644 --- a/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx +++ b/src/pages/sq/dashboard/wa-hook/wa_hook_home.tsx @@ -12,58 +12,78 @@ import { Badge, ScrollArea, Tooltip, + Divider, } from "@mantine/core"; import { useLocalStorage, useShallowEffect } from "@mantine/hooks"; import { showNotification } from "@mantine/notifications"; -import { IconRefresh, IconMessageCircle, IconUser, IconCalendar, IconHash, IconCode } from "@tabler/icons-react"; +import { + IconRefresh, + IconMessageCircle, + IconUser, + IconCalendar, + IconHash, + IconCode, +} from "@tabler/icons-react"; import dayjs from "dayjs"; import useSWR from "swr"; export default function WaHookHome() { const [page, setPage] = useLocalStorage({ key: "wa-hook-page", defaultValue: 1 }); const { data, error, isLoading, mutate } = useSWR( - "/wa-hook", + `/wa-hook?page=${page}`, () => apiFetch["wa-hook"].list.get({ query: { page, limit: 10 } }), { refreshInterval: 4000, revalidateOnFocus: true, - revalidateOnReconnect: true, dedupingInterval: 3000, } ); useShallowEffect(() => { mutate(); - setPage(data?.data?.list?.length || 1); - }, []); + }, [page]); async function handleReset() { await apiFetch["wa-hook"].reset.post(); mutate(); showNotification({ title: "Reset Completed", - message: "WhatsApp Hook data has been successfully reset.", + message: "All WhatsApp Hook data has been cleared.", color: "teal", }); } - if (isLoading) return ; + if (isLoading) return ; if (error) return ( - Failed to load data: {error.message} + Failed to load webhook data. ); return ( - + - - WhatsApp Hook Monitor - + + + WhatsApp Hook Monitor + + + Real-time webhook activity and message tracking + + - + + + {data?.data?.list?.length ? ( data.data.list.map((item) => { @@ -88,44 +111,55 @@ export default function WaHookHome() { - - + + - {contact?.profile?.name || "Unknown"} + {contact?.profile?.name || "Unknown Sender"} - + - {msg?.text?.body || "(No message body)"} + + {msg?.text?.body || "(No message content)"} + - + - + {msg?.id} - + - + {dayjs(Number(msg?.timestamp) * 1000).format("YYYY-MM-DD HH:mm:ss")} - + - + {msg?.type || "Unknown"} @@ -135,13 +169,25 @@ export default function WaHookHome() { p="sm" radius="md" style={{ - backgroundColor: "#2D2D2D", - border: "1px solid rgba(0,255,255,0.1)", + backgroundColor: "rgba(45,45,45,0.7)", + border: "1px solid rgba(0,255,255,0.15)", + boxShadow: "inset 0 0 10px rgba(0,255,255,0.1)", }} > - - {JSON.stringify(answer, null, 2)} - + + + Flow Response + + + id: {answer.id} + + + type: {answer.type} + + + {answer.text} + + )} @@ -155,21 +201,21 @@ export default function WaHookHome() { backgroundColor: "#2D2D2D", border: "1px solid rgba(0,255,255,0.1)", textAlign: "center", - padding: 40, + padding: 60, }} > - No webhook data available yet. + No webhook activity detected yet. )} - + { setPage(value); mutate(); @@ -177,6 +223,14 @@ export default function WaHookHome() { radius="xl" withEdges color="teal" + size="md" + styles={{ + control: { + backgroundColor: "#2D2D2D", + border: "1px solid rgba(0,255,200,0.15)", + color: "#EAEAEA", + }, + }} />