From c59f9a2556731ad95ab8bd7eefe7fa8a41629834 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 20 Dec 2022 17:45:24 -0300 Subject: use translation context from web-utils, don't use match react-router since is broken --- .../paths/instance/templates/update/UpdatePage.tsx | 44 +++++++++++----------- 1 file changed, 21 insertions(+), 23 deletions(-) (limited to 'packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx') 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>(template); const errors: FormErrors = { 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.`} /> 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`} />
{onBack && ( )} - Confirm + Confirm
-- cgit v1.2.3