[slug].js
1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"use client";
import AboutInfoBrands from "@/components/Brands/AboutInfoBrands";
import CompanyOverview from "@/components/Brands/CompanyOverview";
import InnerBannerBrands from "@/components/Brands/InnerBannerBrands";
import Breadcrumb from "@/components/Common/Breadcrumb";
import { Contact } from "@/container/Home/Contact";
import { getBrandsBySlug } from "@/services/brandsApi";
import Head from "next/head";
export default function BrandDetailPage({ brandData }) {
console.log("brandData new", brandData)
const breadcrumbData = [
{
href: "/brands",
label: "Brands",
},
{
href: `/brands/${brandData?.slug}`,
label: brandData.banner?.title || brandData?.slug,
},
];
return (
<>
<Head>
<title>{brandData.banner?.title}</title>
</Head>
<Breadcrumb breadcrumbData={breadcrumbData} />
<InnerBannerBrands data={brandData?.banner} />
<AboutInfoBrands data={brandData?.info} />
<CompanyOverview data={brandData?.companyOverview} />
<Contact />
</>
);
}
export async function getServerSideProps({ params }) {
try {
const { slug } = params;
const brandData = await getBrandsBySlug(slug);
if (!brandData) {
return { notFound: true };
}
return {
props: {
brandData,
},
};
} catch (error) {
return {
notFound: true,
};
}
}