fix: add safety checks for data structure in Hero, Production, Products components; update SVG attribute for Header component

This commit is contained in:
2026-04-28 21:52:21 +03:30
parent 4c307f7a92
commit a3ed2599ed
8 changed files with 104 additions and 75 deletions

2
.env
View File

@@ -1,4 +1,4 @@
NEXT_PUBLIC_API_BASE_URL=http://cms.soheilkhaledabadi.ir
NEXT_PUBLIC_API_BASE_URL=https://cms.soheilkhaledabadi.ir
NEXT_PUBLIC_IMAGE_HOSTNAME=axicon-portal.iran.liara.run
ARVAN_NAMESPACE=docker.arvancloud.ir
IMAGE_TAG=latest

View File

@@ -19,13 +19,19 @@ export default async function About({lang}) {
const data = await getData(lang === 'fa' ? 1 : 2);
// Add safety checks for data structure
if (!data || typeof data !== 'object') {
console.error('About: Invalid data received from API');
return null;
}
return(
<div className='grid lg:grid-cols-3 grid-cols-1 grid-rows-3 gap-2 font-[5] my-16 mx-8 lg:mx-28'>
<div className='flex justify-between items-center p-8'>
<div className='flex flex-col w-full'>
<span>{ data.aboutSuper[0].body }</span>
<span className='font-[4] text-3xl lg:text-4xl pt-2'>{ data.aboutHead[0].body }</span>
<span>{ data.aboutSuper?.[0]?.body || '' }</span>
<span className='font-[4] text-3xl lg:text-4xl pt-2'>{ data.aboutHead?.[0]?.body || '' }</span>
</div>
<svg className='' width="128" height="74" viewBox="0 0 128 74" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M80.5657 36.6117C80.5657 46.6722 83.2246 55.7663 87.5075 62.3363C91.7923 68.9091 97.6768 72.9235 104.133 72.9235C110.589 72.9235 116.473 68.9091 120.758 62.3363C125.041 55.7663 127.7 46.6722 127.7 36.6117C127.7 26.5513 125.041 17.4572 120.758 10.8872C116.473 4.31441 110.589 0.3 104.133 0.3C97.6768 0.3 91.7923 4.31441 87.5075 10.8872C83.2246 17.4572 80.5657 26.5513 80.5657 36.6117Z" stroke="url(#paint0_linear_124_2568)" stroke-width="0.6"/>
@@ -53,16 +59,16 @@ export default async function About({lang}) {
</svg>
</div>
<div className='row-span-2 flex flex-col justify-between py-10 px-8 bg-zinc-100 rounded-xl h-full'>
<span className='font-[4] text-xl'>{ data.about1Head[0].body }</span>
<p className='text-zinc-600 py-4'> { data.about1Desc[0].body }
<span className='font-[4] text-xl'>{ data.about1Head?.[0]?.body || '' }</span>
<p className='text-zinc-600 py-4'> { data.about1Desc?.[0]?.body || '' }
</p>
<Image alt="" src={PicAbout} className=''/>
</div>
<Image alt="" src={ data.about1Image[0].body } width={800} height={800} className='row-span-3 h-full w-full object-cover rounded-xl'/>
<Image alt="" src={ data.about1Image?.[0]?.body || '' } width={800} height={800} className='row-span-3 h-full w-full object-cover rounded-xl'/>
<div className='row-span-2 flex flex-col justify-between py-10 px-8 bg-zinc-100 rounded-xl h-full'>
<span className='font-[4] text-xl'>{ data.about2Head[0].body }</span>
<p className='text-zinc-600 py-4'> { data.about2Desc[0].body }
<span className='font-[4] text-xl'>{ data.about2Head?.[0]?.body || '' }</span>
<p className='text-zinc-600 py-4'> { data.about2Desc?.[0]?.body || '' }
</p>
<Link href="#products" className='hidden lg:flex items-center bg-red-700 font-[4] w-fit p-2 '>
<span className='text-md text-zinc-50'> بیشتر بدانید</span>
@@ -73,7 +79,7 @@ export default async function About({lang}) {
</div>
</Link>
</div>
<Image alt="" src={ data.about2Image[0].body } width={800} height={800} className='max-h-48 object-cover rounded-xl w-full h-full'/>
<Image alt="" src={ data.about2Image?.[0]?.body || '' } width={800} height={800} className='max-h-48 object-cover rounded-xl w-full h-full'/>
</div>
)

View File

@@ -34,6 +34,13 @@ async function getData(id) {
export default async function Footer({ lang }){
const data = await getData(lang === 'fa' ? 1 : 2);
// Add safety checks for data structure
if (!data || typeof data !== 'object') {
console.error('Footer: Invalid data received from API');
return null;
}
return (
<div className="flex flex-col ">
<div className="h-14 bg-zinc-900 flex items-center wrapper w-full">
@@ -50,7 +57,7 @@ export default async function Footer({ lang }){
<div className='flex flex-col pr-'>
<div className='flex'>
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_205_1259)">
<g clipPath="url(#clip0_205_1259)">
<path d="M15.0726 31.9931C14.9787 31.9192 14.9173 31.8778 14.8642 31.8274C14.365 31.3594 13.7893 31.028 13.1376 30.8182C11.8833 30.4136 10.6097 30.0526 9.43958 29.4265C4.54034 26.8046 1.64442 22.7579 0.996899 17.2291C0.474323 12.7655 1.76316 8.78366 4.68876 5.3769C7.09592 2.57349 10.1589 0.82904 13.808 0.233289C18.603 -0.54885 22.9085 0.635058 26.6052 3.79468C29.546 6.30884 31.2856 9.53128 31.8406 13.3667C32.9265 20.8726 28.3628 28.0976 21.1178 30.3743C20.6166 30.5317 20.1175 30.698 19.6184 30.863C19.0192 31.0612 18.496 31.3863 18.0341 31.8143C17.9734 31.8702 17.9106 31.9234 17.8243 32C17.8015 31.913 17.778 31.8647 17.7787 31.8178C17.7987 30.8354 17.7594 29.8462 17.8574 28.8714C18.0079 27.3748 18.6837 26.0984 19.7889 25.0802C20.6829 24.2566 21.5983 23.4517 22.5482 22.6951C27.7159 18.5801 27.2003 10.5115 21.5382 7.09927C17.1146 4.43323 11.4367 5.5985 8.48486 9.77773C5.50058 14.0039 6.46704 19.7978 10.6242 22.9326C11.6797 23.7285 12.6634 24.6425 13.5739 25.6034C14.6205 26.708 15.063 28.11 15.103 29.6274C15.1216 30.326 15.1085 31.0253 15.1071 31.7239C15.1071 31.7977 15.0892 31.8709 15.0733 31.9931H15.0726Z" fill="#FAFAFA"/>
<path className="fill-red-400" d="M16.4351 22.6694C12.4326 22.6604 9.16181 19.4083 9.18321 15.4244C9.20461 11.3004 12.563 8.1339 16.5655 8.1767C20.4611 8.21812 23.7111 11.4965 23.7042 15.4382C23.6966 19.4242 20.4252 22.6791 16.4351 22.6694Z" fill="#FAFAFA"/>
</g>
@@ -60,13 +67,13 @@ export default async function Footer({ lang }){
</clipPath>
</defs>
</svg>
<span className='text-b-1 text-2xl pr-2 pb-2 font-[4]'>{ data.footerHead[0].body }</span>
<span className='text-b-1 text-2xl pr-2 pb-2 font-[4]'>{ data.footerHead?.[0]?.body || '' }</span>
</div>
<p className='text-n-1 font-[5] py-10 text-justify max-w-md'>
{ data.footerDesc[0].body }
{ data.footerDesc?.[0]?.body || '' }
</p>
<div className='flex'>
<span className='text-b-1 font-[4] pl-8'>{ data.footerFollow[0].body }</span>
<span className='text-b-1 font-[4] pl-8'>{ data.footerFollow?.[0]?.body || '' }</span>
<svg className='ml-4' width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.1401 2.96004L7.11012 5.96004C1.04012 7.99004 1.04012 11.3 7.11012 13.32L9.79012 14.21L10.6801 16.89C12.7001 22.96 16.0201 22.96 18.0401 16.89L21.0501 7.87004C22.3901 3.82004 20.1901 1.61004 16.1401 2.96004ZM16.4601 8.34004L12.6601 12.16C12.5101 12.31 12.3201 12.38 12.1301 12.38C11.9401 12.38 11.7501 12.31 11.6001 12.16C11.3101 11.87 11.3101 11.39 11.6001 11.1L15.4001 7.28004C15.6901 6.99004 16.1701 6.99004 16.4601 7.28004C16.7501 7.57004 16.7501 8.05004 16.4601 8.34004Z" fill="#FAFAFA"/>
</svg>
@@ -77,7 +84,7 @@ export default async function Footer({ lang }){
</div>
<div className='flex'>
<div className='flex flex-col pl-20'>
<span className='font-[4] text-lg pb-6 text-b-1'>{ data.footerService[0].body }</span>
<span className='font-[4] text-lg pb-6 text-b-1'>{ data.footerService?.[0]?.body || '' }</span>
<span className='font-[5] text-n-1'> لیست خدمات</span>
<span className='font-[5] text-n-1'> لیست خدمات</span>
<span className='font-[5] text-n-1'> لیست خدمات</span>
@@ -85,7 +92,7 @@ export default async function Footer({ lang }){
<span className='font-[5] text-n-1'> لیست خدمات</span>
</div>
<div className='flex flex-col'>
<span className='font-[4] text-lg pb-6 text-n-1'> { data.footerService[0].body }</span>
<span className='font-[4] text-lg pb-6 text-n-1'> { data.footerService?.[0]?.body || '' }</span>
<span className='font-[5] text-n-1'> لیست محصولات</span>
<span className='font-[5] text-n-1'> لیست محصولات</span>
<span className='font-[5] text-n-1'> لیست محصولات</span>
@@ -94,26 +101,26 @@ export default async function Footer({ lang }){
</div>
</div>
<div className='flex flex-col text-white'>
<span className=' font-[4] text-xl pb-6'>{ data.footerContact[0].body }</span>
<span className=' font-[4] text-xl pb-6'>{ data.footerContact?.[0]?.body || '' }</span>
<div className='flex items-center font-[5]'>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.75 15.375H5.25C3 15.375 1.5 14.25 1.5 11.625V6.375C1.5 3.75 3 2.625 5.25 2.625H12.75C15 2.625 16.5 3.75 16.5 6.375V11.625C16.5 14.25 15 15.375 12.75 15.375Z" stroke="#FAFAFA" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
<path opacity="0.4" d="M12.75 6.75L10.4025 8.625C9.63 9.24 8.3625 9.24 7.59 8.625L5.25 6.75" stroke="#FAFAFA" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span className='pr-4'> { data.footerEmail[0].body } </span>
<span className='pr-4'> { data.footerEmail?.[0]?.body || '' } </span>
</div>
<div className='flex items-center py-2 font-[5]'>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M16.4775 13.7475C16.4775 14.0175 16.4175 14.295 16.29 14.565C16.1625 14.835 15.9975 15.09 15.78 15.33C15.4125 15.735 15.0075 16.0275 14.55 16.215C14.1 16.4025 13.6125 16.5 13.0875 16.5C12.3225 16.5 11.505 16.32 10.6425 15.9525C9.78 15.585 8.9175 15.09 8.0625 14.4675C7.2 13.8375 6.3825 13.14 5.6025 12.3675C4.83 11.5875 4.1325 10.77 3.51 9.915C2.895 9.06 2.4 8.205 2.04 7.3575C1.68 6.5025 1.5 5.685 1.5 4.905C1.5 4.395 1.59 3.9075 1.77 3.4575C1.95 3 2.235 2.58 2.6325 2.205C3.1125 1.7325 3.6375 1.5 4.1925 1.5C4.4025 1.5 4.6125 1.545 4.8 1.635C4.995 1.725 5.1675 1.86 5.3025 2.055L7.0425 4.5075C7.1775 4.695 7.275 4.8675 7.3425 5.0325C7.41 5.19 7.4475 5.3475 7.4475 5.49C7.4475 5.67 7.395 5.85 7.29 6.0225C7.1925 6.195 7.05 6.375 6.87 6.555L6.3 7.1475C6.2175 7.23 6.18 7.3275 6.18 7.4475C6.18 7.5075 6.1875 7.56 6.2025 7.62C6.225 7.68 6.2475 7.725 6.2625 7.77C6.3975 8.0175 6.63 8.34 6.96 8.73C7.2975 9.12 7.6575 9.5175 8.0475 9.915C8.4525 10.3125 8.8425 10.68 9.24 11.0175C9.63 11.3475 9.9525 11.5725 10.2075 11.7075C10.245 11.7225 10.29 11.745 10.3425 11.7675C10.4025 11.79 10.4625 11.7975 10.53 11.7975C10.6575 11.7975 10.755 11.7525 10.8375 11.67L11.4075 11.1075C11.595 10.92 11.775 10.7775 11.9475 10.6875C12.12 10.5825 12.2925 10.53 12.48 10.53C12.6225 10.53 12.7725 10.56 12.9375 10.6275C13.1025 10.695 13.275 10.7925 13.4625 10.92L15.945 12.6825C16.14 12.8175 16.275 12.975 16.3575 13.1625C16.4325 13.35 16.4775 13.5375 16.4775 13.7475Z" stroke="#FAFAFA" stroke-width="1.5" stroke-miterlimit="10"/>
</svg>
<span className='pr-4'> { data.footerPhone[0].body } </span>
<span className='pr-4'> { data.footerPhone?.[0]?.body || '' } </span>
</div>
<div className='flex items-center font-[5]'>
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.4" d="M9.00016 10.0726C10.2925 10.0726 11.3402 9.02492 11.3402 7.73258C11.3402 6.44023 10.2925 5.39258 9.00016 5.39258C7.70781 5.39258 6.66016 6.44023 6.66016 7.73258C6.66016 9.02492 7.70781 10.0726 9.00016 10.0726Z" stroke="#FAFAFA" stroke-width="1.5"/>
<path d="M2.71478 6.3675C4.19228 -0.127498 13.8148 -0.119998 15.2848 6.375C16.1473 10.185 13.7773 13.41 11.6998 15.405C10.1923 16.86 7.80728 16.86 6.29228 15.405C4.22228 13.41 1.85228 10.1775 2.71478 6.3675Z" stroke="#FAFAFA" stroke-width="1.5"/>
</svg>
<span className='pr-4'>{ data.footerAddress[0].body }</span>
<span className='pr-4'>{ data.footerAddress?.[0]?.body || '' }</span>
</div>
</div>

View File

@@ -16,7 +16,7 @@ export default function Header(){
</button>
<Link href="/" className="justify-self-center">
<svg width="56" height="72" viewBox="0 0 56 72" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_213_1191)">
<g clipPath="url(#clip0_213_1191)">
<path d="M25.6219 57.416C25.4534 57.2834 25.3432 57.2091 25.2478 57.1187C24.3521 56.2787 23.3188 55.684 22.1493 55.3074C19.8983 54.5814 17.6125 53.9335 15.5126 52.8098C6.72028 48.1045 1.52317 40.8422 0.361095 30.92C-0.57674 22.9094 1.73625 15.7635 6.98664 9.64959C11.3066 4.61848 16.8036 1.48782 23.3523 0.418668C31.9576 -0.984987 39.6845 1.1397 46.3187 6.81007C51.5963 11.3221 54.7183 17.1052 55.7144 23.9884C57.6632 37.4588 49.4729 50.425 36.4708 54.5108C35.5714 54.7933 34.6757 55.0918 33.78 55.3879C32.7046 55.7435 31.7655 56.327 30.9367 57.0951C30.8277 57.1955 30.715 57.2909 30.5601 57.4284C30.5192 57.2723 30.4771 57.1856 30.4783 57.1013C30.5143 55.3384 30.4437 53.5631 30.6196 51.8138C30.8897 49.1279 32.1025 46.8372 34.086 45.0098C35.6903 43.5318 37.3331 42.0873 39.0378 40.7295C48.3121 33.3445 47.3866 18.8644 37.2253 12.7406C29.2865 7.95604 19.0967 10.0473 13.7993 17.5475C8.44357 25.1319 10.178 35.5299 17.6386 41.1556C19.5328 42.5841 21.2982 44.2244 22.9323 45.9489C24.8105 47.9311 25.6046 50.4473 25.6764 53.1703C25.7099 54.4241 25.6863 55.6791 25.6839 56.9328C25.6839 57.0654 25.6517 57.1967 25.6232 57.416H25.6219Z" fill="#18181B"/>
<path className="fill-red-700" d="M28.0664 40.6827C20.8834 40.6666 15.0135 34.8303 15.0519 27.6807C15.0904 20.2796 21.1175 14.5968 28.3006 14.6736C35.2916 14.748 41.1242 20.6314 41.1118 27.7054C41.0982 34.8587 35.2272 40.7001 28.0664 40.6827Z" fill="#18181B"/>
<path d="M14.2574 69.1917C14.5919 69.9586 14.9128 70.635 15.1742 71.3325C15.2473 71.527 15.3848 71.8776 14.9599 71.9569C14.3503 72.0709 14.1273 71.9681 14.0319 71.5406C13.7371 70.2126 12.8191 69.4655 11.4575 69.463C8.42352 69.4581 5.38825 69.4705 2.35423 69.4507C1.91195 69.4482 1.78682 69.5931 1.80788 70.0069C1.8339 70.5161 1.80788 71.029 1.81408 71.5394C1.81779 71.8169 1.73727 71.9594 1.42011 71.9681C0.624749 71.9916 0.624749 72.0052 0.624749 71.1987C0.624749 69.4804 0.635899 67.7621 0.617316 66.0437C0.61236 65.6176 0.749877 65.4924 1.17481 65.4937C5.138 65.5085 9.10119 65.5011 13.0644 65.5036C14.11 65.5036 14.8595 66.009 15.1407 66.8874C15.417 67.7472 15.1122 68.5438 14.2661 69.1831C14.2289 69.2103 14.1942 69.2413 14.2562 69.1905L14.2574 69.1917ZM7.70497 68.3196C8.40122 68.3196 9.09871 68.3196 9.79496 68.3196C10.8319 68.3196 11.8701 68.3196 12.907 68.3196C13.6751 68.3196 14.0555 68.0445 14.0629 67.4932C14.0703 66.937 13.6851 66.6471 12.9306 66.6433C12.7757 66.6433 12.6209 66.6433 12.466 66.6433C9.29197 66.6433 6.11796 66.6433 2.94518 66.6433C1.80169 66.6433 1.81779 66.6433 1.80788 67.772C1.80417 68.1944 1.93673 68.3332 2.36414 68.3282C4.14442 68.3084 5.92469 68.3196 7.70497 68.3196Z" fill="#18181B"/>

View File

@@ -71,6 +71,12 @@ export default async function Hero({lang}){
const data = await getData(lang === 'fa' ? 1 : 2);
// Add safety checks for data structure
if (!data || typeof data !== 'object') {
console.error('Hero: Invalid data received from API');
return null;
}
return (
<div className="flex flex-col w-full lg:py-8 items-center overflow-hidden">
<div className="relative flex justify-center pb-60 lg:pb-0">
@@ -79,11 +85,11 @@ export default async function Hero({lang}){
<p className="font-[5] max-w-sm text-justify text-zinc-600">اولین و تنها تولید کننده ی آلیاژهای منیزیم به صورت شمش و بیلت در سال ۱۳۹۶ در استان قم واقع در شهرک صنعتی شکوهیه شروع به فعالیت نمود.</p>
</div>*/}
<h1 className="col-span-2 text-3xl sm:text-4xl md:text-5xl lg:text-7xl font-[1] leading-normal w-full text-center pt-8">
{data.title1[0].body} <br/> {data.title2[0].body}
{data.title1?.[0]?.body || ''} <br/> {data.title2?.[0]?.body || ''}
</h1>
</div>
<div className="relative flex justify-center w-fit mb-[-15px] lg:mx-[290px]">
<MG lang={lang} props={data.mgprops}/>
<MG lang={lang} props={data.mgprops || []}/>
<div className="hidden lg:inline absolute bottom-32 right-[-140px]">
<svg width="234" height="191" viewBox="0 0 234 191" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.6311 176.663C13.4447 176.866 13.4588 177.183 13.6625 177.369C13.8663 177.555 14.1825 177.541 14.3689 177.337L13.6311 176.663ZM175 1L175 0.5L174.78 0.5L174.631 0.662518L175 1ZM233 1.5L233.5 1.5L233.5 0.500003L233 0.500003L233 1.5ZM14.3689 177.337L175.369 1.33748L174.631 0.662518L13.6311 176.663L14.3689 177.337ZM175 1.5L233 1.5L233 0.500003L175 0.5L175 1.5Z" fill="black"/>
@@ -93,12 +99,12 @@ export default async function Hero({lang}){
<Image alt="" src={bg} width={700} priority={true} />
<div className="absolute top-[-220px] left-[-100px] lg:top-0 lg:left-[-350px] flex flex-col items-center h-full justify-center pl-32 font-[5]">
<div className="flex flex-col items-center">
<span className="text-2xl lg:text-4xl font-[4] pb-2">{ data.stat1[0].body }</span>
<span className="text-zinc-700">{ data.statlabel1[0].body }</span>
<span className="text-2xl lg:text-4xl font-[4] pb-2">{ data.stat1?.[0]?.body || '' }</span>
<span className="text-zinc-700">{ data.statlabel1?.[0]?.body || '' }</span>
</div>
<div className="flex flex-col items-center pt-8">
<span className="text-2xl lg:text-4xl font-[4] pb-2">{ data.stat2[0].body }</span>
<span className="text-zinc-700">{ data.statlabel2[0].body }</span>
<span className="text-2xl lg:text-4xl font-[4] pb-2">{ data.stat2?.[0]?.body || '' }</span>
<span className="text-zinc-700">{ data.statlabel2?.[0]?.body || '' }</span>
</div>
</div>
</div>

View File

@@ -17,12 +17,18 @@ export default async function Production({ lang }){
const data = await getData(lang === 'fa' ? 1 : 2);
// Add safety checks for data structure
if (!data || typeof data !== 'object') {
console.error('Production: Invalid data received from API');
return null;
}
return(
<div className=" flex flex-col h-fit py-16">
<div className='flex flex-col lg:flex-row items-center justify-between font-[5] lg:mx-28 pb-12 lg:py-20 px-4'>
<div className='flex flex-col'>
<span className=''>{ data.equipmentSuper[0].body }</span>
<span className='font-[4] text-3xl lg:text-4xl pt-4'>{ data.equipmentHead[0].body }</span>
<span className=''>{ data.equipmentSuper?.[0]?.body || '' }</span>
<span className='font-[4] text-3xl lg:text-4xl pt-4'>{ data.equipmentHead?.[0]?.body || '' }</span>
</div>
<svg className='mt-6 mx-6' width="73" height="38" viewBox="0 0 73 38" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M36.5786 18.8969C36.5786 24.0903 35.206 28.7852 32.9948 32.1772C30.7827 35.5705 27.7441 37.6438 24.4097 37.6438C21.0753 37.6438 18.0367 35.5705 15.8246 32.1772C13.6134 28.7852 12.2408 24.0903 12.2408 18.8969C12.2408 13.7035 13.6134 9.00865 15.8246 5.6167C18.0367 2.22336 21.0753 0.15 24.4097 0.15C27.7441 0.15 30.7827 2.22336 32.9948 5.6167C35.206 9.00865 36.5786 13.7035 36.5786 18.8969Z" stroke="url(#paint0_linear_124_2450)" stroke-width="0.3"/>
@@ -54,37 +60,37 @@ export default async function Production({ lang }){
</defs>
</svg>
<p className='text-black-1 max-w-4xl '>
{ data.equipmentDesc[0].body }
{ data.equipmentDesc?.[0]?.body || '' }
</p>
</div>
<div className="grid grid-cols-1 lg:grid-cols-2 grid-rows-2 bg-zinc-100 font-[5]">
<div className="flex w-full">
<Image alt="" src={ data.equipment3Image[0].body } width={500} height={500} className="object-cover aspect-square w-1/2"/>
<Image alt="" src={ data.equipment3Image?.[0]?.body || '' } width={500} height={500} className="object-cover aspect-square w-1/2"/>
<div className="flex flex-col justify-center lg:p-10 sm:p-4 md:p-8 p-2 text-sm sm:text-base">
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title[0].body }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc[0].body }</p>
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title?.[0]?.body || '' }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc?.[0]?.body || '' }</p>
</div>
</div>
<div className="flex w-full flex-row-reverse lg:flex-row">
<Image alt="" src={ data.equipment3Image[1].body } width={500} height={500} className="object-cover aspect-square w-1/2"/>
<Image alt="" src={ data.equipment3Image?.[1]?.body || '' } width={500} height={500} className="object-cover aspect-square w-1/2"/>
<div className="flex flex-col justify-center lg:p-10 sm:p-4 md:p-8 p-2 text-sm sm:text-base">
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title[1].body }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc[1].body }</p>
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title?.[1]?.body || '' }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc?.[1]?.body || '' }</p>
</div>
</div>
<div className="flex w-full flex-row-reverse lg:flex-row">
<div className="flex flex-col justify-center lg:p-10 sm:p-4 md:p-8 p-2 text-sm sm:text-base">
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title[2].body }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc[2].body }</p>
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title?.[2]?.body || '' }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc?.[2]?.body || '' }</p>
</div>
<Image alt="" src={ data.equipment3Image[2].body } width={500} height={500} className="object-cover aspect-square w-1/2"/>
<Image alt="" src={ data.equipment3Image?.[2]?.body || '' } width={500} height={500} className="object-cover aspect-square w-1/2"/>
</div>
<div className="flex w-full">
<div className="flex flex-col justify-center lg:p-10 sm:p-4 md:p-8 p-2 text-sm sm:text-base">
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title[3].body }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc[3].body }</p>
<span classname="font-[4] text-black-1 text-2xl pb-8"> { data.equipment3Title?.[3]?.body || '' }</span>
<p classname="font-[5] text- text-black-1">{ data.equipment3Desc?.[3]?.body || '' }</p>
</div>
<Image alt="" src={ data.equipment3Image[3].body } width={500} height={500} className="object-cover aspect-square w-1/2"/>
<Image alt="" src={ data.equipment3Image?.[3]?.body || '' } width={500} height={500} className="object-cover aspect-square w-1/2"/>
</div>
</div>

View File

@@ -14,19 +14,26 @@ async function getData(id) {
export default async function Products({ lang }){
const data = await getData(lang === 'fa' ? 1 : 2);
// Add safety checks for data structure
if (!data || typeof data !== 'object') {
console.error('Products: Invalid data received from API');
return null;
}
return(
<div className="relative flex flex-col">
<Image alt="" src={productbg} className="absolute top-0 w-full object-cover h-[500px] md:h-96 lg:h-fit"/>
<div className="flex flex-col z-10 text-white font-[5] pt-8 lg:pt-16 w-full items-center ">
<span>{data.productsSuper[0].body}</span>
<span className="font-[4] text-3xl lg:text-4xl pt-4">{data.productsHead[0].body}</span>
<p className="max-w-4xl text-center pt-6 px-8 text-sm sm:text-md lg:pt-12">{data.productsDesc[0].body}</p>
<span>{data.productsSuper?.[0]?.body || ''}</span>
<span className="font-[4] text-3xl lg:text-4xl pt-4">{data.productsHead?.[0]?.body || ''}</span>
<p className="max-w-4xl text-center pt-6 px-8 text-sm sm:text-md lg:pt-12">{data.productsDesc?.[0]?.body || ''}</p>
</div>
<div className="flex justify-center z-10 py-16 overflow-x-scroll">
{
data.productImages.map((image, index) => (
<ProductCard key={index} image={image.body} desc={data.productDescs[index].body} />
))
data.productImages?.map((image, index) => (
<ProductCard key={index} image={image?.body || ''} desc={data.productDescs?.[index]?.body || ''} />
)) || []
}
</div>
</div>

37
package-lock.json generated
View File

@@ -129,6 +129,7 @@
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.0.tgz",
"integrity": "sha512-T1NCJqT/j9+cn8fvkt7jtwbLBfLC/1y1c7NtCeXFRgzGTsafi68MRv8yzkYSapBnFA6L3U2VSc02ciDzoAJhJg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
@@ -169,6 +170,7 @@
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
"license": "MIT",
"peer": true,
"bin": {
"json5": "lib/cli.js"
},
@@ -181,6 +183,7 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"license": "ISC",
"peer": true,
"bin": {
"semver": "bin/semver.js"
}
@@ -218,6 +221,7 @@
"resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.28.6.tgz",
"integrity": "sha512-JYtls3hqi15fcx5GaSNL7SCTJ2MNmjrkHXg4FSpOA/grxK8KwyZ5bubHsCq8FXCkua6xhuaaBit+3b7+VZRfcA==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/compat-data": "^7.28.6",
"@babel/helper-validator-option": "^7.27.1",
@@ -234,6 +238,7 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"license": "ISC",
"peer": true,
"bin": {
"semver": "bin/semver.js"
}
@@ -265,6 +270,7 @@
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.28.6.tgz",
"integrity": "sha512-67oXFAYr2cDLDVGLXTEABjdBJZ6drElUSI7WKp70NrpyISso3plG9SAGEF6y7zbha/wOzUByWWTJvEDVNIUGcA==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/helper-module-imports": "^7.28.6",
"@babel/helper-validator-identifier": "^7.28.5",
@@ -309,6 +315,7 @@
"resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz",
"integrity": "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
@@ -318,6 +325,7 @@
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.2.tgz",
"integrity": "sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/template": "^7.28.6",
"@babel/types": "^7.29.0"
@@ -446,7 +454,6 @@
"resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.4.0.tgz",
"integrity": "sha512-QgD4fyscGcbbKwJmqNvUMSE02OsHUa+lAWKdEUIJKgqe5IwRSKd7+KhibEWdaKwgjLj0DRSHA9biAIqGBk05lw==",
"license": "MIT",
"peer": true,
"dependencies": {
"@emotion/memoize": "^0.9.0"
}
@@ -1132,6 +1139,7 @@
"resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
"integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.5",
"@jridgewell/trace-mapping": "^0.3.24"
@@ -2583,7 +2591,6 @@
"resolved": "https://registry.npmjs.org/@nextui-org/theme/-/theme-2.4.5.tgz",
"integrity": "sha512-c7Y17n+hBGiFedxMKfg7Qyv93iY5MteamLXV4Po4c1VF1qZJI6I+IKULFh3FxPWzAoz96r6NdYT7OLFjrAJdWg==",
"license": "MIT",
"peer": true,
"dependencies": {
"@nextui-org/shared-utils": "2.1.2",
"clsx": "^1.2.1",
@@ -2849,7 +2856,8 @@
"version": "4.2.4",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.2.4.tgz",
"integrity": "sha512-HhKppgO81FQof5m6TEnuBWCZGgfRAWbaeOaGT00KOy/Pf/j6oUihdvBpA7ltCeAvZpFhW3j0PTclkxsd4IXYDA==",
"license": "MIT"
"license": "MIT",
"peer": true
},
"node_modules/@nextui-org/shared-icons": {
"version": "2.1.1",
@@ -2871,7 +2879,6 @@
"resolved": "https://registry.npmjs.org/@nextui-org/system/-/system-2.4.6.tgz",
"integrity": "sha512-6ujAriBZMfQ16n6M6Ad9g32KJUa1CzqIVaHN/tymadr/3m8hrr7xDw6z50pVjpCRq2PaaA1hT8Hx7EFU3f2z3Q==",
"license": "MIT",
"peer": true,
"dependencies": {
"@internationalized/date": "3.6.0",
"@nextui-org/react-utils": "2.1.3",
@@ -5690,7 +5697,6 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz",
"integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==",
"license": "MIT",
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -6251,7 +6257,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"baseline-browser-mapping": "^2.10.12",
"caniuse-lite": "^1.0.30001782",
@@ -6541,7 +6546,8 @@
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
"license": "MIT"
"license": "MIT",
"peer": true
},
"node_modules/core-js": {
"version": "3.49.0",
@@ -7054,7 +7060,6 @@
"integrity": "sha512-aaCpf2JqqKesMFGgmRPessmVKjcGXqdlAYLLC3THM8t5nBRZRQ+st5WM/hoJXkdioEXLLbXgclUpM0TXo5HX5Q==",
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
"license": "MIT",
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.4.0",
@@ -7217,7 +7222,6 @@
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz",
"integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==",
"license": "MIT",
"peer": true,
"dependencies": {
"@rtsao/scc": "^1.1.0",
"array-includes": "^3.1.9",
@@ -7674,7 +7678,6 @@
"resolved": "https://registry.npmjs.org/framer-motion/-/framer-motion-12.38.0.tgz",
"integrity": "sha512-rFYkY/pigbcswl1XQSb7q424kSTQ8q6eAC+YUsSKooHQYuLdzdHjrt6uxUC+PRAO++q5IS7+TamgIw1AphxR+g==",
"license": "MIT",
"peer": true,
"dependencies": {
"motion-dom": "^12.38.0",
"motion-utils": "^12.36.0",
@@ -7775,6 +7778,7 @@
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
"integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=6.9.0"
}
@@ -8077,7 +8081,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/runtime": "^7.23.2"
}
@@ -8822,6 +8825,7 @@
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
"license": "ISC",
"peer": true,
"dependencies": {
"yallist": "^3.0.2"
}
@@ -9558,7 +9562,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"nanoid": "^3.3.11",
"picocolors": "^1.1.1",
@@ -9792,7 +9795,6 @@
"integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"prettier": "bin/prettier.cjs"
},
@@ -9966,7 +9968,6 @@
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
"license": "MIT",
"peer": true,
"dependencies": {
"loose-envify": "^1.1.0"
},
@@ -10054,7 +10055,6 @@
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
"license": "MIT",
"peer": true,
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.2"
@@ -10068,7 +10068,6 @@
"resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-13.5.0.tgz",
"integrity": "sha512-CFJ5NDGJ2MUyBohEHxljOq/39NQ972rh1ajnadG9BjTk+UXbHLq4z5DKEbEQBDoIhUmmbuS/fIMJKo6VOax1HA==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/runtime": "^7.22.5",
"html-parse-stringify": "^3.0.1"
@@ -10898,7 +10897,6 @@
"resolved": "https://registry.npmjs.org/styled-components/-/styled-components-5.3.11.tgz",
"integrity": "sha512-uuzIIfnVkagcVHv9nE0VPlHPSCmXIUGKfJ42LNjxCCTDTL5sgnJ8Z7GZBq0EnLYGln77tPpEpExt2+qa+cZqSw==",
"license": "MIT",
"peer": true,
"dependencies": {
"@babel/helper-module-imports": "^7.0.0",
"@babel/traverse": "^7.4.5",
@@ -11083,7 +11081,6 @@
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.2.tgz",
"integrity": "sha512-9jPkMiIBXvPc2KywkraqsUfbfj+dHDb+JPWtSJa9MLFdrPyazI7q6WX2sUrm7R9eVR7qqv3Pas7EvQFzxKnI6w==",
"license": "MIT",
"peer": true,
"dependencies": {
"@alloc/quick-lru": "^5.2.0",
"arg": "^5.0.2",
@@ -11275,7 +11272,6 @@
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
"integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==",
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@@ -11734,7 +11730,8 @@
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==",
"license": "ISC"
"license": "ISC",
"peer": true
},
"node_modules/yaml": {
"version": "2.8.3",