Skip to content

Commit 6ba3285

Browse files
fix menu
1 parent a15436e commit 6ba3285

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/component/productDetails/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import styles from "./productDetails.module.scss";
1515
import { useRouter } from "next/router";
1616

1717
const ProductDetails: FC<productDetailsProps> = ({ product }) => {
18-
const router = useRouter();
19-
const locale = router.locale || "en";
18+
// const router = useRouter();
19+
// const locale = router.locale || "en";
2020
const { data: featuredProduct = [] } = useQuery({
21-
queryKey: ["featuredProduct", locale],
21+
queryKey: ["featuredProduct"],
2222
queryFn: async () => {
23-
const productData = await getData(FeaturedProductAPI, {}, "", "", locale);
23+
const productData = await getData(FeaturedProductAPI, {}, "", "");
2424
return FeaturedProductTransformer(productData);
2525
},
2626
enabled: !!product.id,

src/pages/category/[slug].tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
109109
const categoryId = context.query.slug;
110110
const page = context.query.page;
111111
const referer = context.req.headers.referer || null;
112-
112+
const menuData = await getData(MegaMenuAPI, {}, "", "", locale);
113+
const menu = MegaMenuTransformer(menuData).menuItems;
113114
if (!referer) {
114115
const categoryData = await getData(
115116
CategoryAPI,
@@ -119,14 +120,13 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
119120
locale
120121
);
121122
const data = CategoryTransformer(categoryData);
122-
const menuData = await getData(MegaMenuAPI, {}, "", "", locale);
123-
const menu = MegaMenuTransformer(menuData).menuItems;
123+
124124
return {
125125
props: { initialCategory: data, menu },
126126
};
127127
}
128128

129-
return { props: { initialCategory: null, categoryId } };
129+
return { props: { initialCategory: null, categoryId, menu } };
130130
}
131131

132132
export default CategoryPage;

src/pages/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ export default function Home({
5555
export async function getServerSideProps(context: GetServerSidePropsContext) {
5656
const referer = context.req.headers.referer || null;
5757
const locale = context.locale;
58-
58+
const menuData = await getData(MegaMenuAPI, {}, "", "", locale);
59+
const menu = MegaMenuTransformer(menuData).menuItems;
5960
if (!referer) {
6061
const data = await getData(HomePageAPI, {}, "", "", locale);
6162
const { homeProductCarousel } = HomeTransformer(data);
62-
const menuData = await getData(MegaMenuAPI, {}, "", "", locale);
63-
const menu = MegaMenuTransformer(menuData).menuItems;
63+
6464
return { props: { homeProductCarousel, menu } };
6565
}
66-
return { props: { homeProductCarousel: null } };
66+
return { props: { homeProductCarousel: null, menu } };
6767
}

src/pages/product/[slug].tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ProductPage: FC<ProductPageProps> = ({ initialProduct, productId }) => {
2727

2828
return (
2929
<>
30-
<MetaTags title={product.title} />
30+
<MetaTags title={product?.title} />
3131
{product && <ProductDetails product={product} />}
3232
</>
3333
);
@@ -37,6 +37,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
3737
const locale = context.locale;
3838
const productId = context.query.slug;
3939
const referer = context.req.headers.referer || null;
40+
const menuData = await getData(MegaMenuAPI, {}, "", "", locale);
41+
const menu = MegaMenuTransformer(menuData).menuItems;
4042
if (!referer) {
4143
const productData =
4244
productId &&
@@ -48,11 +50,9 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
4850
locale
4951
));
5052
const data = ProductTransformer(productData);
51-
const menuData = await getData(MegaMenuAPI, {}, "", "", locale);
52-
const menu = MegaMenuTransformer(menuData).menuItems;
5353
return { props: { initialProduct: data, productId, menu } };
5454
}
55-
return { props: { initialProduct: null, productId } };
55+
return { props: { initialProduct: null, productId, menu } };
5656
}
5757

5858
export default ProductPage;

0 commit comments

Comments
 (0)