aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx')
-rw-r--r--packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx27
1 files changed, 21 insertions, 6 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx
index 5e3e58d80..56626cfa8 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/products/update/index.tsx
@@ -48,9 +48,8 @@ export default function UpdateProduct({
}: Props): VNode {
const result = useProductDetails(pid);
const [notif, setNotif] = useState<Notification | undefined>(undefined);
- const { lib } = useSessionContext();
- const { state } = useSessionContext();
-
+ const { state, lib } = useSessionContext();
+
const { i18n } = useTranslationContext();
if (!result) return <Loading />;
@@ -71,6 +70,7 @@ export default function UpdateProduct({
}
}
+
return (
<Fragment>
<NotificationCard notification={notif} />
@@ -79,12 +79,27 @@ export default function UpdateProduct({
onBack={onBack}
onUpdate={(data) => {
return lib.instance.updateProduct(state.token, pid, data)
- .then(onConfirm)
+ .then(resp => {
+ if (resp.type === "ok") {
+ setNotif({
+ message: i18n.str`Product (ID: ${pid}) has been updated`,
+ type: "SUCCESS",
+ });
+ onConfirm()
+ } else {
+ setNotif({
+ message: i18n.str`Could not update product`,
+ type: "ERROR",
+ description: resp.detail?.hint,
+ });
+
+ }
+ })
.catch((error) => {
setNotif({
- message: i18n.str`could not create product`,
+ message: i18n.str`Could not update product`,
type: "ERROR",
- description: error.message,
+ description: error instanceof Error ? error.message : String(error),
});
});
}}