Skip to content

Commit f948922

Browse files
authored
Merge pull request #36 from bc-chaz/product-edit-fix
fix(common): fixes a bug when saving a product
2 parents 8833a79 + 6da4c70 commit f948922

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pages/products/[pid].tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { useRouter } from 'next/router';
22
import ErrorMessage from '../../components/error';
33
import Form from '../../components/form';
44
import Loading from '../../components/loading';
5+
import { useSession } from '../../context/session';
56
import { useProductInfo, useProductList } from '../../lib/hooks';
67
import { FormData } from '../../types';
78

89
const ProductInfo = () => {
910
const router = useRouter();
11+
const { storeHash } = useSession();
1012
const pid = Number(router.query?.pid);
1113
const { isError, isLoading, list = [], mutateList } = useProductList();
1214
const { isLoading: isInfoLoading, product } = useProductInfo(pid, list);
@@ -22,7 +24,7 @@ const ProductInfo = () => {
2224
mutateList([...filteredList, { ...product, ...data }], false);
2325

2426
// Update product details
25-
await fetch(`/api/products/${pid}`, {
27+
await fetch(`/api/products/${pid}?context=${storeHash}`, {
2628
method: 'PUT',
2729
headers: { 'Content-Type': 'application/json' },
2830
body: JSON.stringify(data),

0 commit comments

Comments
 (0)