Skip to content

Commit

Permalink
Merge pull request #36 from bc-chaz/product-edit-fix
Browse files Browse the repository at this point in the history
fix(common): fixes a bug when saving a product
  • Loading branch information
bc-chaz committed Jun 10, 2021
2 parents 8833a79 + 6da4c70 commit f948922
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pages/products/[pid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { useRouter } from 'next/router';
import ErrorMessage from '../../components/error';
import Form from '../../components/form';
import Loading from '../../components/loading';
import { useSession } from '../../context/session';
import { useProductInfo, useProductList } from '../../lib/hooks';
import { FormData } from '../../types';

const ProductInfo = () => {
const router = useRouter();
const { storeHash } = useSession();
const pid = Number(router.query?.pid);
const { isError, isLoading, list = [], mutateList } = useProductList();
const { isLoading: isInfoLoading, product } = useProductInfo(pid, list);
Expand All @@ -22,7 +24,7 @@ const ProductInfo = () => {
mutateList([...filteredList, { ...product, ...data }], false);

// Update product details
await fetch(`/api/products/${pid}`, {
await fetch(`/api/products/${pid}?context=${storeHash}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
Expand Down

0 comments on commit f948922

Please sign in to comment.