diff --git a/.routify/config.js b/.routify/config.js index 0fc406c3..9681972a 100644 --- a/.routify/config.js +++ b/.routify/config.js @@ -13,5 +13,5 @@ module.exports = { "svx", "md" ], - "started": "2021-01-30T20:58:04.111Z" + "started": "2021-01-31T12:48:46.113Z" } \ No newline at end of file diff --git a/.routify/routes.js b/.routify/routes.js index d9f3e9b9..91199f96 100644 --- a/.routify/routes.js +++ b/.routify/routes.js @@ -1,11 +1,11 @@ /** * @roxi/routify 2.7.3 - * File generated Sat Jan 30 2021 20:58:05 GMT+0000 (Greenwich Mean Time) + * File generated Sun Jan 31 2021 12:48:47 GMT+0000 (Greenwich Mean Time) */ export const __version = "2.7.3" -export const __timestamp = "2021-01-30T20:58:05.710Z" +export const __timestamp = "2021-01-31T12:48:47.585Z" //buildRoutes import { buildClientTree } from "@roxi/routify/runtime/buildRoutes" diff --git a/rollup.config.js b/rollup.config.js index b6a434bb..d73fd3a1 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -71,7 +71,8 @@ export default { 'process.env.SERVER_URL': production ? JSON.stringify('https://server.enki.jobspeed.uk') : JSON.stringify('http://localhost:8080'), - 'process.env.STRIPE_KEY': JSON.stringify('pk_test_51HpvnTAk37gvJ51oYwywMtrDcDlL6FXuVY0aQ1EYEJUiw9MG70UElEMhhazqhhafUOslK1IugHRApQ7GWNUcnqT400dJ4HWjbp') + 'process.env.STRIPE_KEY': JSON.stringify('pk_test_51HpvnTAk37gvJ51oYwywMtrDcDlL6FXuVY0aQ1EYEJUiw9MG70UElEMhhazqhhafUOslK1IugHRApQ7GWNUcnqT400dJ4HWjbp'), + 'process.env.JEWELLERY_CATEGORY_ID': JSON.stringify('1875996') }), // In dev mode, call `npm run start` once diff --git a/src/components/ProductView/ProductView.svelte b/src/components/ProductView/ProductView.svelte index 2c563fb4..0adbb305 100644 --- a/src/components/ProductView/ProductView.svelte +++ b/src/components/ProductView/ProductView.svelte @@ -3,6 +3,7 @@ import { onMount } from 'svelte'; import AddToBasket from '../AddToBasket/AddToBasket.svelte'; import { retrieveStateFn } from '../../libs/requests'; + import type { GetFn } from '../../libs/requests'; interface Product { @@ -16,17 +17,20 @@ let productArr: readonly Product[] = []; - const getProducts: GetFn = (url: string): Promise> => - fetch(url).then((res) => res.json()); + const getProducts: GetFn = ( + url: string + ): Promise> => fetch(url).then((res) => res.json()); - onMount(async () => { + const refreshProducts = async (id: string) => { const result = await retrieveStateFn( - process.env.SERVER_URL as string, - categoryId, + `${process.env.SERVER_URL}/products-by-category?id=${id}`, getProducts )()(); - productArr = result['_tag'] === 'Right' ? result.right : []; - }); + productArr = result['_tag'] === 'Right' ? result.right as Product[] : []; + } + + onMount(async () => await refreshProducts(categoryId)); + $: refreshProducts(categoryId)