From 1934d0b655ee0a02c2d1776163adf5c550ac9e58 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Mon, 8 Jun 2026 23:26:41 +0200 Subject: [PATCH] feat(plan4): page /produits avec catalogue Shopify + filtres --- src/app/(dashboard)/produits/page.tsx | 51 +++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/src/app/(dashboard)/produits/page.tsx b/src/app/(dashboard)/produits/page.tsx index 904b19d..d03781d 100644 --- a/src/app/(dashboard)/produits/page.tsx +++ b/src/app/(dashboard)/produits/page.tsx @@ -1,9 +1,56 @@ +'use client' +import { useState, useEffect, useMemo } from 'react' import { Header } from '@/components/layout/Header' +import { ProductFiltersBar } from '@/components/products/ProductFiltersBar' +import { ProductTable } from '@/components/products/ProductTable' +import type { CatalogProduct, ProductFilters } from '@/types/products' + export default function ProduitsPage() { + const [allProducts, setAllProducts] = useState([]) + const [loading, setLoading] = useState(true) + const [error, setError] = useState(null) + const [filters, setFilters] = useState({ status: 'all', search: '' }) + + useEffect(() => { + setLoading(true) + setError(null) + const params = filters.status !== 'all' ? `?status=${filters.status}` : '' + fetch(`/api/products/list${params}`) + .then((r) => r.json()) + .then((data) => { + if (data.error) throw new Error(data.error) + setAllProducts(data.products) + }) + .catch((e: Error) => setError(e.message)) + .finally(() => setLoading(false)) + }, [filters.status]) + + const displayed = useMemo(() => { + if (!filters.search.trim()) return allProducts + const q = filters.search.toLowerCase() + return allProducts.filter( + (p) => p.title.toLowerCase().includes(q) || p.ref.toLowerCase().includes(q), + ) + }, [allProducts, filters.search]) + return ( <> -
-

Module Produits — à implémenter (Plan 4)

+
+
+
+ setFilters((prev) => ({ ...prev, ...f }))} + /> + {error && ( +
+ {error} +
+ )} + +
+
) }