commit 544ffe4ec1ab451c2efa1d105ab9c2355ae665dd parent dfaf6cc009b0df86d26c8d46a7d962b46fe36ce2 Author: Sebastian <sebasjm@gmail.com> Date: Wed, 5 Nov 2025 16:28:05 -0300 adding some missing bound method Diffstat:
16 files changed, 242 insertions(+), 137 deletions(-)
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/Table.tsx b/packages/merchant-backoffice-ui/src/paths/instance/accounts/list/Table.tsx @@ -28,7 +28,14 @@ import { succeedOrThrow, TalerMerchantApi, } from "@gnu-taler/taler-util"; -import { ButtonBetter, ButtonBetterBulma, LocalNotificationBannerBulma, SafeHandlerTemplate, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + ButtonBetter, + ButtonBetterBulma, + LocalNotificationBannerBulma, + SafeHandlerTemplate, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { Fragment, h, VNode } from "preact"; import { StateUpdater, useState } from "preact/hooks"; import { useSessionContext } from "../../../../context/session.js"; @@ -41,51 +48,26 @@ interface Props { onCreate: () => void; } -export function CardTable({ - accounts, - onCreate, - onSelect, -}: Props): VNode { +export function CardTable({ accounts, onCreate, onSelect }: Props): VNode { const [rowSelection, rowSelectionHandler] = useState<string[]>([]); const { i18n } = useTranslationContext(); const { state: session, lib } = useSessionContext(); const [notification, safeFunctionHandler] = useLocalNotificationBetter(); - const remove = safeFunctionHandler(lib.instance.deleteBankAccount).lambda((id: string) => !session.token ? undefined! : [session.token, id]) + const remove = safeFunctionHandler( + lib.instance.deleteBankAccount.bind(lib.instance), + ).lambda((id: string) => (!session.token ? undefined! : [session.token, id])); remove.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unauthorized` - case HttpStatusCode.NotFound: return i18n.str`Not found` + case HttpStatusCode.Unauthorized: + return i18n.str`Unauthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Not found`; } - } - remove.onSuccess = () => i18n.str`The bank account has been deleted.` - // async (e: TalerMerchantApi.BankAccountEntry) => { - // return lib.instance - // .deleteBankAccount(state.token, e.h_wire) - // .then((resp) => { - // if (resp.type === "ok") { - // setNotif({ - // message: i18n.str`The bank account details have been successfully deleted.`, - // type: "SUCCESS", - // }); - // } else { - // setNotif({ - // message: i18n.str`The bank account details could not be deleted.`, - // type: "ERROR", - // description: resp.detail?.hint, - // }); - // } - // }) - // .catch((error) => - // setNotif({ - // message: i18n.str`The bank account details could not be deleted.`, - // type: "ERROR", - // description: - // error instanceof Error ? error.message : String(error), - // }), - // ); - // } + }; + remove.onSuccess = () => i18n.str`The bank account has been deleted.`; + return ( <Fragment> <LocalNotificationBannerBulma notification={notification} /> @@ -130,13 +112,12 @@ export function CardTable({ </div> </div> </Fragment> - ); } interface TableProps { rowSelection: string[]; accounts: Entity[]; - onDelete: SafeHandlerTemplate<[id:string], unknown>; + onDelete: SafeHandlerTemplate<[id: string], unknown>; onSelect: (e: Entity) => void; rowSelectionHandler: StateUpdater<string[]>; } 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 @@ -107,7 +107,7 @@ export default function OrderList({ onCreate, onSelect }: Props): VNode { const data = {} as TalerMerchantApi.RefundRequest const refund = safeFunctionHandler( - lib.instance.addRefund, + lib.instance.addRefund.bind(lib.instance), !session.token || !orderToBeRefunded ? undefined : [session.token, orderToBeRefunded.order_id, data], ); refund.onSuccess = () => { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/CreatePage.tsx @@ -81,7 +81,7 @@ export function CreatePage({ onCreated, onBack }: Props): VNode { const hasErrors = errors !== undefined; const data = hasErrors ? undefined : state as TalerMerchantApi.OtpDeviceAddDetails - const create = safeFunctionHandler(lib.instance.addOtpDevice, !session.token || !data ? undefined : [session.token, data]) + const create = safeFunctionHandler(lib.instance.addOtpDevice.bind(lib.instance), !session.token || !data ? undefined : [session.token, data]) create.onSuccess = (success, token, req) => { onCreated(req) } diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx @@ -48,7 +48,7 @@ export function CardTable({ const { i18n } = useTranslationContext(); - const remove = safeFunctionHandler(lib.instance.deleteOtpDevice) + const remove = safeFunctionHandler(lib.instance.deleteOtpDevice.bind(lib.instance)) .lambda((id: string) => !session.token ? undefined! : [session.token, id]) remove.onFail = (fail) => { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/UpdatePage.tsx @@ -24,7 +24,12 @@ import { randomRfc3548Base32Key, TalerMerchantApi, } from "@gnu-taler/taler-util"; -import { ButtonBetterBulma, LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + ButtonBetterBulma, + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { FormProvider } from "../../../../components/form/FormProvider.js"; @@ -51,19 +56,23 @@ export function UpdatePage({ device, onUpdated, onBack }: Props): VNode { const [notification, safeFunctionHandler] = useLocalNotificationBetter(); const { state: session, lib } = useSessionContext(); - - const update = safeFunctionHandler(lib.instance - .updateOtpDevice, !session.token ? undefined : [session.token, device.id, state as Entity]) + const update = safeFunctionHandler( + lib.instance.updateOtpDevice.bind(lib.instance), + !session.token ? undefined : [session.token, device.id, state as Entity], + ); update.onSuccess = (suc, t, id, req) => { - onUpdated({ ...req, id: device.id }) - } + onUpdated({ ...req, id: device.id }); + }; update.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unauthorized` - case HttpStatusCode.NotFound: return i18n.str`Template id is unknown` - case HttpStatusCode.Conflict: return i18n.str`The provided information is inconsistent with the current state of the template` + case HttpStatusCode.Unauthorized: + return i18n.str`Unauthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Template id is unknown`; + case HttpStatusCode.Conflict: + return i18n.str`The provided information is inconsistent with the current state of the template`; } - } + }; return ( <div> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/create/CreatePage.tsx @@ -44,7 +44,7 @@ export function CreatePage({ onCreate, onBack }: Props): VNode { const [notification, safeFunctionHandler] = useLocalNotificationBetter(); const create = safeFunctionHandler( - lib.instance.addProduct, + lib.instance.addProduct.bind(lib.instance), !session.token || !form ? undefined : [session.token, form], ); create.onSuccess = onCreate; 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 @@ -58,7 +58,7 @@ export default function ProductList({ onCreate, onSelect }: Props): VNode { const { i18n } = useTranslationContext(); const remove = safeFunctionHandler( - lib.instance.deleteProduct, + lib.instance.deleteProduct.bind(lib.instance), !session.token || !deleting ? undefined : [session.token, deleting.id], ); remove.onSuccess = (suc, t, id) => { diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/create/CreatePage.tsx @@ -28,7 +28,12 @@ import { TalerMerchantApi, TranslatedString, } from "@gnu-taler/taler-util"; -import { ButtonBetterBulma, LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + ButtonBetterBulma, + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; import { @@ -139,9 +144,7 @@ export function CreatePage({ onCreated, onBack }: Props): VNode { amount: contract_amount, summary: contract_summary, currency: - cList.length > 1 && state.currency_editable - ? undefined - : config.currency, + cList.length > 1 && state.currency_editable ? undefined : config.currency, }; const data: TalerMerchantApi.TemplateAddDetails = { template_id: state.id!, @@ -156,16 +159,21 @@ export function CreatePage({ onCreated, onBack }: Props): VNode { : config.currency, }, otp_id: state.otpId!, - } + }; - const create = safeFunctionHandler(lib.instance.addTemplate.bind(lib.instance), !session.token ? undefined : [session.token, data]) - create.onSuccess = onCreated + const create = safeFunctionHandler( + lib.instance.addTemplate.bind(lib.instance), + !session.token ? undefined : [session.token, data], + ); + create.onSuccess = onCreated; create.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unauthorized` - case HttpStatusCode.NotFound: return i18n.str`Not found` + case HttpStatusCode.Unauthorized: + return i18n.str`Unauthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Not found`; } - } + }; const deviceList = !devices || devices instanceof TalerError || devices.type === "fail" 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 @@ -25,7 +25,11 @@ import { TalerMerchantApi, assertUnreachable, } from "@gnu-taler/taler-util"; -import { LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { useState } from "preact/hooks"; import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js"; @@ -77,16 +81,23 @@ export default function ListTemplates({ } } - const remove = safeFunctionHandler(lib.instance.deleteTemplate.bind(lib.instance), !session.token || !deleting ? undefined : [session.token, deleting.template_id]) + const remove = safeFunctionHandler( + lib.instance.deleteTemplate.bind(lib.instance), + !session.token || !deleting + ? undefined + : [session.token, deleting.template_id], + ); remove.onSuccess = () => { - setDeleting(null) - } + setDeleting(null); + }; remove.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unauthorized` - case HttpStatusCode.NotFound: return i18n.str`Not found` + case HttpStatusCode.Unauthorized: + return i18n.str`Unauthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Not found`; } - } + }; return ( <section class="section is-main-section"> @@ -137,7 +148,9 @@ export default function ListTemplates({ </i18n.Translate> </p> <p class="warning"> - <i18n.Translate>Deleting a template cannot be undone.</i18n.Translate> + <i18n.Translate> + Deleting a template cannot be undone. + </i18n.Translate> </p> </ConfirmModal> )} diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx @@ -26,9 +26,14 @@ import { HttpStatusCode, TalerError, TalerMerchantApi, - TranslatedString + TranslatedString, } from "@gnu-taler/taler-util"; -import { ButtonBetterBulma, LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + ButtonBetterBulma, + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { Fragment, VNode, h } from "preact"; import { useState } from "preact/hooks"; import { @@ -66,8 +71,11 @@ interface Props { template: TalerMerchantApi.TemplateDetails & WithId; } -function changeToCurrency(am: string | undefined, currency: string | undefined): string | undefined { - if (!am || !currency) return undefined +function changeToCurrency( + am: string | undefined, + currency: string | undefined, +): string | undefined { + if (!am || !currency) return undefined; const amount = Amounts.parse(am); if (!amount) return undefined; const newAmount = { @@ -100,7 +108,7 @@ export function UpdatePage({ template, onUpdated, onBack }: Props): VNode { const startingAmount = unsupportedCurrency ? changeToCurrency(currentAmount, default_currency) - : currentAmount + : currentAmount; const [state, setState] = useState<Partial<Entity>>({ description: template.template_description, @@ -108,8 +116,8 @@ export function UpdatePage({ template, onUpdated, onBack }: Props): VNode { otpId: template.otp_id, pay_duration: template.template_contract.pay_duration ? Duration.fromTalerProtocolDuration( - template.template_contract.pay_duration, - ) + template.template_contract.pay_duration, + ) : undefined, summary: template.editable_defaults?.summary ?? template.template_contract.summary, @@ -126,7 +134,7 @@ export function UpdatePage({ template, onUpdated, onBack }: Props): VNode { if (!newState.amount_editable) { newState.currency_editable = false; } - newState.amount = changeToCurrency(newState.amount, newState.currency) + newState.amount = changeToCurrency(newState.amount, newState.currency); return newState; }); } @@ -190,9 +198,7 @@ export function UpdatePage({ template, onUpdated, onBack }: Props): VNode { amount: contract_amount, summary: contract_summary, currency: - cList.length > 1 && state.currency_editable - ? undefined - : state.currency, + cList.length > 1 && state.currency_editable ? undefined : state.currency, }; const data: TalerMerchantApi.TemplatePatchDetails = { template_description: state.description!, @@ -206,16 +212,22 @@ export function UpdatePage({ template, onUpdated, onBack }: Props): VNode { : state.currency, }, otp_id: state.otpId!, - } - const update = safeFunctionHandler(lib.instance.updateTemplate.bind(lib.instance), !session.token || !!errors ? undefined : [session.token, template.id, data]) - update.onSuccess = onUpdated + }; + const update = safeFunctionHandler( + lib.instance.updateTemplate.bind(lib.instance), + !session.token || !!errors ? undefined : [session.token, template.id, data], + ); + update.onSuccess = onUpdated; update.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unauthorized` - case HttpStatusCode.NotFound: return i18n.str`Not found` - case HttpStatusCode.Conflict: return i18n.str`Conflict` + case HttpStatusCode.Unauthorized: + return i18n.str`Unauthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Not found`; + case HttpStatusCode.Conflict: + return i18n.str`Conflict`; } - } + }; return ( <div> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/use/UsePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/use/UsePage.tsx @@ -19,8 +19,18 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { AmountString, HttpStatusCode, TalerMerchantApi, UsingTemplateDetails } from "@gnu-taler/taler-util"; -import { ButtonBetterBulma, LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + AmountString, + HttpStatusCode, + TalerMerchantApi, + UsingTemplateDetails, +} from "@gnu-taler/taler-util"; +import { + ButtonBetterBulma, + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { useState } from "preact/hooks"; import { @@ -40,7 +50,12 @@ interface Props { onBack?: () => void; } -export function UsePage({ id, template, onBack, onOrderCreated }: Props): VNode { +export function UsePage({ + id, + template, + onBack, + onOrderCreated, +}: Props): VNode { const { i18n } = useTranslationContext(); const { lib } = useSessionContext(); const [notification, safeFunctionHandler] = useLocalNotificationBetter(); @@ -67,7 +82,6 @@ export function UsePage({ id, template, onBack, onOrderCreated }: Props): VNode (k) => (errors as any)[k] !== undefined, ); - /* * if (template.template_contract.amount) { delete state.amount; @@ -77,19 +91,27 @@ export function UsePage({ id, template, onBack, onOrderCreated }: Props): VNode } */ - const useTemplate = safeFunctionHandler(lib.instance.useTemplateCreateOrder.bind(lib.instance), !!errors ? undefined : [id, state as UsingTemplateDetails]) + const useTemplate = safeFunctionHandler( + lib.instance.useTemplateCreateOrder.bind(lib.instance), + !!errors ? undefined : [id, state as UsingTemplateDetails], + ); useTemplate.onSuccess = (success) => { - onOrderCreated(success.order_id) - } + onOrderCreated(success.order_id); + }; useTemplate.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unauthorized.` - case HttpStatusCode.NotFound: return i18n.str`Not found.` - case HttpStatusCode.Conflict: return i18n.str`Conflict.` - case HttpStatusCode.Gone: return i18n.str`No more stock for product with ID "${fail.body.product_id}".` - case HttpStatusCode.UnavailableForLegalReasons: return i18n.str`No exchange would accept a payment because of KYC requirements.` + case HttpStatusCode.Unauthorized: + return i18n.str`Unauthorized.`; + case HttpStatusCode.NotFound: + return i18n.str`Not found.`; + case HttpStatusCode.Conflict: + return i18n.str`Conflict.`; + case HttpStatusCode.Gone: + return i18n.str`No more stock for product with ID "${fail.body.product_id}".`; + case HttpStatusCode.UnavailableForLegalReasons: + return i18n.str`No exchange would accept a payment because of KYC requirements.`; } - } + }; return ( <div> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/create/CreatePage.tsx @@ -19,11 +19,24 @@ * @author Christian Blättler */ -import { AbsoluteTime, Duration, HttpStatusCode, TalerMerchantApi } from "@gnu-taler/taler-util"; -import { ButtonBetterBulma, LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + AbsoluteTime, + Duration, + HttpStatusCode, + TalerMerchantApi, +} from "@gnu-taler/taler-util"; +import { + ButtonBetterBulma, + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { h, VNode } from "preact"; import { useState } from "preact/hooks"; -import { FormErrors, FormProvider } from "../../../../components/form/FormProvider.js"; +import { + FormErrors, + FormProvider, +} from "../../../../components/form/FormProvider.js"; import { Input } from "../../../../components/form/Input.js"; import { InputDate } from "../../../../components/form/InputDate.js"; import { InputDuration } from "../../../../components/form/InputDuration.js"; @@ -52,7 +65,9 @@ export function CreatePage({ onCreated, onBack }: Props): VNode { duration: Duration.toTalerProtocolDuration(Duration.getForever()), valid_after: AbsoluteTime.toProtocolTimestamp(AbsoluteTime.never()), valid_before: AbsoluteTime.toProtocolTimestamp(AbsoluteTime.never()), - validity_granularity: Duration.toTalerProtocolDuration(Duration.getForever()), + validity_granularity: Duration.toTalerProtocolDuration( + Duration.getForever(), + ), }); const errors: FormErrors<Entity> = { @@ -61,20 +76,26 @@ export function CreatePage({ onCreated, onBack }: Props): VNode { description: !value.description ? i18n.str`Required` : undefined, valid_after: !value.valid_after ? undefined : undefined, valid_before: !value.valid_before ? i18n.str`Required` : undefined, - validity_granularity: !value.validity_granularity ? i18n.str`Required` : undefined, + validity_granularity: !value.validity_granularity + ? i18n.str`Required` + : undefined, duration: !value.duration ? i18n.str`Required` : undefined, kind: !value.kind ? i18n.str`Required` : undefined, }; - - const create = safeFunctionHandler(lib.instance.createTokenFamily.bind(lib.instance), !session.token || !!errors ? undefined : [session.token, value as Entity]); - create.onSuccess = onCreated + const create = safeFunctionHandler( + lib.instance.createTokenFamily.bind(lib.instance), + !session.token || !!errors ? undefined : [session.token, value as Entity], + ); + create.onSuccess = onCreated; create.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unaouthorized` - case HttpStatusCode.NotFound: return i18n.str`Not found` + case HttpStatusCode.Unauthorized: + return i18n.str`Unaouthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Not found`; } - } + }; return ( <div> @@ -91,7 +112,9 @@ export function CreatePage({ onCreated, onBack }: Props): VNode { > <InputWithAddon<Entity> name="slug" - addonBefore={new URL("tokenfamily/", session.backendUrl.href).href} + addonBefore={ + new URL("tokenfamily/", session.backendUrl.href).href + } label={i18n.str`Slug`} tooltip={i18n.str`Token family slug to use in URLs (for internal use only)`} /> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/list/index.tsx @@ -25,7 +25,11 @@ import { TalerMerchantApi, assertUnreachable, } from "@gnu-taler/taler-util"; -import { LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { VNode, h } from "preact"; import { useState } from "preact/hooks"; import { ErrorLoadingMerchant } from "../../../../components/ErrorLoadingMerchant.js"; @@ -71,18 +75,22 @@ export default function TokenFamilyList({ onCreate, onSelect }: Props): VNode { } } - - const remove = safeFunctionHandler(lib.instance.deleteTokenFamily.bind(lib.instance), !session.token || !deleting ? undefined : [session.token, deleting.slug]); + const remove = safeFunctionHandler( + lib.instance.deleteTokenFamily.bind(lib.instance), + !session.token || !deleting ? undefined : [session.token, deleting.slug], + ); remove.onSuccess = () => { setDeleting(null); - return i18n.str`Token family has been deleted.` - } + return i18n.str`Token family has been deleted.`; + }; remove.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unaouthorized` - case HttpStatusCode.NotFound: return i18n.str`Not found` + case HttpStatusCode.Unauthorized: + return i18n.str`Unaouthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Not found`; } - } + }; return ( <section class="section is-main-section"> diff --git a/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/tokenfamilies/update/UpdatePage.tsx @@ -20,10 +20,18 @@ */ import { HttpStatusCode, TalerMerchantApi } from "@gnu-taler/taler-util"; -import { ButtonBetterBulma, LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + ButtonBetterBulma, + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; import { h } from "preact"; import { useState } from "preact/hooks"; -import { FormErrors, FormProvider } from "../../../../components/form/FormProvider.js"; +import { + FormErrors, + FormProvider, +} from "../../../../components/form/FormProvider.js"; import { Input } from "../../../../components/form/Input.js"; import { InputDate } from "../../../../components/form/InputDate.js"; import { InputDuration } from "../../../../components/form/InputDuration.js"; @@ -53,15 +61,21 @@ export function UpdatePage({ onUpdated, onBack, tokenFamily }: Props) { const hasErrors = errors !== undefined; - const update = safeFunctionHandler(lib.instance.updateTokenFamily.bind(lib.instance), !session.token || !!errors ? undefined : [session.token, tokenFamily.slug, value as Entity]); - update.onSuccess = onUpdated + const update = safeFunctionHandler( + lib.instance.updateTokenFamily.bind(lib.instance), + !session.token || !!errors + ? undefined + : [session.token, tokenFamily.slug, value as Entity], + ); + update.onSuccess = onUpdated; update.onFail = (fail) => { switch (fail.case) { - case HttpStatusCode.Unauthorized: return i18n.str`Unaouthorized` - case HttpStatusCode.NotFound: return i18n.str`Not found` + case HttpStatusCode.Unauthorized: + return i18n.str`Unaouthorized`; + case HttpStatusCode.NotFound: + return i18n.str`Not found`; } - } - + }; return ( <div> @@ -73,7 +87,9 @@ export function UpdatePage({ onUpdated, onBack, tokenFamily }: Props) { <div class="level-left"> <div class="level-item"> <span class="is-size-4"> - <i18n.Translate>Token Family: <b>{tokenFamily.name}</b></i18n.Translate> + <i18n.Translate> + Token Family: <b>{tokenFamily.name}</b> + </i18n.Translate> </span> </div> </div> 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 @@ -36,7 +36,11 @@ import { NotFoundPageOrAdminCreate } from "../../../notfound/index.js"; import { useSessionContext } from "../../../../context/session.js"; import { NotificationCard } from "../../../../components/menu/index.js"; import { Notification } from "../../../../utils/types.js"; -import { LocalNotificationBannerBulma, useLocalNotificationBetter, useTranslationContext } from "@gnu-taler/web-util/browser"; +import { + LocalNotificationBannerBulma, + useLocalNotificationBetter, + useTranslationContext, +} from "@gnu-taler/web-util/browser"; interface Props { onCreate: () => void; @@ -52,7 +56,6 @@ export default function ListTransfer({ onCreate }: Props): VNode { const { state: session, lib } = useSessionContext(); - const [position, setPosition] = useState<string | undefined>(undefined); const instance = useInstanceBankAccounts(); @@ -83,7 +86,9 @@ export default function ListTransfer({ onCreate }: Props): VNode { ); // <LocalNotificationBannerBulma notification={notification} /> const [notification, safeFunctionHandler] = useLocalNotificationBetter(); - const remove = safeFunctionHandler(lib.instance.deleteWireTransfer.bind(lib.instance)) + const remove = safeFunctionHandler( + lib.instance.deleteWireTransfer.bind(lib.instance), + ); if (!result) return <Loading />; if (result instanceof TalerError) { return <ErrorLoadingMerchant error={result} />; @@ -113,7 +118,13 @@ export default function ListTransfer({ onCreate }: Props): VNode { onLoadMoreAfter={result.loadNext} onCreate={onCreate} onDelete={async (transfer) => { - (!session.token ? remove : remove.withArgs(session.token, String(transfer.transfer_serial_id))).call() + (!session.token + ? remove + : remove.withArgs( + session.token, + String(transfer.transfer_serial_id), + ) + ).call(); }} onShowAll={() => setFilter(undefined)} onShowUnverified={() => setFilter(false)} diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/Table.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/list/Table.tsx @@ -60,7 +60,9 @@ export function CardTable({ const [notification, safeFunctionHandler] = useLocalNotificationBetter(); - const deleteWebhook = safeFunctionHandler(lib.instance.deleteWebhook.bind(lib.instance)); + const deleteWebhook = safeFunctionHandler( + lib.instance.deleteWebhook.bind(lib.instance), + ); deleteWebhook.onSuccess = () => i18n.str`Webhook deleted successfully`; deleteWebhook.onFail = (fail) => { switch (fail.case) {