diff options
author | Sebastian <sebasjm@gmail.com> | 2024-04-01 12:57:14 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-04-01 12:57:14 -0300 |
commit | 49960c51f73c8b000623a7d8978e9ab6386b04f2 (patch) | |
tree | 77378055d32f3688e01b804c69c23b485d516688 /packages/merchant-backoffice-ui/src/paths/instance/orders/create | |
parent | 9237058c8ff4ad12a28520c2ec63afdea65af119 (diff) | |
download | wallet-core-49960c51f73c8b000623a7d8978e9ab6386b04f2.tar.xz |
migrate getInstance
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/orders/create')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx index a7165fa41..54d8c7b47 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { HttpStatusCode, TalerErrorDetail, TalerMerchantApi } from "@gnu-taler/taler-util"; +import { HttpStatusCode, TalerError, TalerErrorDetail, TalerMerchantApi } from "@gnu-taler/taler-util"; import { ErrorType, HttpError, useMerchantApiContext } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; @@ -30,6 +30,7 @@ import { useInstanceProducts } from "../../../../hooks/product.js"; import { Notification } from "../../../../utils/types.js"; import { CreatePage } from "./CreatePage.js"; import { useSessionContext } from "../../../../context/session.js"; +import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js"; export type Entity = { request: TalerMerchantApi.PostOrderRequest; @@ -55,22 +56,27 @@ export default function OrderCreate({ const detailsResult = useInstanceDetails(); const inventoryResult = useInstanceProducts(); - if (detailsResult.loading) return <Loading />; + if (!detailsResult) return <Loading /> + if (detailsResult instanceof TalerError) { + return <ErrorLoadingMerchant error={detailsResult} /> + } + + // if (detailsResult.loading) return <Loading />; if (inventoryResult.loading) return <Loading />; - if (!detailsResult.ok) { - if ( - detailsResult.type === ErrorType.CLIENT && - detailsResult.status === HttpStatusCode.Unauthorized - ) - return onUnauthorized(); - if ( - detailsResult.type === ErrorType.CLIENT && - detailsResult.status === HttpStatusCode.NotFound - ) - return onNotFound(); - return onLoadError(detailsResult); - } + // if (!detailsResult.ok) { + // if ( + // detailsResult.type === ErrorType.CLIENT && + // detailsResult.status === HttpStatusCode.Unauthorized + // ) + // return onUnauthorized(); + // if ( + // detailsResult.type === ErrorType.CLIENT && + // detailsResult.status === HttpStatusCode.NotFound + // ) + // return onNotFound(); + // return onLoadError(detailsResult); + // } if (!inventoryResult.ok) { if ( @@ -112,7 +118,7 @@ export default function OrderCreate({ }); }); }} - instanceConfig={detailsResult.data} + instanceConfig={detailsResult.body} instanceInventory={inventoryResult.data} /> </Fragment> |