build ok,

This commit is contained in:
louiscklaw
2025-06-15 11:28:24 +08:00
parent c319c103f6
commit b7cd25b614
1088 changed files with 4376 additions and 7002 deletions

View File

@@ -47,9 +47,7 @@ export async function GET(req: NextRequest) {
products: paginatedProducts,
totalPages,
totalItems,
categoryOptions: Array.from(
new Set(_products.map(({ category: c_category }) => c_category))
), // Remove duplicate categories
categoryOptions: Array.from(new Set(_products.map(({ category: c_category }) => c_category))), // Remove duplicate categories
},
STATUS.OK
);
@@ -70,9 +68,7 @@ function paginateProducts(products: Products, page: number, perPage: number) {
function filterProducts(products: Products, searchQuery: string, category: string) {
return products.filter(({ id, name, category: prodCategory }) => {
// Accept search by id or name
const matchesSearch = searchQuery
? id.includes(searchQuery) || name.toLowerCase().includes(searchQuery)
: true;
const matchesSearch = searchQuery ? id.includes(searchQuery) || name.toLowerCase().includes(searchQuery) : true;
const matchesCategory = category ? prodCategory === category : true;
return matchesSearch && matchesCategory;