WIP POC in progress

This commit is contained in:
goncy
2021-08-09 18:11:00 -03:00
parent f765590484
commit 04f9799636
9 changed files with 143 additions and 67 deletions

View File

@@ -1,17 +1,60 @@
import type { RawProductWithPrice } from '@framework/types/product'
import type { RawProduct } from '@framework/types/product'
import type { Product } from '@commerce/types/product'
export function normalize(product: RawProductWithPrice): Product {
export function normalize(product: RawProduct): Product {
return {
id: product.ID,
name: product.Name,
description: product.Description,
images: [],
variants: [],
slug: product.ID,
images: product.xp.Images,
price: {
value: product.priceSchedule.PriceBreaks[0].Price,
currencyCode: 'USD',
value: product.xp.Price,
currencyCode: product.xp.PriceCurrency,
},
options: [],
// TODO: Implement this
variants: [
{
id: 'unique',
options: [
{
id: 'unique',
displayName: 'Model',
values: [
{
label: 'Unique',
},
],
},
],
},
],
options: [
{
id: 'option-color',
displayName: 'Color',
values: [
{
label: 'color',
hexColors: ['#222'],
},
],
},
{
id: 'option-size',
displayName: 'Size',
values: [
{
label: 'S',
},
{
label: 'M',
},
{
label: 'L',
},
],
},
],
}
}