diff --git a/packages/client/src/adapters/harness.tsx b/packages/client/src/adapters/harness.tsx index 1e7f0a8..ffcb670 100644 --- a/packages/client/src/adapters/harness.tsx +++ b/packages/client/src/adapters/harness.tsx @@ -64,11 +64,11 @@ export async function makeMonolithicApp({ }; } -export async function makeMicroservicesApp({ +export async function runBackendAndRender({ products = [], }: AppContext) { - const { catalogApp, ordersApp, cartApp, orderRepo, productRepo } = await runMicroservices(products) + const { catalogApp, ordersApp, cartApp, orderRepo } = await runMicroservices(products) const queryClient = new QueryClient(); @@ -85,9 +85,8 @@ export async function makeMicroservicesApp({ const driver = createDriver(app); return { - productRepo, orderRepo, - driver, + app: driver, [Symbol.dispose]: async () => { await cartServer.close(); await catalogServer.close(); diff --git a/packages/client/src/components/Shop.tsx b/packages/client/src/components/Shop.tsx index 1a2ccf7..4a532af 100644 --- a/packages/client/src/components/Shop.tsx +++ b/packages/client/src/components/Shop.tsx @@ -3,14 +3,14 @@ import React, {useState} from "react"; import {useProducts} from "../hooks/products"; import {useCartWidget} from "../hooks/cart"; -interface ShopProps { +type ShopProps = { cartId: string; } export const Shop: React.FC = ({ cartId }) => { const [ freeTextSearch, setFreeTextSearch ] = useState(''); - const { products, productsLoading, productsError } = useProducts({freeTextSearch}); + const products = useProducts(freeTextSearch); const { viewCart, addItem, itemCount, fetched } = useCartWidget(cartId); return
@@ -20,11 +20,19 @@ export const Shop: React.FC = ({ cartId }) => { setFreeTextSearch(e.target.value)}/>
- + }; -const Products: React.FC<{ products: Product[] | undefined, isLoading: boolean, error: unknown | null, addItem: (id: string) => void }> = ({ products, isLoading, error, addItem }) => { +type ProductsProps = { + products: { + data: Product[] | undefined; + isLoading: boolean; + error: unknown | null; + } + addItem: (id: string) => void; +} +const Products: React.FC = ( {products: {data, isLoading, error}, addItem}) => { if (isLoading) { return
Loading...
@@ -34,7 +42,7 @@ const Products: React.FC<{ products: Product[] | undefined, isLoading: boolean, return
<>Error: {error}
} - return <>{products!.map(({ title, id }) => + return <>{data!.map(({ title, id }) =>

{title}