18 lines
512 B
TypeScript
18 lines
512 B
TypeScript
|
|
import type { Product } from '../types/cart';
|
|||
|
|
|
|||
|
|
export function normalizeProductImage(product: Product, size = '65,fit'): Product {
|
|||
|
|
return {
|
|||
|
|
...product,
|
|||
|
|
image: product.image?.replace('{SIZE}', size),
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function getLargeProductImage(product: Product): string {
|
|||
|
|
return product.image?.replace('65,fit', '335,fit') ?? '';
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
export function getProductAmount(product: Product): string {
|
|||
|
|
return product.unit === 'g'
|
|||
|
|
? `${product.n} г`
|
|||
|
|
: `${product.n} шт`;
|
|||
|
|
}
|