diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/orders/create/index.tsx | 42 |
1 files changed, 30 insertions, 12 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 3b06b387d..82556d25a 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 { HttpError } from "@gnu-taler/web-util/lib/index.browser"; +import { ErrorType, HttpError } from "@gnu-taler/web-util/lib/index.browser"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { Loading } from "../../../../components/exception/loading.js"; @@ -30,6 +30,7 @@ import { useOrderAPI } from "../../../../hooks/order.js"; import { useInstanceProducts } from "../../../../hooks/product.js"; import { Notification } from "../../../../utils/types.js"; import { CreatePage } from "./CreatePage.js"; +import { HttpStatusCode } from "@gnu-taler/taler-util"; export type Entity = { request: MerchantBackend.Orders.PostOrderRequest; @@ -55,19 +56,36 @@ export default function OrderCreate({ const detailsResult = useInstanceDetails(); const inventoryResult = useInstanceProducts(); - if (detailsResult.clientError && detailsResult.isUnauthorized) - return onUnauthorized(); - if (detailsResult.clientError && detailsResult.isNotfound) - return onNotFound(); if (detailsResult.loading) return <Loading />; - if (!detailsResult.ok) return onLoadError(detailsResult); - - if (inventoryResult.clientError && inventoryResult.isUnauthorized) - return onUnauthorized(); - if (inventoryResult.clientError && inventoryResult.isNotfound) - return onNotFound(); if (inventoryResult.loading) return <Loading />; - if (!inventoryResult.ok) return onLoadError(inventoryResult); + + 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 ( + inventoryResult.type === ErrorType.CLIENT && + inventoryResult.status === HttpStatusCode.Unauthorized + ) + return onUnauthorized(); + if ( + inventoryResult.type === ErrorType.CLIENT && + inventoryResult.status === HttpStatusCode.NotFound + ) + return onNotFound(); + return onLoadError(inventoryResult); + } return ( <Fragment> |