From 126772becab5d1d7a253984b4a9ae1a73013a5ae Mon Sep 17 00:00:00 2001 From: Mahen Date: Wed, 11 Feb 2026 07:56:16 +0700 Subject: [PATCH] feat: get review data total --- src/components/dashboards/Header.tsx | 6 ++++-- src/hooks/useHeader.ts | 10 ---------- src/types/index.ts | 1 + 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/components/dashboards/Header.tsx b/src/components/dashboards/Header.tsx index 75f9663..49011d4 100644 --- a/src/components/dashboards/Header.tsx +++ b/src/components/dashboards/Header.tsx @@ -18,10 +18,12 @@ import { import { signOut } from "next-auth/react"; import Link from "next/link"; import { useHeader } from "@/src/hooks/useHeader"; +import { useDashboards } from "@/src/hooks/useDashboard"; export function Header() { - const { open, setOpen, session, mounted, productCount, loadingProductCount } = + const { open, setOpen, session, mounted, productCount } = useHeader(); + const { totalReviews } = useDashboards(); if (!mounted) return null; return ( @@ -50,7 +52,7 @@ export function Header() {
- 12,450 Ulasan + {totalReviews} Ulasan
setOpen(true)}> diff --git a/src/hooks/useHeader.ts b/src/hooks/useHeader.ts index 7cea149..8462d16 100644 --- a/src/hooks/useHeader.ts +++ b/src/hooks/useHeader.ts @@ -7,7 +7,6 @@ export const useHeader = () => { const session = useSession(); const [mounted, setMounted] = useState(false); const [productCount, setProductCount] = useState(null); - const [loadingProductCount, setLoadingProductCount] = useState(false); const handleRefresh = () => { setIsRefreshing(true); @@ -18,8 +17,6 @@ export const useHeader = () => { setMounted(true); const getProductCount = async () => { try { - setLoadingProductCount(true); - const res = await fetch("/api/product"); if (!res.ok) throw new Error("Failed to fetch product count"); @@ -27,18 +24,12 @@ export const useHeader = () => { setProductCount(data.count); } catch (error) { console.error("Failed get product count:", error); - } finally { - setLoadingProductCount(false); } }; getProductCount(); }, []); - useEffect(()=>{ - - }) - return { open, setOpen, @@ -47,6 +38,5 @@ export const useHeader = () => { handleRefresh, mounted, productCount, - loadingProductCount, }; }; diff --git a/src/types/index.ts b/src/types/index.ts index 74021ad..bd3ea08 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -28,6 +28,7 @@ export interface BrandFilterProps { } export type Review = { + brand: string; id: number; createdAt: string; sentiment: Sentiment;