export interface Product { id: number; name: string; picture: string; unitary_price: number; bulk_price: number; available_quantity: number; company_name: string; } export function mapProduct(data: any) { if(!data) return null; const product: Product = { id: data.id, name: data.attributes.name, picture: data.attributes.picture, unitary_price: data.attributes.unitary_price, bulk_price: data.attributes.bulk_price, available_quantity: data.attributes.available_quantity, company_name: data.attributes.company.name }; return product; }