@@ -2,11 +2,13 @@ import { useRouter } from 'next/router';
2
2
import ErrorMessage from '../../components/error' ;
3
3
import Form from '../../components/form' ;
4
4
import Loading from '../../components/loading' ;
5
+ import { useSession } from '../../context/session' ;
5
6
import { useProductInfo , useProductList } from '../../lib/hooks' ;
6
7
import { FormData } from '../../types' ;
7
8
8
9
const ProductInfo = ( ) => {
9
10
const router = useRouter ( ) ;
11
+ const { storeHash } = useSession ( ) ;
10
12
const pid = Number ( router . query ?. pid ) ;
11
13
const { isError, isLoading, list = [ ] , mutateList } = useProductList ( ) ;
12
14
const { isLoading : isInfoLoading , product } = useProductInfo ( pid , list ) ;
@@ -22,7 +24,7 @@ const ProductInfo = () => {
22
24
mutateList ( [ ...filteredList , { ...product , ...data } ] , false ) ;
23
25
24
26
// Update product details
25
- await fetch ( `/api/products/${ pid } ` , {
27
+ await fetch ( `/api/products/${ pid } ?context= ${ storeHash } ` , {
26
28
method : 'PUT' ,
27
29
headers : { 'Content-Type' : 'application/json' } ,
28
30
body : JSON . stringify ( data ) ,
0 commit comments