import { fakerES } from "@faker-js/faker"; export function mockGenerator({ length }) { const flowersMock = Array.from({ length }, (_, i) => { const position = fakerES.datatype.boolean() && i + 1; const discount = fakerES.datatype.boolean() && fakerES.commerce.price({ min: 5, max: 15, dec: 0 }); const flower = { id: i + 1, name: fakerES.commerce.productName(), description: fakerES.commerce.productDescription(), price: fakerES.commerce.price({ symbol: "€", min: 20, max: 200, dec: 0, }), specialPrice: fakerES.commerce.price({ symbol: "€", min: 20, max: 60, dec: 0, }), isNew: fakerES.datatype.boolean(), slug: fakerES.commerce.isbn({ separator: "-", variant: 13 }), category: fakerES.number.int({ min: 1, max: 2 }), postalCode: "12345", dateExpired: "2024-01-30", images: Array.from( { length: fakerES.number.int({ min: 2, max: 6 }) }, () => fakerES.image.urlPicsumPhotos() ), featured: fakerES.number.int({ min: 0, max: 1 }), }; if (position) flower.position = position; if (discount) flower.discount = discount; return flower; }); return flowersMock; }