diff --git a/.env b/.env index 7b4a416..989a3af 100644 --- a/.env +++ b/.env @@ -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 diff --git a/components/About.js b/components/About.js index 2230046..bba7d83 100755 --- a/components/About.js +++ b/components/About.js @@ -18,14 +18,20 @@ async function getData(id) { 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(
- { data.aboutSuper[0].body } - { data.aboutHead[0].body } + { data.aboutSuper?.[0]?.body || '' } + { data.aboutHead?.[0]?.body || '' }
@@ -53,16 +59,16 @@ export default async function About({lang}) {
- { data.about1Head[0].body } -

{ data.about1Desc[0].body } + { data.about1Head?.[0]?.body || '' } +

{ data.about1Desc?.[0]?.body || '' }

- +
- { data.about2Head[0].body } -

{ data.about2Desc[0].body } + { data.about2Head?.[0]?.body || '' } +

{ data.about2Desc?.[0]?.body || '' }

بیشتر بدانید @@ -73,8 +79,8 @@ export default async function About({lang}) {
- + ) -} \ No newline at end of file +} diff --git a/components/Footer.js b/components/Footer.js index 5940487..8cc075e 100755 --- a/components/Footer.js +++ b/components/Footer.js @@ -33,7 +33,14 @@ async function getData(id) { export default async function Footer({ lang }){ - const data = await getData(lang === 'fa' ? 1 : 2); + 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 (
@@ -50,7 +57,7 @@ export default async function Footer({ lang }){
- + @@ -60,13 +67,13 @@ export default async function Footer({ lang }){ - { data.footerHead[0].body } + { data.footerHead?.[0]?.body || '' }

- { data.footerDesc[0].body } + { data.footerDesc?.[0]?.body || '' }

- { data.footerFollow[0].body } + { data.footerFollow?.[0]?.body || '' } @@ -77,7 +84,7 @@ export default async function Footer({ lang }){
- { data.footerService[0].body } + { data.footerService?.[0]?.body || '' } لیست خدمات لیست خدمات لیست خدمات @@ -85,7 +92,7 @@ export default async function Footer({ lang }){ لیست خدمات
- { data.footerService[0].body } + { data.footerService?.[0]?.body || '' } لیست محصولات لیست محصولات لیست محصولات @@ -94,26 +101,26 @@ export default async function Footer({ lang }){
- { data.footerContact[0].body } + { data.footerContact?.[0]?.body || '' }
- { data.footerEmail[0].body } + { data.footerEmail?.[0]?.body || '' }
- { data.footerPhone[0].body } + { data.footerPhone?.[0]?.body || '' }
- { data.footerAddress[0].body } + { data.footerAddress?.[0]?.body || '' }
@@ -121,4 +128,4 @@ export default async function Footer({ lang }){
) -} \ No newline at end of file +} diff --git a/components/Header.js b/components/Header.js index b9ef5bc..7ae231d 100755 --- a/components/Header.js +++ b/components/Header.js @@ -16,7 +16,7 @@ export default function Header(){ - + diff --git a/components/Hero.js b/components/Hero.js index 945883d..d2b3c18 100755 --- a/components/Hero.js +++ b/components/Hero.js @@ -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 (
@@ -79,11 +85,11 @@ export default async function Hero({lang}){

اولین و تنها تولید کننده ی آلیاژهای منیزیم به صورت شمش و بیلت در سال ۱۳۹۶ در استان قم واقع در شهرک صنعتی شکوهیه شروع به فعالیت نمود.

*/}

- {data.title1[0].body}
{data.title2[0].body} + {data.title1?.[0]?.body || ''}
{data.title2?.[0]?.body || ''}

- +
@@ -93,12 +99,12 @@ export default async function Hero({lang}){
- { data.stat1[0].body } - { data.statlabel1[0].body } + { data.stat1?.[0]?.body || '' } + { data.statlabel1?.[0]?.body || '' }
- { data.stat2[0].body } - { data.statlabel2[0].body } + { data.stat2?.[0]?.body || '' } + { data.statlabel2?.[0]?.body || '' }
@@ -114,4 +120,4 @@ export default async function Hero({lang}){
) -} \ No newline at end of file +} diff --git a/components/Production.js b/components/Production.js index a19cf6c..e9beb70 100755 --- a/components/Production.js +++ b/components/Production.js @@ -16,13 +16,19 @@ async function getData(id) { 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(
- { data.equipmentSuper[0].body } - { data.equipmentHead[0].body } + { data.equipmentSuper?.[0]?.body || '' } + { data.equipmentHead?.[0]?.body || '' }
@@ -54,40 +60,40 @@ export default async function Production({ lang }){

- { data.equipmentDesc[0].body } + { data.equipmentDesc?.[0]?.body || '' }

- +
- { data.equipment3Title[0].body } -

{ data.equipment3Desc[0].body }

+ { data.equipment3Title?.[0]?.body || '' } +

{ data.equipment3Desc?.[0]?.body || '' }

- +
- { data.equipment3Title[1].body } -

{ data.equipment3Desc[1].body }

+ { data.equipment3Title?.[1]?.body || '' } +

{ data.equipment3Desc?.[1]?.body || '' }

- { data.equipment3Title[2].body } -

{ data.equipment3Desc[2].body }

+ { data.equipment3Title?.[2]?.body || '' } +

{ data.equipment3Desc?.[2]?.body || '' }

- +
- { data.equipment3Title[3].body } -

{ data.equipment3Desc[3].body }

+ { data.equipment3Title?.[3]?.body || '' } +

{ data.equipment3Desc?.[3]?.body || '' }

- +
) -} \ No newline at end of file +} diff --git a/components/Products.js b/components/Products.js index 34163c4..c240c53 100755 --- a/components/Products.js +++ b/components/Products.js @@ -14,21 +14,28 @@ 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(
- {data.productsSuper[0].body} - {data.productsHead[0].body} -

{data.productsDesc[0].body}

+ {data.productsSuper?.[0]?.body || ''} + {data.productsHead?.[0]?.body || ''} +

{data.productsDesc?.[0]?.body || ''}

{ - data.productImages.map((image, index) => ( - - )) + data.productImages?.map((image, index) => ( + + )) || [] }
) -} \ No newline at end of file +} diff --git a/package-lock.json b/package-lock.json index 4bc152a..c279e24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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",