inalco.js
2.23 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"use client";
import InnerBannerBrands from "@/components/valcucines/InnerBannerBrands";
import Breadcrumb from "@/components/Common/Breadcrumb";
import { Contact } from "@/container/Home/Contact";
import { getBrandsBySlug } from "@/services/brandsApi";
import Head from "next/head";
import AboutInfoBrands from "@/components/Inalco/AboutInfoBrands";
import CompanyOverview from "@/components/Inalco/CompanyOverview";
import WeCare from "@/components/Inalco/WeCare";
import { getInalcoBySlug } from "@/services/inalcoApi";
import { getRedisClient } from "@/redis-client";
const bannerData = [
{
id: 8,
title: "Inalco",
description: "<p>INALCO Is Synonymous With Sustainable Innovation, Creativity, Elegance, Excellence, Exclusivity And Emotions.</p>",
image: [
{
url: "/image/brands/Inalco.png",
},
{
url: "/image/brands/Inalco.png",
}
]
}
];
export default function inalcoPage({ brandData, inalcoData }) {
const breadcrumbData = [
{
href: "/brands",
label: "Brands",
},
{
href: `/brands/`,
label: "Inalco",
},
];
return (
<>
<Head>
<title>Akruti</title>
</Head>
<Breadcrumb breadcrumbData={breadcrumbData} />
<InnerBannerBrands data={inalcoData?.banner || []} />
<AboutInfoBrands infoData={inalcoData?.info || []} />
<CompanyOverview companyOverviewData={inalcoData?.overviewItem || []} />
<WeCare weCareData={inalcoData?.weCare || []} />
<Contact />
</>
);
}
export async function getServerSideProps({ params }) {
const redis = getRedisClient();
const REDIS_KEY = `${process.env.REDIS_KEY_PREFIX}_inalco`;
const REDIS_EXPIRE = parseInt(process.env.REDIS_KEY_EXPIRE) || 86400;
try {
const cachedData = await redis.get(REDIS_KEY);
if (cachedData) {
console.log("redis data fetched");
return { props: { inalcoData: JSON.parse(cachedData) } };
}
const inalcoData = await getInalcoBySlug();
await redis.set(REDIS_KEY, JSON.stringify(inalcoData), "EX", REDIS_EXPIRE);
console.log("normal data fetched");
return { props: { inalcoData } };
} catch (error) {
console.error("Product page SSR error:", error);
return { notFound: true };
}
}