feat: extend Product with featured/featuredOrder

This commit is contained in:
belviskhoremk
2026-08-13 09:08:31 +02:00
parent 35b28f6a2a
commit 004ba924b2
2 changed files with 12 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ const ROW = {
image: 'products/edge-control.jpg',
description: 'Tenue longue durée.',
in_stock: true,
featured: true,
featured_order: 0,
}
import { fetchProducts, getProductsByCategory, type Product } from './products'
@@ -49,6 +51,8 @@ describe('fetchProducts', () => {
image: 'https://cdn.example/products/edge-control.jpg',
description: 'Tenue longue durée.',
inStock: true,
featured: true,
featuredOrder: 0,
},
])
})
@@ -61,8 +65,8 @@ describe('fetchProducts', () => {
describe('getProductsByCategory', () => {
const products: Product[] = [
{ id: 'a', name: 'A', category: 'hair-care', price: 1, image: '', description: '', inStock: true },
{ id: 'b', name: 'B', category: 'tools', price: 1, image: '', description: '', inStock: true },
{ id: 'a', name: 'A', category: 'hair-care', price: 1, image: '', description: '', inStock: true, featured: false, featuredOrder: null },
{ id: 'b', name: 'B', category: 'tools', price: 1, image: '', description: '', inStock: true, featured: false, featuredOrder: null },
]
it('returns all products for "all"', () => {

View File

@@ -9,6 +9,8 @@ export interface Product {
image: string
description: string
inStock: boolean
featured: boolean
featuredOrder: number | null
}
interface ProductRow {
@@ -19,6 +21,8 @@ interface ProductRow {
image: string
description: string
in_stock: boolean
featured: boolean
featured_order: number | null
}
export async function fetchProducts(): Promise<Product[]> {
@@ -32,6 +36,8 @@ export async function fetchProducts(): Promise<Product[]> {
image: resolveImageUrl(row.image),
description: row.description,
inStock: row.in_stock,
featured: row.featured,
featuredOrder: row.featured_order,
}))
}