Trying to upgrade to Nextjs v15

This commit is contained in:
2024-10-23 10:02:02 +05:30
parent 543533d6e0
commit c0a53993ee
5 changed files with 85 additions and 78 deletions
+66 -66
View File
@@ -15,7 +15,7 @@
"@medusajs/product": "^0.3.13-preview-20241001060739", "@medusajs/product": "^0.3.13-preview-20241001060739",
"@mikro-orm/core": "^5.9.7", "@mikro-orm/core": "^5.9.7",
"@mikro-orm/postgresql": "^5.9.7", "@mikro-orm/postgresql": "^5.9.7",
"@next/third-parties": "^14.2.15", "@next/third-parties": "14.2.16",
"@radix-ui/react-checkbox": "^1.1.2", "@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0", "@radix-ui/react-label": "^2.1.0",
@@ -30,9 +30,9 @@
"clsx": "^2.1.1", "clsx": "^2.1.1",
"lucide-react": "^0.447.0", "lucide-react": "^0.447.0",
"medusa-react": "^9.0.18", "medusa-react": "^9.0.18",
"next": "14.2.13", "next": "14.2.16",
"react": "^18", "react": "18.3.1",
"react-dom": "^18", "react-dom": "18.3.1",
"react-icons": "^5.3.0", "react-icons": "^5.3.0",
"sharp": "^0.33.5", "sharp": "^0.33.5",
"swiper": "^11.1.14", "swiper": "^11.1.14",
@@ -42,12 +42,12 @@
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20", "@types/node": "^20",
"@types/react": "^18", "@types/react": "18.3.12",
"@types/react-dom": "^18", "@types/react-dom": "18.3.1",
"@typescript-eslint/eslint-plugin": "^8.8.1", "@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1", "@typescript-eslint/parser": "^8.8.1",
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "14.2.13", "eslint-config-next": "14.2.16",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
@@ -3260,14 +3260,14 @@
] ]
}, },
"node_modules/@next/env": { "node_modules/@next/env": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/env/-/env-14.2.16.tgz",
"integrity": "sha512-s3lh6K8cbW1h5Nga7NNeXrbe0+2jIIYK9YaA9T7IufDWnZpozdFUp6Hf0d5rNWUKu4fEuSX2rCKlGjCrtylfDw==" "integrity": "sha512-fLrX5TfJzHCbnZ9YUSnGW63tMV3L4nSfhgOQ0iCcX21Pt+VSTDuaLsSuL8J/2XAiVA5AnzvXDpf6pMs60QxOag=="
}, },
"node_modules/@next/eslint-plugin-next": { "node_modules/@next/eslint-plugin-next": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-14.2.16.tgz",
"integrity": "sha512-z8Mk0VljxhIzsSiZUSdt3wp+t2lKd+jk5a9Jsvh3zDGkItgDMfjv/ZbET6HsxEl/fSihVoHGsXV6VLyDH0lfTQ==", "integrity": "sha512-noORwKUMkKc96MWjTOwrsUCjky0oFegHbeJ1yEnQBGbMHAaTEIgLZIIfsYF0x3a06PiS+2TXppfifR+O6VWslg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"glob": "10.3.10" "glob": "10.3.10"
@@ -3320,9 +3320,9 @@
} }
}, },
"node_modules/@next/swc-darwin-arm64": { "node_modules/@next/swc-darwin-arm64": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.2.16.tgz",
"integrity": "sha512-IkAmQEa2Htq+wHACBxOsslt+jMoV3msvxCn0WFSfJSkv/scy+i/EukBKNad36grRxywaXUYJc9mxEGkeIs8Bzg==", "integrity": "sha512-uFT34QojYkf0+nn6MEZ4gIWQ5aqGF11uIZ1HSxG+cSbj+Mg3+tYm8qXYd3dKN5jqKUm5rBVvf1PBRO/MeQ6rxw==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -3335,9 +3335,9 @@
} }
}, },
"node_modules/@next/swc-darwin-x64": { "node_modules/@next/swc-darwin-x64": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.2.16.tgz",
"integrity": "sha512-Dv1RBGs2TTjkwEnFMVL5XIfJEavnLqqwYSD6LXgTPdEy/u6FlSrLBSSfe1pcfqhFEXRAgVL3Wpjibe5wXJzWog==", "integrity": "sha512-mCecsFkYezem0QiZlg2bau3Xul77VxUD38b/auAjohMA22G9KTJneUYMv78vWoCCFkleFAhY1NIvbyjj1ncG9g==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -3350,9 +3350,9 @@
} }
}, },
"node_modules/@next/swc-linux-arm64-gnu": { "node_modules/@next/swc-linux-arm64-gnu": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.2.16.tgz",
"integrity": "sha512-yB1tYEFFqo4ZNWkwrJultbsw7NPAAxlPXURXioRl9SdW6aIefOLS+0TEsKrWBtbJ9moTDgU3HRILL6QBQnMevg==", "integrity": "sha512-yhkNA36+ECTC91KSyZcgWgKrYIyDnXZj8PqtJ+c2pMvj45xf7y/HrgI17hLdrcYamLfVt7pBaJUMxADtPaczHA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -3365,9 +3365,9 @@
} }
}, },
"node_modules/@next/swc-linux-arm64-musl": { "node_modules/@next/swc-linux-arm64-musl": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.2.16.tgz",
"integrity": "sha512-v5jZ/FV/eHGoWhMKYrsAweQ7CWb8xsWGM/8m1mwwZQ/sutJjoFaXchwK4pX8NqwImILEvQmZWyb8pPTcP7htWg==", "integrity": "sha512-X2YSyu5RMys8R2lA0yLMCOCtqFOoLxrq2YbazFvcPOE4i/isubYjkh+JCpRmqYfEuCVltvlo+oGfj/b5T2pKUA==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -3380,9 +3380,9 @@
} }
}, },
"node_modules/@next/swc-linux-x64-gnu": { "node_modules/@next/swc-linux-x64-gnu": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.2.16.tgz",
"integrity": "sha512-aVc7m4YL7ViiRv7SOXK3RplXzOEe/qQzRA5R2vpXboHABs3w8vtFslGTz+5tKiQzWUmTmBNVW0UQdhkKRORmGA==", "integrity": "sha512-9AGcX7VAkGbc5zTSa+bjQ757tkjr6C/pKS7OK8cX7QEiK6MHIIezBLcQ7gQqbDW2k5yaqba2aDtaBeyyZh1i6Q==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -3395,9 +3395,9 @@
} }
}, },
"node_modules/@next/swc-linux-x64-musl": { "node_modules/@next/swc-linux-x64-musl": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.2.16.tgz",
"integrity": "sha512-4wWY7/OsSaJOOKvMsu1Teylku7vKyTuocvDLTZQq0TYv9OjiYYWt63PiE1nTuZnqQ4RPvME7Xai+9enoiN0Wrg==", "integrity": "sha512-Klgeagrdun4WWDaOizdbtIIm8khUDQJ/5cRzdpXHfkbY91LxBXeejL4kbZBrpR/nmgRrQvmz4l3OtttNVkz2Sg==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -3410,9 +3410,9 @@
} }
}, },
"node_modules/@next/swc-win32-arm64-msvc": { "node_modules/@next/swc-win32-arm64-msvc": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.2.16.tgz",
"integrity": "sha512-uP1XkqCqV2NVH9+g2sC7qIw+w2tRbcMiXFEbMihkQ8B1+V6m28sshBwAB0SDmOe0u44ne1vFU66+gx/28RsBVQ==", "integrity": "sha512-PwW8A1UC1Y0xIm83G3yFGPiOBftJK4zukTmk7DI1CebyMOoaVpd8aSy7K6GhobzhkjYvqS/QmzcfsWG2Dwizdg==",
"cpu": [ "cpu": [
"arm64" "arm64"
], ],
@@ -3425,9 +3425,9 @@
} }
}, },
"node_modules/@next/swc-win32-ia32-msvc": { "node_modules/@next/swc-win32-ia32-msvc": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.2.16.tgz",
"integrity": "sha512-V26ezyjPqQpDBV4lcWIh8B/QICQ4v+M5Bo9ykLN+sqeKKBxJVDpEc6biDVyluTXTC40f5IqCU0ttth7Es2ZuMw==", "integrity": "sha512-jhPl3nN0oKEshJBNDAo0etGMzv0j3q3VYorTSFqH1o3rwv1MQRdor27u1zhkgsHPNeY1jxcgyx1ZsCkDD1IHgg==",
"cpu": [ "cpu": [
"ia32" "ia32"
], ],
@@ -3440,9 +3440,9 @@
} }
}, },
"node_modules/@next/swc-win32-x64-msvc": { "node_modules/@next/swc-win32-x64-msvc": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.13.tgz", "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.2.16.tgz",
"integrity": "sha512-WwzOEAFBGhlDHE5Z73mNU8CO8mqMNLqaG+AO9ETmzdCQlJhVtWZnOl2+rqgVQS+YHunjOWptdFmNfbpwcUuEsw==", "integrity": "sha512-OA7NtfxgirCjfqt+02BqxC3MIgM/JaGjw9tOe4fyZgPsqfseNiMPnCRP44Pfs+Gpo9zPN+SXaFsgP6vk8d571A==",
"cpu": [ "cpu": [
"x64" "x64"
], ],
@@ -3455,9 +3455,9 @@
} }
}, },
"node_modules/@next/third-parties": { "node_modules/@next/third-parties": {
"version": "14.2.15", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/@next/third-parties/-/third-parties-14.2.15.tgz", "resolved": "https://registry.npmjs.org/@next/third-parties/-/third-parties-14.2.16.tgz",
"integrity": "sha512-15CvipE1p1GtlzVfbDfXPrAGIhzJJe75Yy6+GIBRTd36lu95BegRsUJwCxJYoKz47Q09stcU2gJDMduMGqrikw==", "integrity": "sha512-owdCT5BbGyfdDXkmZ1kjPMRPJ8+WLLJFTJSjMRQOYwq5j5o0L3U47sHi07J0mhgJgX6RmRyLd0OFPHCVfAY3Kw==",
"dependencies": { "dependencies": {
"third-party-capital": "1.0.20" "third-party-capital": "1.0.20"
}, },
@@ -4815,9 +4815,9 @@
"devOptional": true "devOptional": true
}, },
"node_modules/@types/react": { "node_modules/@types/react": {
"version": "18.3.10", "version": "18.3.12",
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.10.tgz", "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.12.tgz",
"integrity": "sha512-02sAAlBnP39JgXwkAq3PeU9DVaaGpZyF3MGcC0MKgQVkZor5IiiDAipVaxQHtDJAmO4GIy/rVBy/LzVj76Cyqg==", "integrity": "sha512-D2wOSq/d6Agt28q7rSI3jhU7G6aiuzljDGZ2hTZHIkrTLUI+AF3WMeKkEZ9nN2fkBAlcktT6vcZjDFiIhMYEQw==",
"devOptional": true, "devOptional": true,
"dependencies": { "dependencies": {
"@types/prop-types": "*", "@types/prop-types": "*",
@@ -4825,9 +4825,9 @@
} }
}, },
"node_modules/@types/react-dom": { "node_modules/@types/react-dom": {
"version": "18.3.0", "version": "18.3.1",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.0.tgz", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.1.tgz",
"integrity": "sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg==", "integrity": "sha512-qW1Mfv8taImTthu4KoXgDfLuk4bydU6Q/TkADnDWWHwi4NX4BR+LWfTp2sVmTqRrsHvyDDTelgelxJ+SsejKKQ==",
"devOptional": true, "devOptional": true,
"dependencies": { "dependencies": {
"@types/react": "*" "@types/react": "*"
@@ -7465,12 +7465,12 @@
} }
}, },
"node_modules/eslint-config-next": { "node_modules/eslint-config-next": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-14.2.13.tgz", "resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-14.2.16.tgz",
"integrity": "sha512-aro1EKAoyYchnO/3Tlo91hnNBO7QO7qnv/79MAFC+4Jq8TdUVKQlht5d2F+YjrePjdpOvfL+mV9JPfyYNwkk1g==", "integrity": "sha512-HOcnCJsyLXR7B8wmjaCgkTSpz+ijgOyAkP8OlvANvciP8PspBYFEBTmakNMxOf71fY0aKOm/blFIiKnrM4K03Q==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@next/eslint-plugin-next": "14.2.13", "@next/eslint-plugin-next": "14.2.16",
"@rushstack/eslint-patch": "^1.3.3", "@rushstack/eslint-patch": "^1.3.3",
"@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", "@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0", "@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
@@ -10585,11 +10585,11 @@
} }
}, },
"node_modules/next": { "node_modules/next": {
"version": "14.2.13", "version": "14.2.16",
"resolved": "https://registry.npmjs.org/next/-/next-14.2.13.tgz", "resolved": "https://registry.npmjs.org/next/-/next-14.2.16.tgz",
"integrity": "sha512-BseY9YNw8QJSwLYD7hlZzl6QVDoSFHL/URN5K64kVEVpCsSOWeyjbIGK+dZUaRViHTaMQX8aqmnn0PHBbGZezg==", "integrity": "sha512-LcO7WnFu6lYSvCzZoo1dB+IO0xXz5uEv52HF1IUN0IqVTUIZGHuuR10I5efiLadGt+4oZqTcNZyVVEem/TM5nA==",
"dependencies": { "dependencies": {
"@next/env": "14.2.13", "@next/env": "14.2.16",
"@swc/helpers": "0.5.5", "@swc/helpers": "0.5.5",
"busboy": "1.6.0", "busboy": "1.6.0",
"caniuse-lite": "^1.0.30001579", "caniuse-lite": "^1.0.30001579",
@@ -10604,15 +10604,15 @@
"node": ">=18.17.0" "node": ">=18.17.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"@next/swc-darwin-arm64": "14.2.13", "@next/swc-darwin-arm64": "14.2.16",
"@next/swc-darwin-x64": "14.2.13", "@next/swc-darwin-x64": "14.2.16",
"@next/swc-linux-arm64-gnu": "14.2.13", "@next/swc-linux-arm64-gnu": "14.2.16",
"@next/swc-linux-arm64-musl": "14.2.13", "@next/swc-linux-arm64-musl": "14.2.16",
"@next/swc-linux-x64-gnu": "14.2.13", "@next/swc-linux-x64-gnu": "14.2.16",
"@next/swc-linux-x64-musl": "14.2.13", "@next/swc-linux-x64-musl": "14.2.16",
"@next/swc-win32-arm64-msvc": "14.2.13", "@next/swc-win32-arm64-msvc": "14.2.16",
"@next/swc-win32-ia32-msvc": "14.2.13", "@next/swc-win32-ia32-msvc": "14.2.16",
"@next/swc-win32-x64-msvc": "14.2.13" "@next/swc-win32-x64-msvc": "14.2.16"
}, },
"peerDependencies": { "peerDependencies": {
"@opentelemetry/api": "^1.1.0", "@opentelemetry/api": "^1.1.0",
+11 -7
View File
@@ -16,7 +16,7 @@
"@medusajs/product": "^0.3.13-preview-20241001060739", "@medusajs/product": "^0.3.13-preview-20241001060739",
"@mikro-orm/core": "^5.9.7", "@mikro-orm/core": "^5.9.7",
"@mikro-orm/postgresql": "^5.9.7", "@mikro-orm/postgresql": "^5.9.7",
"@next/third-parties": "^14.2.15", "@next/third-parties": "14.2.16",
"@radix-ui/react-checkbox": "^1.1.2", "@radix-ui/react-checkbox": "^1.1.2",
"@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0", "@radix-ui/react-label": "^2.1.0",
@@ -31,9 +31,9 @@
"clsx": "^2.1.1", "clsx": "^2.1.1",
"lucide-react": "^0.447.0", "lucide-react": "^0.447.0",
"medusa-react": "^9.0.18", "medusa-react": "^9.0.18",
"next": "14.2.13", "next": "14.2.16",
"react": "^18", "react": "18.3.1",
"react-dom": "^18", "react-dom": "18.3.1",
"react-icons": "^5.3.0", "react-icons": "^5.3.0",
"sharp": "^0.33.5", "sharp": "^0.33.5",
"swiper": "^11.1.14", "swiper": "^11.1.14",
@@ -43,12 +43,12 @@
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20", "@types/node": "^20",
"@types/react": "^18", "@types/react": "18.3.12",
"@types/react-dom": "^18", "@types/react-dom": "18.3.1",
"@typescript-eslint/eslint-plugin": "^8.8.1", "@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1", "@typescript-eslint/parser": "^8.8.1",
"eslint": "^8", "eslint": "^8",
"eslint-config-next": "14.2.13", "eslint-config-next": "14.2.16",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
@@ -56,5 +56,9 @@
"prettier": "^3.3.3", "prettier": "^3.3.3",
"tailwindcss": "^3.4.1", "tailwindcss": "^3.4.1",
"typescript": "^5" "typescript": "^5"
},
"overrides": {
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1"
} }
} }
+4 -4
View File
@@ -28,7 +28,7 @@ export default function MyCartComponent() {
<h3 className='font-semibold'> <h3 className='font-semibold'>
{item.product_title} ({item.variant_title}) {item.product_title} ({item.variant_title})
</h3> </h3>
<p className='text-sm text-gray-600'>${item.unit_price}</p> <p className='text-sm text-gray-600'>{item.unit_price}</p>
</div> </div>
<div className='flex items-center'> <div className='flex items-center'>
<Button variant='outline' size='icon' onClick={() => updateQuantity(item.id, item.quantity - 1)}> <Button variant='outline' size='icon' onClick={() => updateQuantity(item.id, item.quantity - 1)}>
@@ -56,18 +56,18 @@ export default function MyCartComponent() {
<div className='space-y-1'> <div className='space-y-1'>
<div className='flex justify-between'> <div className='flex justify-between'>
<span>Subtotal</span> <span>Subtotal</span>
<span>${cart?.subtotal}</span> <span>{cart?.subtotal?.toFixed(2)}</span>
</div> </div>
<div className='flex justify-between'> <div className='flex justify-between'>
<span>Tax</span> <span>Tax</span>
<span>${cart?.tax_total}</span> <span>{cart?.tax_total?.toFixed(2)}</span>
</div> </div>
</div> </div>
</CardContent> </CardContent>
<Separator /> <Separator />
<CardFooter className='justify-between'> <CardFooter className='justify-between'>
<span className='font-semibold'>Total</span> <span className='font-semibold'>Total</span>
<span className='font-semibold'>${cart?.total}</span> <span className='font-semibold'>{cart?.total?.toFixed(2)}</span>
</CardFooter> </CardFooter>
</Card> </Card>
<Button className='w-full mt-4' size='lg'> <Button className='w-full mt-4' size='lg'>
@@ -21,6 +21,7 @@ async function fetchProduct(handle: string, region: HttpTypes.StoreRegion | unde
handle: handle, handle: handle,
fields: `*variants.calculated_price`, fields: `*variants.calculated_price`,
region_id: region?.id || (process.env.NEXT_PUBLIC_DEFAULT_REGION_ID as string), region_id: region?.id || (process.env.NEXT_PUBLIC_DEFAULT_REGION_ID as string),
country_code: 'in',
}); });
const response = await fetch( const response = await fetch(
// const products: HttpTypes.StoreProduct[] = await fetch( // const products: HttpTypes.StoreProduct[] = await fetch(
+3 -1
View File
@@ -7,6 +7,7 @@ async function fetchProducts() {
const params = new URLSearchParams({ const params = new URLSearchParams({
fields: `*variants.prices.*`, fields: `*variants.prices.*`,
region_id: process.env.NEXT_PUBLIC_DEFAULT_REGION_ID as string, region_id: process.env.NEXT_PUBLIC_DEFAULT_REGION_ID as string,
country_code: 'in',
}); });
const response = await fetch(`${process.env.NEXT_PRIVATE_BASE_URL}/store/products?${params}`, { const response = await fetch(`${process.env.NEXT_PRIVATE_BASE_URL}/store/products?${params}`, {
@@ -24,6 +25,7 @@ async function fetchProducts() {
} }
const data = await response.json(); const data = await response.json();
console.log(JSON.stringify(data.products));
return data.products; return data.products;
} }
@@ -50,7 +52,7 @@ export default async function ProductsPage() {
<img <img
src={product.images?.[0].url as string} src={product.images?.[0].url as string}
alt={product.title as string} alt={product.title as string}
className='w-full h-auto flex-grow group-hover:opacity-80 transition-opacity duration-1000 group-hover:rounded-lg group-hover:shadow-lg' className='w-full h-auto flex-grow group-hover:opacity-80 transition-opacity duration-1000 group-hover:rounded-lg'
/> />
<button className='bg-black text-white px-4 py-2 rounded hover:bg-gray-800 transition-colors duration-300 absolute bottom-4 left-1/2 transform -translate-x-1/2 opacity-0 group-hover:opacity-100'> <button className='bg-black text-white px-4 py-2 rounded hover:bg-gray-800 transition-colors duration-300 absolute bottom-4 left-1/2 transform -translate-x-1/2 opacity-0 group-hover:opacity-100'>
Add to Cart Add to Cart