diff options
author | Sebastian <sebasjm@gmail.com> | 2022-12-20 17:45:24 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-12-20 17:45:24 -0300 |
commit | c59f9a2556731ad95ab8bd7eefe7fa8a41629834 (patch) | |
tree | 5cb60195d66cebbee0ba99e05eafe22f369a46a8 /packages/merchant-backoffice-ui/src/paths/instance/templates/update | |
parent | 382e66b179d6fda2598936196b2ae1b97bfab8ef (diff) | |
download | wallet-core-c59f9a2556731ad95ab8bd7eefe7fa8a41629834.tar.xz |
use translation context from web-utils, don't use match react-router since is broken
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/templates/update')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx | 44 | ||||
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/templates/update/index.tsx | 7 |
2 files changed, 24 insertions, 27 deletions
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 index 42d9e5825..a49e8000b 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx @@ -19,6 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ +import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { h, VNode } from "preact"; import { useState } from "preact/hooks"; import { AsyncButton } from "../../../../components/exception/AsyncButton.js"; @@ -31,11 +32,8 @@ import { InputCurrency } from "../../../../components/form/InputCurrency.js"; import { InputDuration } from "../../../../components/form/InputDuration.js"; import { InputNumber } from "../../../../components/form/InputNumber.js"; import { InputWithAddon } from "../../../../components/form/InputWithAddon.js"; -import { ProductForm } from "../../../../components/product/ProductForm.js"; import { useBackendContext } from "../../../../context/backend.js"; import { MerchantBackend, WithId } from "../../../../declaration.js"; -import { useListener } from "../../../../hooks/listener.js"; -import { Translate, useTranslator } from "../../../../i18n/index.js"; import { undefinedIfEmpty } from "../../../../utils/table.js"; type Entity = MerchantBackend.Template.TemplatePatchDetails & WithId; @@ -47,28 +45,28 @@ interface Props { } export function UpdatePage({ template, onUpdate, onBack }: Props): VNode { - const i18n = useTranslator(); + const { i18n } = useTranslationContext(); const backend = useBackendContext(); const [state, setState] = useState<Partial<Entity>>(template); const errors: FormErrors<Entity> = { template_description: !state.template_description - ? i18n`should not be empty` + ? i18n.str`should not be empty` : undefined, template_contract: !state.template_contract ? undefined : undefinedIfEmpty({ minimum_age: state.template_contract.minimum_age < 0 - ? i18n`should be greater that 0` + ? i18n.str`should be greater that 0` : undefined, pay_duration: !state.template_contract.pay_duration - ? i18n`can't be empty` + ? i18n.str`can't be empty` : state.template_contract.pay_duration.d_us === "forever" ? undefined : state.template_contract.pay_duration.d_us < 1000 - ? i18n`to short` + ? i18n.str`to short` : undefined, }), }; @@ -112,57 +110,57 @@ export function UpdatePage({ template, onUpdate, onBack }: Props): VNode { name="id" addonBefore={`templates/`} readonly - label={i18n`Identifier`} - tooltip={i18n`Name of the template in URLs.`} + label={i18n.str`Identifier`} + tooltip={i18n.str`Name of the template in URLs.`} /> <Input<Entity> name="template_description" - label={i18n`Description`} + label={i18n.str`Description`} help="" - tooltip={i18n`Describe what this template stands for`} + tooltip={i18n.str`Describe what this template stands for`} /> <Input name="template_contract.summary" inputType="multiline" - label={i18n`Order summary`} - tooltip={i18n`Title of the order to be shown to the customer`} + label={i18n.str`Order summary`} + tooltip={i18n.str`Title of the order to be shown to the customer`} /> <InputCurrency name="template_contract.amount" - label={i18n`Order price`} - tooltip={i18n`total product price added up`} + label={i18n.str`Order price`} + tooltip={i18n.str`total product price added up`} /> <InputNumber name="template_contract.minimum_age" - label={i18n`Minimum age`} + label={i18n.str`Minimum age`} help="" - tooltip={i18n`Is this contract restricted to some age?`} + tooltip={i18n.str`Is this contract restricted to some age?`} /> <InputDuration name="template_contract.pay_duration" - label={i18n`Payment timeout`} + label={i18n.str`Payment timeout`} help="" - tooltip={i18n`How much time has the customer to complete the payment once the order was created.`} + tooltip={i18n.str`How much time has the customer to complete the payment once the order was created.`} /> </FormProvider> <div class="buttons is-right mt-5"> {onBack && ( <button class="button" onClick={onBack}> - <Translate>Cancel</Translate> + <i18n.Translate>Cancel</i18n.Translate> </button> )} <AsyncButton disabled={hasErrors} data-tooltip={ hasErrors - ? i18n`Need to complete marked fields` + ? i18n.str`Need to complete marked fields` : "confirm operation" } onClick={submitForm} > - <Translate>Confirm</Translate> + <i18n.Translate>Confirm</i18n.Translate> </AsyncButton> </div> </div> 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 25dc9abdc..4a4cc4274 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 @@ -19,18 +19,17 @@ * @author Sebastian Javier Marchano (sebasjm) */ +import { useTranslationContext } from "@gnu-taler/web-util/lib/index.browser"; import { Fragment, h, VNode } from "preact"; import { useState } from "preact/hooks"; import { Loading } from "../../../../components/exception/loading.js"; import { NotificationCard } from "../../../../components/menu/index.js"; import { MerchantBackend, WithId } from "../../../../declaration.js"; import { HttpError } from "../../../../hooks/backend.js"; -import { useProductAPI, useProductDetails } from "../../../../hooks/product.js"; import { useTemplateAPI, useTemplateDetails, } from "../../../../hooks/templates.js"; -import { useTranslator } from "../../../../i18n/index.js"; import { Notification } from "../../../../utils/types.js"; import { UpdatePage } from "./UpdatePage.js"; @@ -56,7 +55,7 @@ export default function UpdateTemplate({ const result = useTemplateDetails(tid); const [notif, setNotif] = useState<Notification | undefined>(undefined); - const i18n = useTranslator(); + const { i18n } = useTranslationContext(); if (result.clientError && result.isUnauthorized) return onUnauthorized(); if (result.clientError && result.isNotfound) return onNotFound(); @@ -74,7 +73,7 @@ export default function UpdateTemplate({ .then(onConfirm) .catch((error) => { setNotif({ - message: i18n`could not update template`, + message: i18n.str`could not update template`, type: "ERROR", description: error.message, }); |