floranet/src/mock/cards.ts

39 lines
1.1 KiB
TypeScript

import { fakerES } from '@faker-js/faker';
export const cardMock = Array.from({ length: 8 }, (_, i) => ({
id: i + 1,
imgSrc: `assets/flowers/flower-${i + 1}.png`,
title: fakerES.commerce.productName(),
discount: fakerES.commerce.price({ min: 5, max: 15, dec: 0 }),
isNew: fakerES.datatype.boolean(),
value: fakerES.commerce.price({ min: 20, max: 150 }),
// title: 'Nombre del producto',
// discount: i % 2 === 0 ? '10' : '',
// isNew: i % 2 === 0,
// value: '25,90',
}));
interface GenerateFlowersParams {
length: number;
}
export function generateFlowers({ length }: GenerateFlowersParams) {
const flowersMock = Array.from({ length }, (_, i) => ({
id: i + 1,
title: fakerES.commerce.productName(),
description: fakerES.commerce.productDescription(),
price: fakerES.commerce.price({
symbol: '€',
min: 20,
max: 200,
dec: 0,
}),
sku: fakerES.commerce.isbn({ separator: '', variant: 13 }),
category: fakerES.commerce.productMaterial(),
images: Array.from({ length: fakerES.number.int({ min: 2, max: 6 }) }, () =>
fakerES.image.urlPicsumPhotos()
),
}));
return flowersMock;
}