From c59f9a2556731ad95ab8bd7eefe7fa8a41629834 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
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<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>
-- 
cgit v1.2.3

