diff --git a/src/components/dashboards/BrandFilter.tsx b/src/components/dashboards/BrandFilter.tsx
index cf02cf5..9696831 100644
--- a/src/components/dashboards/BrandFilter.tsx
+++ b/src/components/dashboards/BrandFilter.tsx
@@ -2,10 +2,19 @@
import { cn } from "@/lib/utils";
import { useBrandFilter } from "@/src/hooks/useBrandFilter";
+import { Button } from "../ui/button";
export function BrandFilter() {
- const { brands, isLoading, totalCount, selectedBrand, handleSelect } =
- useBrandFilter();
+ const {
+ isLoading,
+ totalCount,
+ selectedBrand,
+ visibleBrands,
+ isExpanded,
+ validBrands,
+ setIsExpanded,
+ handleSelect,
+ } = useBrandFilter();
if (isLoading) {
return (
@@ -29,27 +38,52 @@ export function BrandFilter() {
Semua ({totalCount.toLocaleString()})
- {brands.map((brand) => {
- if (brand.count === 0) return null;
+
+ {visibleBrands.map((brand) => {
+ const isActive =
+ selectedBrand?.toLowerCase() === brand.name.toLowerCase();
- const isActive =
- selectedBrand?.toLowerCase() === brand.name.toLowerCase();
+ return (
+
+ );
+ })}
- return (
+ {!isExpanded && validBrands.length > 3 && (
- );
- })}
+ )}
+
+ {isExpanded && (
+
+ )}
+
);
}
diff --git a/src/components/dashboards/DashboardClient.tsx b/src/components/dashboards/DashboardClient.tsx
index 3e69b5a..988fc73 100644
--- a/src/components/dashboards/DashboardClient.tsx
+++ b/src/components/dashboards/DashboardClient.tsx
@@ -50,10 +50,10 @@ export default function DashboardClient() {
- Akurasi 92.4%
+ Akurasi 82.0%
•
- XGBoost + TF-IDF
+ XGBoost + SMOTE + Chi-Square
•
Real-time Analysis
diff --git a/src/hooks/useBrandFilter.ts b/src/hooks/useBrandFilter.ts
index 5590b2c..788b404 100644
--- a/src/hooks/useBrandFilter.ts
+++ b/src/hooks/useBrandFilter.ts
@@ -6,6 +6,7 @@ export const useBrandFilter = () => {
const [brands, setBrands] = useState<{ name: string; count: number }[]>([]);
const [isLoading, setIsLoading] = useState(true);
const { selectedBrand, handleSelect } = useSelectSearch();
+ const [isExpanded, setIsExpanded] = useState(false);
useEffect(() => {
const fetchBrands = async () => {
@@ -28,5 +29,19 @@ export const useBrandFilter = () => {
const totalCount = brands.reduce((sum, b) => sum + (b?.count || 0), 0);
- return { brands, isLoading, totalCount, selectedBrand, handleSelect };
+ const validBrands = brands.filter((brand) => brand.count > 0);
+
+ const visibleBrands = isExpanded ? validBrands : validBrands.slice(0, 3);
+
+ return {
+ brands,
+ isLoading,
+ totalCount,
+ selectedBrand,
+ visibleBrands,
+ validBrands,
+ isExpanded,
+ handleSelect,
+ setIsExpanded,
+ };
};