diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx | 41 |
1 files changed, 16 insertions, 25 deletions
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> |