aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-03-29 17:26:04 -0300
committerSebastian <sebasjm@gmail.com>2024-03-29 17:26:04 -0300
commitfdce0509a0f78d18fe5296cd1dda4a63b15daf5d (patch)
treedf88b1cc95912bb2127f5c04a42766c15d572614 /packages/merchant-backoffice-ui
parentc3cba95a9fd88eb77fd18263287d3a63a9f757e2 (diff)
downloadwallet-core-fdce0509a0f78d18fe5296cd1dda4a63b15daf5d.tar.xz
fix #8358
Diffstat (limited to 'packages/merchant-backoffice-ui')
-rw-r--r--packages/merchant-backoffice-ui/src/Routing.tsx82
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/preference.ts3
-rw-r--r--packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx2
-rw-r--r--packages/merchant-backoffice-ui/src/paths/settings/index.tsx1
4 files changed, 64 insertions, 24 deletions
diff --git a/packages/merchant-backoffice-ui/src/Routing.tsx b/packages/merchant-backoffice-ui/src/Routing.tsx
index c30b1912a..06701b513 100644
--- a/packages/merchant-backoffice-ui/src/Routing.tsx
+++ b/packages/merchant-backoffice-ui/src/Routing.tsx
@@ -122,7 +122,7 @@ export enum InstancePaths {
}
// eslint-disable-next-line @typescript-eslint/no-empty-function
-const noop = () => {};
+const noop = () => { };
export enum AdminPaths {
list_instances = "/instances",
@@ -130,7 +130,7 @@ export enum AdminPaths {
update_instance = "/instance/:id/update",
}
-export interface Props {}
+export interface Props { }
export const privatePages = {
home: urlPattern(/\/home/, () => "#/home"),
@@ -153,11 +153,17 @@ export function Routing(_p: Props): VNode {
useState<GlobalNotifState>(undefined);
const [error] = useErrorBoundary();
+ const [preference] = usePreference();
+
+ const now = AbsoluteTime.now();
const instance = useInstanceBankAccounts();
const accounts = !instance.ok ? undefined : instance.data.accounts;
const shouldWarnAboutMissingBankAccounts =
- !state.isAdmin && accounts !== undefined && accounts.length < 1;
+ !state.isAdmin && accounts !== undefined && accounts.length < 1 &&
+ (AbsoluteTime.isNever(preference.hideMissingAccountUntil) ||
+ AbsoluteTime.cmp(now, preference.hideMissingAccountUntil) > 1);
+ ;
const shouldLogin =
state.status === "loggedOut" || state.status === "expired";
@@ -245,14 +251,10 @@ export function Routing(_p: Props): VNode {
return (
<Fragment>
<Menu />
- <NotificationCard
- notification={{
- type: "INFO",
- message: i18n.str`You need to associate a bank account to receive revenue.`,
- description: i18n.str`Without this the merchant backend will refuse to create new orders.`,
- }}
- />
- <BankAccountCreatePage onConfirm={() => {}} />
+ <BankAccountBanner />
+ <BankAccountCreatePage onConfirm={() => {
+ route(InstancePaths.bank_list);
+ }} />
</Fragment>
);
}
@@ -682,20 +684,20 @@ function AdminInstanceUpdatePage({
const notif =
error.type === ErrorType.TIMEOUT
? {
- message: i18n.str`The request to the backend take too long and was cancelled`,
- description: i18n.str`Diagnostic from ${error.info.url} is '${error.message}'`,
- type: "ERROR" as const,
- }
+ message: i18n.str`The request to the backend take too long and was cancelled`,
+ description: i18n.str`Diagnostic from ${error.info.url} is '${error.message}'`,
+ type: "ERROR" as const,
+ }
: {
- message: i18n.str`The backend reported a problem: HTTP status #${error.status}`,
- description: i18n.str`Diagnostic from ${error.info.url} is '${error.message}'`,
- details:
- error.type === ErrorType.CLIENT ||
+ message: i18n.str`The backend reported a problem: HTTP status #${error.status}`,
+ description: i18n.str`Diagnostic from ${error.info.url} is '${error.message}'`,
+ details:
+ error.type === ErrorType.CLIENT ||
error.type === ErrorType.SERVER
- ? error.payload.hint
- : undefined,
- type: "ERROR" as const,
- };
+ ? error.payload.hint
+ : undefined,
+ type: "ERROR" as const,
+ };
return (
<Fragment>
<NotificationCard notification={notif} />
@@ -722,6 +724,40 @@ function AdminInstanceUpdatePage({
);
}
+function BankAccountBanner(): VNode {
+ const { i18n } = useTranslationContext();
+
+ const [_, updatePref] = usePreference();
+ const now = AbsoluteTime.now();
+ const oneDay = { d_ms: 1000 * 60 * 60 * 24 };
+ const tomorrow = AbsoluteTime.addDuration(now, oneDay);
+
+ return (
+ <NotificationCard
+ notification={{
+ type: "INFO",
+ message: i18n.str`You need to associate a bank account to receive revenue.`,
+ description: (
+ <div>
+ <p>
+ <i18n.Translate>Without this the merchant backend will refuse to create new orders.</i18n.Translate>
+ </p>
+ <div class="buttons is-right">
+ <button
+ class="button"
+ onClick={() => updatePref("hideMissingAccountUntil", tomorrow)}
+ >
+ <i18n.Translate>Hide for today</i18n.Translate>
+ </button>
+ </div>
+ </div>
+ ),
+ }}
+ />
+ )
+}
+
+
function KycBanner(): VNode {
const kycStatus = useInstanceKYCDetails();
const { i18n } = useTranslationContext();
diff --git a/packages/merchant-backoffice-ui/src/hooks/preference.ts b/packages/merchant-backoffice-ui/src/hooks/preference.ts
index 5a50eb378..a21d2921c 100644
--- a/packages/merchant-backoffice-ui/src/hooks/preference.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/preference.ts
@@ -28,12 +28,14 @@ import { buildStorageKey, useLocalStorage } from "@gnu-taler/web-util/browser";
export interface Preferences {
advanceOrderMode: boolean;
hideKycUntil: AbsoluteTime;
+ hideMissingAccountUntil: AbsoluteTime;
dateFormat: "ymd" | "dmy" | "mdy";
}
const defaultSettings: Preferences = {
advanceOrderMode: false,
hideKycUntil: AbsoluteTime.never(),
+ hideMissingAccountUntil: AbsoluteTime.never(),
dateFormat: "ymd",
};
@@ -41,6 +43,7 @@ export const codecForPreferences = (): Codec<Preferences> =>
buildCodecForObject<Preferences>()
.property("advanceOrderMode", codecForBoolean())
.property("hideKycUntil", codecForAbsoluteTime)
+ .property("hideMissingAccountUntil", codecForAbsoluteTime)
.property(
"dateFormat",
codecForEither(
diff --git a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx
index d53d93e8b..731ea8939 100644
--- a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx
@@ -123,7 +123,7 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode {
newValue.auth_token = undefined;
newValue.auth = newToken === null || newToken === undefined
? { method: "external" }
- : { method: "token", token: newToken };
+ : { method: "token", token: `secret-token:${newToken}` };
if (!newValue.address) newValue.address = {};
if (!newValue.jurisdiction) newValue.jurisdiction = {};
// remove above use conversion
diff --git a/packages/merchant-backoffice-ui/src/paths/settings/index.tsx b/packages/merchant-backoffice-ui/src/paths/settings/index.tsx
index 6290f48e6..0c4b9dd1a 100644
--- a/packages/merchant-backoffice-ui/src/paths/settings/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/settings/index.tsx
@@ -45,6 +45,7 @@ export function Settings({ onClose }: { onClose?: () => void }): VNode {
const next = s(value);
const v: Preferences = {
advanceOrderMode: next.advanceOrderMode ?? false,
+ hideMissingAccountUntil: next.hideMissingAccountUntil ?? AbsoluteTime.never(),
hideKycUntil: next.hideKycUntil ?? AbsoluteTime.never(),
dateFormat: next.dateFormat ?? "ymd",
};