diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths')
22 files changed, 173 insertions, 90 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/admin/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/admin/list/index.tsx index 7dd5d74bb..f26ff8935 100644 --- a/packages/merchant-backoffice-ui/src/paths/admin/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/admin/list/index.tsx @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { TalerError, TalerMerchantApi } from "@gnu-taler/taler-util"; +import { HttpStatusCode, TalerError, TalerMerchantApi, assertUnreachable } from "@gnu-taler/taler-util"; import { useMerchantApiContext, useTranslationContext @@ -34,6 +34,7 @@ import { useSessionContext } from "../../../context/session.js"; import { useBackendInstances } from "../../../hooks/instance.js"; import { Notification } from "../../../utils/types.js"; import { View } from "./View.js"; +import { LoginPage } from "../../login/index.js"; interface Props { onCreate: () => void; @@ -59,6 +60,16 @@ export default function Instances({ if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} /> } + if (result.type === "fail") { + switch(result.case) { + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(result.case) + } + } + } return ( <Fragment> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx index 1d5c523a4..a9454cd07 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx @@ -34,6 +34,7 @@ import { useInstanceBankAccounts } from "../../../../hooks/bank.js"; import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { ListPage } from "./ListPage.js"; +import { LoginPage } from "../../../login/index.js"; interface Props { onCreate: () => void; @@ -59,8 +60,11 @@ export default function ListOtpDevices({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate /> } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case) + assertUnreachable(result) } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx index f5b7436d4..97610e96b 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/accounts/update/index.tsx @@ -32,6 +32,7 @@ import { NotificationCard } from "../../../../components/menu/index.js"; import { useSessionContext } from "../../../../context/session.js"; import { useBankAccountDetails } from "../../../../hooks/bank.js"; import { Notification } from "../../../../utils/types.js"; +import { LoginPage } from "../../../login/index.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { UpdatePage } from "./UpdatePage.js"; @@ -63,8 +64,11 @@ export default function UpdateValidator({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case); + assertUnreachable(result); } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx index 627b5d1be..5b6564485 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx @@ -13,31 +13,26 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { ErrorType, HttpError, useMerchantApiContext } from "@gnu-taler/web-util/browser"; -import { Fragment, h, VNode } from "preact"; +import { HttpStatusCode, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; +import { useMerchantApiContext } from "@gnu-taler/web-util/browser"; +import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; +import { ErrorLoadingMerchant } from "../../../components/ErrorLoadingMerchant.js"; import { Loading } from "../../../components/exception/loading.js"; import { DeleteModal } from "../../../components/modal/index.js"; +import { useSessionContext } from "../../../context/session.js"; import { useInstanceDetails } from "../../../hooks/instance.js"; +import { LoginPage } from "../../login/index.js"; import { DetailPage } from "./DetailPage.js"; -import { HttpStatusCode, TalerError, TalerErrorDetail } from "@gnu-taler/taler-util"; -import { useSessionContext } from "../../../context/session.js"; -import { ErrorLoadingMerchant } from "../../../components/ErrorLoadingMerchant.js"; interface Props { - onUnauthorized: () => VNode; - onLoadError: (error: HttpError<TalerErrorDetail>) => VNode; onUpdate: () => void; - onNotFound: () => VNode; onDelete: () => void; } export default function Detail({ onUpdate, - onLoadError, - onUnauthorized, onDelete, - onNotFound, }: Props): VNode { const { state } = useSessionContext(); const result = useInstanceDetails(); @@ -50,21 +45,17 @@ export default function Detail({ if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} /> } + if (result.type === "fail") { + switch(result.case) { + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(result.case) + } + } + } - // if (result.loading) return <Loading />; - // if (!result.ok) { - // if ( - // result.type === ErrorType.CLIENT && - // result.status === HttpStatusCode.Unauthorized - // ) - // return onUnauthorized(); - // if ( - // result.type === ErrorType.CLIENT && - // result.status === HttpStatusCode.NotFound - // ) - // return onNotFound(); - // return onLoadError(result); - // } return ( <Fragment> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx index 9d0bd2e16..32c7b6c7f 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/kyc/list/index.tsx @@ -19,44 +19,23 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { ErrorType, HttpError } from "@gnu-taler/web-util/browser"; -import { h, VNode } from "preact"; +import { HttpStatusCode, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; +import { VNode, h } from "preact"; +import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js"; import { Loading } from "../../../../components/exception/loading.js"; import { useInstanceKYCDetails } from "../../../../hooks/instance.js"; +import { LoginPage } from "../../../login/index.js"; import { ListPage } from "./ListPage.js"; -import { HttpStatusCode, TalerError, TalerErrorDetail } from "@gnu-taler/taler-util"; -import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js"; interface Props { - onUnauthorized: () => VNode; - onLoadError: (error: HttpError<TalerErrorDetail>) => VNode; - onNotFound: () => VNode; } -export default function ListKYC({ - onUnauthorized, - onLoadError, - onNotFound, -}: Props): VNode { +export default function ListKYC(_p: Props): VNode { const result = useInstanceKYCDetails(); if (!result) return <Loading /> if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} /> } - // if (result.loading) return <Loading />; - // if (!result.ok) { - // if ( - // result.type === ErrorType.CLIENT && - // result.status === HttpStatusCode.Unauthorized - // ) - // return onUnauthorized(); - // if ( - // result.type === ErrorType.CLIENT && - // result.status === HttpStatusCode.NotFound - // ) - // return onNotFound(); - // return onLoadError(result); - // } if (result.type === "fail") { switch (result.case) { case HttpStatusCode.GatewayTimeout: { @@ -74,6 +53,12 @@ export default function ListKYC({ case HttpStatusCode.ServiceUnavailable: { return <div /> } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(result) + } } } const status = result.body; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx index d7abc4fbe..32f3f05c7 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/OrderCreatedSuccessfully.tsx @@ -21,6 +21,7 @@ import { CreatedSuccessfully } from "../../../../components/notifications/Create import { useOrderDetails } from "../../../../hooks/order.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { Entity } from "./index.js"; +import { LoginPage } from "../../../login/index.js"; interface Props { entity: Entity; @@ -53,6 +54,9 @@ export function OrderCreatedSuccessfully({ <div>The merchant's interaction with the exchange took too long</div> ); } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { assertUnreachable(result) } 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 e40e766dd..10b115905 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 @@ -32,6 +32,7 @@ import { useInstanceProducts } from "../../../../hooks/product.js"; import { Notification } from "../../../../utils/types.js"; import { CreatePage } from "./CreatePage.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; +import { LoginPage } from "../../../login/index.js"; export type Entity = { request: TalerMerchantApi.PostOrderRequest; @@ -55,6 +56,16 @@ export default function OrderCreate({ if (detailsResult instanceof TalerError) { return <ErrorLoadingMerchant error={detailsResult} /> } + if (detailsResult.type === "fail") { + switch (detailsResult.case) { + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(detailsResult.case); + } + } + } if (!inventoryResult) return <Loading /> if (inventoryResult instanceof TalerError) { return <ErrorLoadingMerchant error={inventoryResult} /> @@ -64,8 +75,11 @@ export default function OrderCreate({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(inventoryResult.case); + assertUnreachable(inventoryResult); } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx index 1c8ceb90e..b232a146b 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/index.tsx @@ -32,6 +32,7 @@ import { useOrderDetails } from "../../../../hooks/order.js"; import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { DetailPage } from "./DetailPage.js"; +import { LoginPage } from "../../../login/index.js"; export interface Props { oid: string; @@ -63,6 +64,9 @@ export default function Update({ oid, onBack }: Props): VNode { <div>The merchant's interaction with the exchange took too long</div> ); } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { assertUnreachable(result); } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx index 7a3fb2d22..8efef1c1b 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/list/index.tsx @@ -46,6 +46,7 @@ import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { ListPage } from "./ListPage.js"; import { RefundModal } from "./Table.js"; +import { LoginPage } from "../../../login/index.js"; interface Props { onSelect: (id: string) => void; @@ -75,16 +76,16 @@ export default function OrderList({ onCreate, onSelect }: Props): VNode { if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} />; } - // if (result.type === "fail") { - // switch (result.case) { - // case HttpStatusCode.NotFound: { - // return <NotFoundPageOrAdminCreate />; - // } - // default: { - // assertUnreachable(result.case); - // } - // } - // } + if (result.type === "fail") { + switch(result.case) { + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(result.case) + } + } + } const isNotPaidActive = filter.paid === false ? "is-active" : ""; const isPaidActive = @@ -206,6 +207,9 @@ function RefundModalForTable({ id, onConfirm, onCancel }: RefundProps): VNode { <div>The merchant's interaction with the exchange took too long</div> ); } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { assertUnreachable(result); } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx index c240b99cb..6b3eded17 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/index.tsx @@ -39,6 +39,7 @@ import { useInstanceOtpDevices } from "../../../../hooks/otp.js"; import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { ListPage } from "./ListPage.js"; +import { LoginPage } from "../../../login/index.js"; interface Props { onCreate: () => void; @@ -62,8 +63,11 @@ export default function ListOtpDevices({ onCreate, onSelect }: Props): VNode { case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case); + assertUnreachable(result); } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx index 43adbe253..4dc3ec67f 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx @@ -40,6 +40,7 @@ import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { CreatedSuccessfully } from "../create/CreatedSuccessfully.js"; import { UpdatePage } from "./UpdatePage.js"; +import { LoginPage } from "../../../login/index.js"; export type Entity = TalerMerchantApi.OtpDevicePatchDetails & WithId; @@ -71,8 +72,11 @@ export default function UpdateValidator({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case); + assertUnreachable(result); } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx index eb38f25d9..73c221662 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/products/list/index.tsx @@ -38,6 +38,7 @@ import { import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { CardTable } from "./Table.js"; +import { LoginPage } from "../../../login/index.js"; interface Props { onCreate: () => void; @@ -65,8 +66,11 @@ export default function ProductList({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case); + assertUnreachable(result); } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx index 9de632218..08b169610 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx @@ -34,6 +34,7 @@ import { useProductDetails } from "../../../../hooks/product.js"; import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { UpdatePage } from "./UpdatePage.js"; +import { LoginPage } from "../../../login/index.js"; export type Entity = TalerMerchantApi.ProductAddDetail; interface Props { @@ -62,8 +63,11 @@ export default function UpdateProduct({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case); + assertUnreachable(result); } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx index 5a8be71b0..23bc95943 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/list/index.tsx @@ -38,6 +38,7 @@ import { import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { ListPage } from "./ListPage.js"; +import { LoginPage } from "../../../login/index.js"; interface Props { onCreate: () => void; @@ -69,8 +70,11 @@ export default function ListTemplates({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate /> } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case) + assertUnreachable(result) } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/index.tsx index 3464fb04e..ed809c7b3 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/index.tsx @@ -28,6 +28,7 @@ import { } from "../../../../hooks/templates.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { QrPage } from "./QrPage.js"; +import { LoginPage } from "../../../login/index.js"; export type Entity = TalerMerchantApi.TransferInformation; interface Props { @@ -49,8 +50,11 @@ export default function TemplateQrPage({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate /> } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case) + assertUnreachable(result) } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx index 1ff4b56cf..5fc8bee93 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx @@ -36,6 +36,7 @@ import { import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { UpdatePage } from "./UpdatePage.js"; +import { LoginPage } from "../../../login/index.js"; export type Entity = TalerMerchantApi.TemplatePatchDetails & WithId; @@ -65,8 +66,11 @@ export default function UpdateTemplate({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate /> } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case) + assertUnreachable(result) } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx index 0073ca574..d631cef96 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/use/index.tsx @@ -35,6 +35,7 @@ import { import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { UsePage } from "./UsePage.js"; +import { LoginPage } from "../../../login/index.js"; export type Entity = TalerMerchantApi.TransferInformation; interface Props { @@ -62,8 +63,11 @@ export default function TemplateUsePage({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate /> } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case) + assertUnreachable(result) } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx index 444283b13..36ba10e30 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/token/index.tsx @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { TalerError } from "@gnu-taler/taler-util"; +import { HttpStatusCode, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; import { useMerchantApiContext, useTranslationContext } from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; @@ -23,6 +23,7 @@ import { NotificationCard } from "../../../components/menu/index.js"; import { useSessionContext } from "../../../context/session.js"; import { useInstanceDetails } from "../../../hooks/instance.js"; import { Notification } from "../../../utils/types.js"; +import { LoginPage } from "../../login/index.js"; import { DetailPage } from "./DetailPage.js"; interface Props { @@ -44,6 +45,16 @@ export default function Token({ if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} /> } + if (result.type === "fail") { + switch(result.case) { + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(result.case) + } + } + } const hasToken = result.body.auth.method === "token" diff --git a/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx index 5edea377f..b53f67884 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx @@ -19,13 +19,14 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { TalerError } from "@gnu-taler/taler-util"; +import { HttpStatusCode, TalerError, assertUnreachable } from "@gnu-taler/taler-util"; import { VNode, h } from "preact"; import { useEffect, useState } from "preact/hooks"; import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js"; import { Loading } from "../../../../components/exception/loading.js"; import { useInstanceBankAccounts } from "../../../../hooks/bank.js"; import { useInstanceTransfers } from "../../../../hooks/transfer.js"; +import { LoginPage } from "../../../login/index.js"; import { ListPage } from "./ListPage.js"; interface Props { @@ -73,17 +74,16 @@ export default function ListTransfer({ if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} />; } - // if (result.type === "fail") { - // switch (result.case) { - // case HttpStatusCode.NotFound: { - // return <NotFoundPageOrAdminCreate />; - // } - // default: { - // assertUnreachable(result.case); - // } - // } - // } - + if (result.type === "fail") { + switch (result.case) { + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(result.case); + } + } + } return ( <ListPage diff --git a/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx index 6dc5b9b02..de3ffce48 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/update/index.tsx @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { OperationOk, TalerError, TalerMerchantApi, TalerMerchantInstanceHttpClient } from "@gnu-taler/taler-util"; +import { HttpStatusCode, TalerError, TalerMerchantApi, TalerMerchantInstanceHttpClient, TalerMerchantManagementResultByMethod, assertUnreachable } from "@gnu-taler/taler-util"; import { useMerchantApiContext, useTranslationContext @@ -29,6 +29,7 @@ import { useManagedInstanceDetails, } from "../../../hooks/instance.js"; import { Notification } from "../../../utils/types.js"; +import { LoginPage } from "../../login/index.js"; import { UpdatePage } from "./UpdatePage.js"; export interface Props { @@ -62,7 +63,7 @@ function CommonUpdate( onBack, onConfirm, }: Props, - result: OperationOk<TalerMerchantApi.QueryInstancesResponse> | TalerError | undefined, + result: TalerMerchantManagementResultByMethod<"getInstanceDetails"> | TalerError | undefined, updateInstance: typeof TalerMerchantInstanceHttpClient.prototype.updateCurrentInstance, ): VNode { const [notif, setNotif] = useState<Notification | undefined>(undefined); @@ -73,6 +74,16 @@ function CommonUpdate( if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} /> } + if (result.type === "fail") { + switch(result.case) { + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } + default: { + assertUnreachable(result.case) + } + } + } return ( <Fragment> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx index 7c24a7228..102aef96e 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/index.tsx @@ -39,6 +39,7 @@ import { useInstanceWebhooks } from "../../../../hooks/webhooks.js"; import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { ListPage } from "./ListPage.js"; +import { LoginPage } from "../../../login/index.js"; interface Props { onCreate: () => void; @@ -61,8 +62,11 @@ export default function ListWebhooks({ onCreate, onSelect }: Props): VNode { case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case); + assertUnreachable(result); } } } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx index 1c3172ffd..262e5bba4 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/index.tsx @@ -36,6 +36,7 @@ import { import { Notification } from "../../../../utils/types.js"; import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { UpdatePage } from "./UpdatePage.js"; +import { LoginPage } from "../../../login/index.js"; export type Entity = TalerMerchantApi.WebhookPatchDetails & WithId; @@ -65,8 +66,11 @@ export default function UpdateWebhook({ case HttpStatusCode.NotFound: { return <NotFoundPageOrAdminCreate />; } + case HttpStatusCode.Unauthorized: { + return <LoginPage /> + } default: { - assertUnreachable(result.case); + assertUnreachable(result); } } } |