diff --git a/src/productTable.tsx b/src/productTable.tsx index 04508a7..396c393 100644 --- a/src/productTable.tsx +++ b/src/productTable.tsx @@ -46,7 +46,30 @@ interface ProductTableProps { const ProductTable = React.memo(({ onChangeQuantity, storeId }: ProductTableProps) => { return ( -
Product table
+ + {({ data }: any) => { + //const products = data && data.store && data.store.products; + //console.table(products); + return ( + + { + data && data.store && data.store.products.map(({ description, id, name, price }: Product) => { + return + + € {price.toFixed(2)} + + + }) + } + +
+
{name}
+ {description} +
) + } + + } +
); }); diff --git a/src/queries.graphql b/src/queries.graphql index 140ce83..34124e9 100644 --- a/src/queries.graphql +++ b/src/queries.graphql @@ -3,4 +3,16 @@ query getStores{ id, name } +} + +query getStore($storeId: String!){ + store (id:$storeId){ + id, + name, + city, + number, + postalCode, + street, + products {id,description,name,price} + } } \ No newline at end of file diff --git a/src/storeSelect.tsx b/src/storeSelect.tsx index 860e142..ca0bca8 100644 --- a/src/storeSelect.tsx +++ b/src/storeSelect.tsx @@ -26,7 +26,7 @@ const StoreSelect = React.memo(({ value, onChange }: StoreSelectProps) => { return ( - {({ data: { stores = [] } }) => ( + {({ data: { stores = [] } = {} }) => (