summaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2024-03-22 13:56:16 -0300
committerSebastian <sebasjm@gmail.com>2024-03-26 16:57:58 -0300
commite2bfbced7ab027c901913e83ff7dd82240661990 (patch)
tree33752605ccaf19498f8c2a64e0117db16f22ce26 /packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
parent0c265558c4b7b78a13272abf1c4c84e3cf93c987 (diff)
downloadwallet-core-e2bfbced7ab027c901913e83ff7dd82240661990.tar.gz
wallet-core-e2bfbced7ab027c901913e83ff7dd82240661990.tar.bz2
wallet-core-e2bfbced7ab027c901913e83ff7dd82240661990.zip
work in progress, new api being used. merchant now should move into using the full API
Diffstat (limited to 'packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx25
1 files changed, 15 insertions, 10 deletions
diff --git a/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx b/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
index 47e3431e2..11344cde3 100644
--- a/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
+++ b/packages/merchant-backoffice-ui/src/components/product/ProductForm.tsx
@@ -19,11 +19,13 @@
* @author Sebastian Javier Marchano (sebasjm)
*/
-import { useTranslationContext } from "@gnu-taler/web-util/browser";
+import {
+ useMerchantApiContext,
+ useTranslationContext,
+} from "@gnu-taler/web-util/browser";
import { h } from "preact";
import { useCallback, useEffect, useState } from "preact/hooks";
import * as yup from "yup";
-import { useBackendContext } from "../../context/backend.js";
import { MerchantBackend } from "../../declaration.js";
import {
ProductCreateSchema as createSchema,
@@ -37,6 +39,7 @@ import { InputNumber } from "../form/InputNumber.js";
import { InputStock, Stock } from "../form/InputStock.js";
import { InputTaxes } from "../form/InputTaxes.js";
import { InputWithAddon } from "../form/InputWithAddon.js";
+import { useSessionContext } from "../../context/session.js";
type Entity = MerchantBackend.Products.ProductDetail & { product_id: string };
@@ -58,12 +61,12 @@ export function ProductForm({ onSubscribe, initial, alreadyExist }: Props) {
!initial || initial.total_stock === -1
? undefined
: {
- current: initial.total_stock || 0,
- lost: initial.total_lost || 0,
- sold: initial.total_sold || 0,
- address: initial.address,
- nextRestock: initial.next_restock,
- },
+ current: initial.total_stock || 0,
+ lost: initial.total_lost || 0,
+ sold: initial.total_sold || 0,
+ address: initial.address,
+ nextRestock: initial.next_restock,
+ },
});
let errors: FormErrors<Entity> = {};
@@ -114,7 +117,9 @@ export function ProductForm({ onSubscribe, initial, alreadyExist }: Props) {
onSubscribe(hasErrors ? undefined : submit);
}, [submit, hasErrors]);
- const { url: backendURL } = useBackendContext()
+ const {
+ state: { backendUrl },
+ } = useSessionContext();
const { i18n } = useTranslationContext();
return (
@@ -128,7 +133,7 @@ export function ProductForm({ onSubscribe, initial, alreadyExist }: Props) {
{alreadyExist ? undefined : (
<InputWithAddon<Entity>
name="product_id"
- addonBefore={`${backendURL}/product/`}
+ addonBefore={new URL("product/", backendUrl).href}
label={i18n.str`ID`}
tooltip={i18n.str`product identification to use in URLs (for internal use only)`}
/>