Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
sujata
/
Akruti-Frontend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 037b0fd1
authored
2026-04-07 17:56:56 +0530
by
Ravindra Kanojiya
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
updated redis clear cache
1 parent
8334a2b2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
73 deletions
pages/about.js
pages/brands/inalco.js
pages/brands/rimadesio.js
pages/brands/valcucine.js
pages/catalogue.js
pages/collections/[category]/[subCategory]/[productSlug].js
pages/collections/[category]/[subCategory]/index.js
pages/collections/[category]/index.js
pages/about.js
View file @
037b0fd
...
@@ -6,6 +6,7 @@ import Breadcrumb from "@/components/Common/Breadcrumb";
...
@@ -6,6 +6,7 @@ import Breadcrumb from "@/components/Common/Breadcrumb";
import
InnerBanner
from
"@/components/Common/InnerBanner"
;
import
InnerBanner
from
"@/components/Common/InnerBanner"
;
import
{
Contact
}
from
"@/container/Home/Contact"
;
import
{
Contact
}
from
"@/container/Home/Contact"
;
import
{
getAboutBySlug
}
from
"@/services/aboutApi"
;
import
{
getAboutBySlug
}
from
"@/services/aboutApi"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
import
Head
from
"next/head"
;
import
Head
from
"next/head"
;
const
bannerData
=
[
const
bannerData
=
[
{
{
...
@@ -40,16 +41,21 @@ const AboutPage = ({ aboutData = {} }) => {
...
@@ -40,16 +41,21 @@ const AboutPage = ({ aboutData = {} }) => {
};
};
export
default
AboutPage
;
export
default
AboutPage
;
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
try
{
const
redis
=
getRedisClient
();
const
aboutData
=
await
getAboutBySlug
()
;
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_about`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
return
{
try
{
props
:
{
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
aboutData
,
if
(
cachedData
)
{
console
.
log
(
"redis data fetched"
);
return
{
props
:
{
aboutData
:
JSON
.
parse
(
cachedData
)
}
};
}
},
const
aboutData
=
await
getAboutBySlug
();
};
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
aboutData
),
"EX"
,
REDIS_EXPIRE
);
console
.
log
(
"normal data fetched"
);
return
{
props
:
{
aboutData
}
};
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Product page SSR error:"
,
error
);
console
.
error
(
"Product page SSR error:"
,
error
);
return
{
notFound
:
true
};
return
{
notFound
:
true
};
...
...
pages/brands/inalco.js
View file @
037b0fd
...
@@ -8,6 +8,7 @@ import AboutInfoBrands from "@/components/Inalco/AboutInfoBrands";
...
@@ -8,6 +8,7 @@ import AboutInfoBrands from "@/components/Inalco/AboutInfoBrands";
import
CompanyOverview
from
"@/components/Inalco/CompanyOverview"
;
import
CompanyOverview
from
"@/components/Inalco/CompanyOverview"
;
import
WeCare
from
"@/components/Inalco/WeCare"
;
import
WeCare
from
"@/components/Inalco/WeCare"
;
import
{
getInalcoBySlug
}
from
"@/services/inalcoApi"
;
import
{
getInalcoBySlug
}
from
"@/services/inalcoApi"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
const
bannerData
=
[
const
bannerData
=
[
{
{
id
:
8
,
id
:
8
,
...
@@ -53,16 +54,21 @@ export default function inalcoPage({ brandData, inalcoData }) {
...
@@ -53,16 +54,21 @@ export default function inalcoPage({ brandData, inalcoData }) {
);
);
}
}
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
try
{
const
redis
=
getRedisClient
();
const
inalcoData
=
await
getInalcoBySlug
()
;
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_inalco`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
return
{
try
{
props
:
{
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
inalcoData
,
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
)
{
}
catch
(
error
)
{
console
.
error
(
"Product page SSR error:"
,
error
);
console
.
error
(
"Product page SSR error:"
,
error
);
return
{
notFound
:
true
};
return
{
notFound
:
true
};
...
...
pages/brands/rimadesio.js
View file @
037b0fd
...
@@ -8,6 +8,7 @@ import Head from "next/head";
...
@@ -8,6 +8,7 @@ import Head from "next/head";
import
AboutInfoBrands
from
"@/components/Rimadesios/AboutInfoBrands"
;
import
AboutInfoBrands
from
"@/components/Rimadesios/AboutInfoBrands"
;
import
CompanyOverview
from
"@/components/Rimadesios/CompanyOverview"
;
import
CompanyOverview
from
"@/components/Rimadesios/CompanyOverview"
;
import
{
getRimadesioBySlug
}
from
"@/services/rimadesioApi"
;
import
{
getRimadesioBySlug
}
from
"@/services/rimadesioApi"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
const
bannerData
=
[
const
bannerData
=
[
{
{
id
:
8
,
id
:
8
,
...
@@ -54,16 +55,21 @@ export default function rimadesiosPage({ brandData, rimadesioData }) {
...
@@ -54,16 +55,21 @@ export default function rimadesiosPage({ brandData, rimadesioData }) {
}
}
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
try
{
const
redis
=
getRedisClient
();
const
rimadesioData
=
await
getRimadesioBySlug
()
;
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_rimadesio`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
return
{
try
{
props
:
{
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
rimadesioData
,
if
(
cachedData
)
{
console
.
log
(
"redis data fetched"
);
return
{
props
:
{
rimadesioData
:
JSON
.
parse
(
cachedData
)
}
};
}
},
const
rimadesioData
=
await
getRimadesioBySlug
();
};
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
rimadesioData
),
"EX"
,
REDIS_EXPIRE
);
console
.
log
(
"normal data fetched"
);
return
{
props
:
{
rimadesioData
}
};
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Product page SSR error:"
,
error
);
console
.
error
(
"Product page SSR error:"
,
error
);
return
{
notFound
:
true
};
return
{
notFound
:
true
};
...
...
pages/brands/valcucine.js
View file @
037b0fd
...
@@ -8,6 +8,7 @@ import { Contact } from "@/container/Home/Contact";
...
@@ -8,6 +8,7 @@ import { Contact } from "@/container/Home/Contact";
import
{
getBrandsBySlug
}
from
"@/services/brandsApi"
;
import
{
getBrandsBySlug
}
from
"@/services/brandsApi"
;
import
Head
from
"next/head"
;
import
Head
from
"next/head"
;
import
{
getValcucineBySlug
}
from
"@/services/valcucineApi"
;
import
{
getValcucineBySlug
}
from
"@/services/valcucineApi"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
const
bannerData
=
[
const
bannerData
=
[
{
{
id
:
8
,
id
:
8
,
...
@@ -57,16 +58,21 @@ export default function valcucinesPage({ brandData, valcucineData }) {
...
@@ -57,16 +58,21 @@ export default function valcucinesPage({ brandData, valcucineData }) {
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
try
{
const
redis
=
getRedisClient
();
const
valcucineData
=
await
getValcucineBySlug
()
;
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_valcucine`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
return
{
try
{
props
:
{
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
valcucineData
,
if
(
cachedData
)
{
console
.
log
(
"redis data fetched"
);
return
{
props
:
{
valcucineData
:
JSON
.
parse
(
cachedData
)
}
};
}
},
const
valcucineData
=
await
getValcucineBySlug
();
};
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
valcucineData
),
"EX"
,
REDIS_EXPIRE
);
console
.
log
(
"normal data fetched"
);
return
{
props
:
{
valcucineData
}
};
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Product page SSR error:"
,
error
);
console
.
error
(
"Product page SSR error:"
,
error
);
return
{
notFound
:
true
};
return
{
notFound
:
true
};
...
...
pages/catalogue.js
View file @
037b0fd
...
@@ -5,6 +5,7 @@ import HeadTitle from "@/components/Common/HeadTitle";
...
@@ -5,6 +5,7 @@ import HeadTitle from "@/components/Common/HeadTitle";
import
InnerBanner
from
"@/components/Common/InnerBanner"
;
import
InnerBanner
from
"@/components/Common/InnerBanner"
;
import
InnerContent
from
"@/components/Contacts/InnerContent"
;
import
InnerContent
from
"@/components/Contacts/InnerContent"
;
import
{
getCataloguesBySlug
}
from
"@/services/cataloguesApi"
;
import
{
getCataloguesBySlug
}
from
"@/services/cataloguesApi"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
import
Head
from
"next/head"
;
import
Head
from
"next/head"
;
const
bannerData
=
[
const
bannerData
=
[
{
{
...
@@ -44,16 +45,21 @@ const ContactsPage = ({cataloguesData={cataloguesData}}) => {
...
@@ -44,16 +45,21 @@ const ContactsPage = ({cataloguesData={cataloguesData}}) => {
};
};
export
default
ContactsPage
;
export
default
ContactsPage
;
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
const
redis
=
getRedisClient
();
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_catalogues`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
try
{
try
{
const
cataloguesData
=
await
getCataloguesBySlug
();
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
if
(
cachedData
)
{
console
.
log
(
"redis data fetched"
);
return
{
props
:
{
cataloguesData
:
JSON
.
parse
(
cachedData
)
}
};
}
return
{
const
cataloguesData
=
await
getCataloguesBySlug
();
props
:
{
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
cataloguesData
),
"EX"
,
REDIS_EXPIRE
);
cataloguesData
,
console
.
log
(
"normal data fetched"
);
return
{
props
:
{
cataloguesData
}
};
},
};
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Product page SSR error:"
,
error
);
console
.
error
(
"Product page SSR error:"
,
error
);
return
{
notFound
:
true
};
return
{
notFound
:
true
};
...
...
pages/collections/[category]/[subCategory]/[productSlug].js
View file @
037b0fd
...
@@ -8,6 +8,7 @@ import Catalogues from "@/container/Home/Catalogues";
...
@@ -8,6 +8,7 @@ import Catalogues from "@/container/Home/Catalogues";
import
{
Contact
}
from
"@/container/Home/Contact"
;
import
{
Contact
}
from
"@/container/Home/Contact"
;
import
{
getCollectionDetailCategoryData
}
from
"@/services/collectionDetailCategoryApi"
;
import
{
getCollectionDetailCategoryData
}
from
"@/services/collectionDetailCategoryApi"
;
import
{
getCataloguesBySlug
}
from
"@/services/cataloguesApi"
;
import
{
getCataloguesBySlug
}
from
"@/services/cataloguesApi"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
import
CompanyOverview
from
"@/components/Collection/CompanyOverview"
;
import
CompanyOverview
from
"@/components/Collection/CompanyOverview"
;
import
TechnicalDetails
from
"@/components/Collection/TechnicalDetails"
;
import
TechnicalDetails
from
"@/components/Collection/TechnicalDetails"
;
import
Explore
from
"@/components/Collection/Explore"
;
import
Explore
from
"@/components/Collection/Explore"
;
...
@@ -153,8 +154,17 @@ export default ProductPage;
...
@@ -153,8 +154,17 @@ export default ProductPage;
/* ---------- SSR ---------- */
/* ---------- SSR ---------- */
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
const
{
productSlug
}
=
params
;
const
redis
=
getRedisClient
();
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_product_
${
productSlug
}
`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
try
{
try
{
const
{
productSlug
}
=
params
;
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
if
(
cachedData
)
{
console
.
log
(
"redis data fetched"
);
return
{
props
:
JSON
.
parse
(
cachedData
)
};
}
const
productData
=
await
getCollectionDetailCategoryData
(
productSlug
);
const
productData
=
await
getCollectionDetailCategoryData
(
productSlug
);
const
cataloguesData
=
await
getCataloguesBySlug
();
const
cataloguesData
=
await
getCataloguesBySlug
();
...
@@ -163,12 +173,10 @@ export async function getServerSideProps({ params }) {
...
@@ -163,12 +173,10 @@ export async function getServerSideProps({ params }) {
return
{
notFound
:
true
};
return
{
notFound
:
true
};
}
}
return
{
const
result
=
{
productData
:
productData
[
0
],
cataloguesData
};
props
:
{
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
result
),
"EX"
,
REDIS_EXPIRE
);
productData
:
productData
[
0
],
// ✅ single product
console
.
log
(
"normal data fetched"
);
cataloguesData
,
return
{
props
:
result
};
},
};
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Product page SSR error:"
,
error
);
console
.
error
(
"Product page SSR error:"
,
error
);
return
{
notFound
:
true
};
return
{
notFound
:
true
};
...
...
pages/collections/[category]/[subCategory]/index.js
View file @
037b0fd
...
@@ -16,6 +16,7 @@ import { getCollectionDetailCategoryData } from "@/services/collectionDetailCate
...
@@ -16,6 +16,7 @@ import { getCollectionDetailCategoryData } from "@/services/collectionDetailCate
import
{
getCollectionSubCategoryData
}
from
"@/services/collectionSubCategoryApi"
;
import
{
getCollectionSubCategoryData
}
from
"@/services/collectionSubCategoryApi"
;
import
{
getCataloguesBySlug
}
from
"@/services/cataloguesApi"
;
import
{
getCataloguesBySlug
}
from
"@/services/cataloguesApi"
;
import
{
fetchFromStrapi
}
from
"@/services/api"
;
import
{
fetchFromStrapi
}
from
"@/services/api"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
import
{
Tab
,
Tabs
}
from
"react-bootstrap"
;
import
{
Tab
,
Tabs
}
from
"react-bootstrap"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
...
@@ -194,22 +195,31 @@ export default SubCategoryOrProductPage;
...
@@ -194,22 +195,31 @@ export default SubCategoryOrProductPage;
====================================================== */
====================================================== */
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
const
{
subCategory
}
=
params
;
const
redis
=
getRedisClient
();
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_subcategory_
${
subCategory
}
`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
try
{
try
{
const
{
subCategory
}
=
params
;
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
if
(
cachedData
)
{
console
.
log
(
"redis data fetched"
);
return
{
props
:
JSON
.
parse
(
cachedData
)
};
}
/* 1️⃣ Check if this slug is a PRODUCT */
/* 1️⃣ Check if this slug is a PRODUCT */
const
productCheck
=
await
getCollectionDetailCategoryData
(
subCategory
);
const
productCheck
=
await
getCollectionDetailCategoryData
(
subCategory
);
if
(
productCheck
&&
productCheck
.
length
>
0
)
{
if
(
productCheck
&&
productCheck
.
length
>
0
)
{
const
cataloguesData
=
await
getCataloguesBySlug
();
const
cataloguesData
=
await
getCataloguesBySlug
();
const
result
=
{
return
{
type
:
"product"
,
props
:
{
productData
:
productCheck
[
0
],
type
:
"product"
,
cataloguesData
,
productData
:
productCheck
[
0
],
cataloguesData
,
},
};
};
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
result
),
"EX"
,
REDIS_EXPIRE
);
console
.
log
(
"normal data fetched"
);
return
{
props
:
result
};
}
}
/* 2️⃣ Otherwise treat as SUBCATEGORY */
/* 2️⃣ Otherwise treat as SUBCATEGORY */
...
@@ -243,13 +253,10 @@ export async function getServerSideProps({ params }) {
...
@@ -243,13 +253,10 @@ export async function getServerSideProps({ params }) {
const
activeSubCategory
=
const
activeSubCategory
=
categoriesSub
.
find
((
item
)
=>
item
.
slug
===
subCategory
)
||
null
;
categoriesSub
.
find
((
item
)
=>
item
.
slug
===
subCategory
)
||
null
;
return
{
const
result
=
{
type
:
"subcategory"
,
products
,
activeSubCategory
};
props
:
{
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
result
),
"EX"
,
REDIS_EXPIRE
);
type
:
"subcategory"
,
console
.
log
(
"normal data fetched"
);
products
,
return
{
props
:
result
};
activeSubCategory
,
},
};
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
console
.
error
(
error
);
return
{
return
{
...
...
pages/collections/[category]/index.js
View file @
037b0fd
...
@@ -4,6 +4,7 @@ import HeadTitle from "@/components/Common/HeadTitle";
...
@@ -4,6 +4,7 @@ import HeadTitle from "@/components/Common/HeadTitle";
import
{
getCollectionPageData
}
from
"@/services/collectionApi"
;
import
{
getCollectionPageData
}
from
"@/services/collectionApi"
;
import
{
getCollectionCategoryBySlug
}
from
"@/services/collectionCategoryApi"
;
import
{
getCollectionCategoryBySlug
}
from
"@/services/collectionCategoryApi"
;
import
{
getCollectionSubCategoryData
}
from
"@/services/collectionSubCategoryApi"
;
import
{
getCollectionSubCategoryData
}
from
"@/services/collectionSubCategoryApi"
;
import
{
getRedisClient
}
from
"@/redis-client"
;
export
default
function
CategoryPage
({
categoryData
,
categoriesSub
,
collectionDataa
})
{
export
default
function
CategoryPage
({
categoryData
,
categoriesSub
,
collectionDataa
})
{
...
@@ -39,26 +40,29 @@ export default function CategoryPage({ categoryData, categoriesSub,collectionDat
...
@@ -39,26 +40,29 @@ export default function CategoryPage({ categoryData, categoriesSub,collectionDat
}
}
export
async
function
getServerSideProps
({
params
})
{
export
async
function
getServerSideProps
({
params
})
{
const
{
category
}
=
params
;
const
redis
=
getRedisClient
();
const
REDIS_KEY
=
`
${
process
.
env
.
REDIS_KEY_PREFIX
}
_category_
${
category
}
`
;
const
REDIS_EXPIRE
=
parseInt
(
process
.
env
.
REDIS_KEY_EXPIRE
)
||
86400
;
try
{
try
{
const
{
category
}
=
params
;
const
cachedData
=
await
redis
.
get
(
REDIS_KEY
);
if
(
cachedData
)
{
console
.
log
(
"redis data fetched"
);
return
{
props
:
JSON
.
parse
(
cachedData
)
};
}
const
categoryData
=
await
getCollectionCategoryBySlug
(
category
);
const
categoryData
=
await
getCollectionCategoryBySlug
(
category
);
const
categoriesSub
=
await
getCollectionSubCategoryData
(
category
);
const
categoriesSub
=
await
getCollectionSubCategoryData
(
category
);
// const collectionDataa = await getCollectionPageData(category);
const
result
=
{
categoryData
,
categoriesSub
};
await
redis
.
set
(
REDIS_KEY
,
JSON
.
stringify
(
result
),
"EX"
,
REDIS_EXPIRE
);
return
{
console
.
log
(
"normal data fetched"
);
props
:
{
return
{
props
:
result
};
categoryData
,
categoriesSub
,
// collectionDataa
},
};
}
catch
(
error
)
{
}
catch
(
error
)
{
return
{
return
{
props
:
{
props
:
{
categoryData
:
null
,
categoryData
:
null
,
categoriesSub
:
[],
categoriesSub
:
[],
// collectionDataa:[]
},
},
};
};
}
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment