summaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-04-03 13:37:27 -0300
committerSebastian <sebasjm@gmail.com>2024-04-03 14:56:30 -0300
commit4bf1ab8ba924b2a0fc4813814bdeeb66a2928382 (patch)
tree8052cd83d9935db2c054a58f7d231c528b8dfc0d /packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx
parent56da180423029a1b53d2be343eed4f073e96dc89 (diff)
downloadwallet-core-4bf1ab8ba924b2a0fc4813814bdeeb66a2928382.tar.gz
wallet-core-4bf1ab8ba924b2a0fc4813814bdeeb66a2928382.tar.bz2
wallet-core-4bf1ab8ba924b2a0fc4813814bdeeb66a2928382.zip
wip #8655: fixing broken builddev/sebasjm/refactor-merchant-2
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/accounts/list/index.tsx37
1 files changed, 20 insertions, 17 deletions
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 ab63d0d5f..1d5c523a4 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
@@ -19,37 +19,30 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
-import { HttpStatusCode, TalerError, TalerErrorDetail, TalerMerchantApi } from "@gnu-taler/taler-util";
+import { HttpStatusCode, TalerError, TalerMerchantApi, assertUnreachable } from "@gnu-taler/taler-util";
import {
- ErrorType,
- HttpError,
useMerchantApiContext,
- useTranslationContext,
+ useTranslationContext
} 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 { NotificationCard } from "../../../../components/menu/index.js";
+import { useSessionContext } from "../../../../context/session.js";
import { useInstanceBankAccounts } from "../../../../hooks/bank.js";
import { Notification } from "../../../../utils/types.js";
+import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js";
import { ListPage } from "./ListPage.js";
-import { useSessionContext } from "../../../../context/session.js";
-import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js";
interface Props {
- onUnauthorized: () => VNode;
- onLoadError: (error: HttpError<TalerErrorDetail>) => VNode;
- onNotFound: () => VNode;
onCreate: () => void;
onSelect: (id: string) => void;
}
export default function ListOtpDevices({
- onUnauthorized,
- onLoadError,
onCreate,
onSelect,
- onNotFound,
}: Props): VNode {
const { i18n } = useTranslationContext();
const [notif, setNotif] = useState<Notification | undefined>(undefined);
@@ -61,11 +54,21 @@ export default function ListOtpDevices({
if (result instanceof TalerError) {
return <ErrorLoadingMerchant error={result} />
}
+ if (result.type === "fail") {
+ switch(result.case) {
+ case HttpStatusCode.NotFound: {
+ return <NotFoundPageOrAdminCreate />
+ }
+ default: {
+ assertUnreachable(result.case)
+ }
+ }
+ }
return (
<Fragment>
<NotificationCard notification={notif} />
- {result.result.length < 1 &&
+ {result.body.length < 1 &&
<NotificationCard notification={{
type: "WARN",
message: i18n.str`You need to associate a bank account to receive revenue.`,
@@ -73,17 +76,17 @@ export default function ListOtpDevices({
}} />
}
<ListPage
- devices={result.result}
+ devices={result.body}
onLoadMoreBefore={
- result.isReachingStart ? result.loadMorePrev : undefined
+ result.isFirstPage ? undefined: result.loadFirst
}
- onLoadMoreAfter={result.isReachingEnd ? result.loadMore : undefined}
+ onLoadMoreAfter={result.isLastPage ? undefined : result.loadNext}
onCreate={onCreate}
onSelect={(e) => {
onSelect(e.h_wire);
}}
onDelete={(e: TalerMerchantApi.BankAccountEntry) => {
- return api.management.deleteAccount(state.token, e.h_wire)
+ return api.management.deleteBankAccount(state.token, e.h_wire)
.then(() =>
setNotif({
message: i18n.str`bank account delete successfully`,