From edd8ae946f6dda60a66b0a2d0d02e4211e3c6f23 Mon Sep 17 00:00:00 2001
From: goncy
Date: Tue, 22 Aug 2023 10:04:20 -0300
Subject: [PATCH] Add details page
---
.eslintrc.cjs | 1 +
.vscode/settings.json | 4 +-
next-env.d.ts | 1 -
package.json | 6 +-
pnpm-lock.yaml | 194 +++++++++---------
src/app/[product]/client.tsx | 20 ++
src/app/[product]/page.tsx | 11 +
src/app/_components/providers.tsx | 11 -
src/app/layout.tsx | 14 +-
src/app/mocks/[mock]/page.tsx | 11 +-
src/app/page.tsx | 7 +-
.../cart/components/CartDrawer/CartDrawer.tsx | 2 +-
.../CartDrawer/__tests__/CartDrawer.test.tsx | 2 +-
.../cart/{context.tsx => context/client.tsx} | 8 +-
src/modules/cart/context/index.tsx | 11 +
src/modules/product/api.ts | 13 +-
.../product/components/ProductCard.tsx | 2 +
src/modules/store/screens/Store.tsx | 2 +-
.../theme/components/ThemeToggle.tsx} | 2 +-
src/modules/theme/context.tsx | 11 +
src/pages/api/revalidate.ts | 11 -
21 files changed, 192 insertions(+), 152 deletions(-)
create mode 100644 src/app/[product]/client.tsx
create mode 100644 src/app/[product]/page.tsx
delete mode 100644 src/app/_components/providers.tsx
rename src/modules/cart/{context.tsx => context/client.tsx} (89%)
create mode 100644 src/modules/cart/context/index.tsx
rename src/{app/_components/theme-toggle.tsx => modules/theme/components/ThemeToggle.tsx} (93%)
create mode 100644 src/modules/theme/context.tsx
delete mode 100644 src/pages/api/revalidate.ts
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index cd34df9..75fee20 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -38,6 +38,7 @@ module.exports = {
plugins: ["prettier-plugin-tailwindcss"],
},
],
+ "@typescript-eslint/no-shadow": "off",
"import/order": [
"warn",
{
diff --git a/.vscode/settings.json b/.vscode/settings.json
index ee46df0..8b78742 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,6 +3,6 @@
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
- "typescript.tsdk": "node_modules\\.pnpm\\typescript@4.9.5\\node_modules\\typescript\\lib",
+ "typescript.tsdk": "node_modules\\typescript\\lib",
"typescript.enablePromptUseWorkspaceTsdk": true
-}
\ No newline at end of file
+}
diff --git a/next-env.d.ts b/next-env.d.ts
index fd36f94..4f11a03 100644
--- a/next-env.d.ts
+++ b/next-env.d.ts
@@ -1,6 +1,5 @@
///
///
-///
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/package.json b/package.json
index 0ac60d7..bb6b477 100644
--- a/package.json
+++ b/package.json
@@ -38,8 +38,8 @@
"@types/jest": "^29.4.0",
"@types/node": "^18.13.0",
"@types/papaparse": "^5.3.7",
- "@types/react": "^18.0.27",
- "@types/react-dom": "^18.0.10",
+ "@types/react": "^18.2.20",
+ "@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@vercel/style-guide": "^4.0.2",
@@ -60,7 +60,7 @@
"tailwindcss": "^3.3.2",
"ts-jest": "^29.0.5",
"ts-standard": "^12.0.2",
- "typescript": "^4.9.5",
+ "typescript": "^5.1.6",
"wait-on": "^7.0.1"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 34171ca..dea3c23 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1,9 +1,13 @@
lockfileVersion: '6.0'
+settings:
+ autoInstallPeers: true
+ excludeLinksFromLockfile: false
+
dependencies:
'@radix-ui/react-dialog':
specifier: ^1.0.3
- version: 1.0.3(@types/react@18.0.27)(react-dom@18.2.0)(react@18.2.0)
+ version: 1.0.3(@types/react@18.2.20)(react-dom@18.2.0)(react@18.2.0)
'@radix-ui/react-label':
specifier: ^2.0.1
version: 2.0.1(react-dom@18.2.0)(react@18.2.0)
@@ -18,7 +22,7 @@ dependencies:
version: 1.0.2(react-dom@18.2.0)(react@18.2.0)
class-variance-authority:
specifier: ^0.6.0
- version: 0.6.0(typescript@4.9.5)
+ version: 0.6.0(typescript@5.1.6)
clsx:
specifier: ^1.2.1
version: 1.2.1
@@ -70,20 +74,20 @@ devDependencies:
specifier: ^5.3.7
version: 5.3.7
'@types/react':
- specifier: ^18.0.27
- version: 18.0.27
+ specifier: ^18.2.20
+ version: 18.2.20
'@types/react-dom':
- specifier: ^18.0.10
- version: 18.0.10
+ specifier: ^18.2.7
+ version: 18.2.7
'@typescript-eslint/eslint-plugin':
specifier: ^5.51.0
- version: 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5)
+ version: 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.1.6)
'@typescript-eslint/parser':
specifier: ^5.51.0
- version: 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ version: 5.51.0(eslint@8.34.0)(typescript@5.1.6)
'@vercel/style-guide':
specifier: ^4.0.2
- version: 4.0.2(@next/eslint-plugin-next@13.3.3-canary.1)(eslint@8.34.0)(jest@29.4.2)(prettier@2.8.4)(typescript@4.9.5)
+ version: 4.0.2(@next/eslint-plugin-next@13.3.3-canary.1)(eslint@8.34.0)(jest@29.4.2)(prettier@2.8.4)(typescript@5.1.6)
autoprefixer:
specifier: ^10.4.13
version: 10.4.13(postcss@8.4.21)
@@ -131,13 +135,13 @@ devDependencies:
version: 3.3.2
ts-jest:
specifier: ^29.0.5
- version: 29.0.5(@babel/core@7.20.12)(jest@29.4.2)(typescript@4.9.5)
+ version: 29.0.5(@babel/core@7.20.12)(jest@29.4.2)(typescript@5.1.6)
ts-standard:
specifier: ^12.0.2
- version: 12.0.2(typescript@4.9.5)
+ version: 12.0.2(typescript@5.1.6)
typescript:
- specifier: ^4.9.5
- version: 4.9.5
+ specifier: ^5.1.6
+ version: 5.1.6
wait-on:
specifier: ^7.0.1
version: 7.0.1
@@ -1087,7 +1091,7 @@ packages:
react: 18.2.0
dev: false
- /@radix-ui/react-dialog@1.0.3(@types/react@18.0.27)(react-dom@18.2.0)(react@18.2.0):
+ /@radix-ui/react-dialog@1.0.3(@types/react@18.2.20)(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-owNhq36kNPqC2/a+zJRioPg6HHnTn5B/sh/NjTY8r4W9g1L5VJlrzZIVcBr7R9Mg8iLjVmh6MGgMlfoVf/WO/A==}
peerDependencies:
react: ^16.8 || ^17.0 || ^18.0
@@ -1106,10 +1110,10 @@ packages:
'@radix-ui/react-primitive': 1.0.2(react-dom@18.2.0)(react@18.2.0)
'@radix-ui/react-slot': 1.0.1(react@18.2.0)
'@radix-ui/react-use-controllable-state': 1.0.0(react@18.2.0)
- aria-hidden: 1.2.2(@types/react@18.0.27)(react@18.2.0)
+ aria-hidden: 1.2.2(@types/react@18.2.20)(react@18.2.0)
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
- react-remove-scroll: 2.5.5(@types/react@18.0.27)(react@18.2.0)
+ react-remove-scroll: 2.5.5(@types/react@18.2.20)(react@18.2.0)
transitivePeerDependencies:
- '@types/react'
dev: false
@@ -1421,7 +1425,7 @@ packages:
dependencies:
'@babel/runtime': 7.20.13
'@testing-library/dom': 8.20.0
- '@types/react-dom': 18.0.10
+ '@types/react-dom': 18.2.7
react: 18.2.0
react-dom: 18.2.0(react@18.2.0)
dev: true
@@ -1521,14 +1525,14 @@ packages:
/@types/prop-types@15.7.5:
resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==}
- /@types/react-dom@18.0.10:
- resolution: {integrity: sha512-E42GW/JA4Qv15wQdqJq8DL4JhNpB3prJgjgapN3qJT9K2zO5IIAQh4VXvCEDupoqAwnz0cY4RlXeC/ajX5SFHg==}
+ /@types/react-dom@18.2.7:
+ resolution: {integrity: sha512-GRaAEriuT4zp9N4p1i8BDBYmEyfo+xQ3yHjJU4eiK5NDa1RmUZG+unZABUTK4/Ox/M+GaHwb6Ow8rUITrtjszA==}
dependencies:
- '@types/react': 18.0.27
+ '@types/react': 18.2.20
dev: true
- /@types/react@18.0.27:
- resolution: {integrity: sha512-3vtRKHgVxu3Jp9t718R9BuzoD4NcQ8YJ5XRzsSKxNDiDonD2MXIT1TmSkenxuCycZJoQT5d2vE8LwWJxBC1gmA==}
+ /@types/react@18.2.20:
+ resolution: {integrity: sha512-WKNtmsLWJM/3D5mG4U84cysVY31ivmyw85dE84fOCk5Hx78wezB/XEjVPWl2JTZ5FkEeaTJf+VgUAUn3PE7Isw==}
dependencies:
'@types/prop-types': 15.7.5
'@types/scheduler': 0.16.2
@@ -1577,7 +1581,7 @@ packages:
dev: true
optional: true
- /@typescript-eslint/eslint-plugin@5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5):
+ /@typescript-eslint/eslint-plugin@5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.1.6):
resolution: {integrity: sha512-wcAwhEWm1RgNd7dxD/o+nnLW8oH+6RK1OGnmbmkj/GGoDPV1WWMVP0FXYQBivKHdwM1pwii3bt//RC62EriIUQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -1588,10 +1592,10 @@ packages:
typescript:
optional: true
dependencies:
- '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
'@typescript-eslint/scope-manager': 5.51.0
- '@typescript-eslint/type-utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
- '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/type-utils': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
+ '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
debug: 4.3.4(supports-color@8.1.1)
eslint: 8.34.0
grapheme-splitter: 1.0.4
@@ -1599,13 +1603,13 @@ packages:
natural-compare-lite: 1.4.0
regexpp: 3.2.0
semver: 7.3.8
- tsutils: 3.21.0(typescript@4.9.5)
- typescript: 4.9.5
+ tsutils: 3.21.0(typescript@5.1.6)
+ typescript: 5.1.6
transitivePeerDependencies:
- supports-color
dev: true
- /@typescript-eslint/parser@5.51.0(eslint@8.34.0)(typescript@4.9.5):
+ /@typescript-eslint/parser@5.51.0(eslint@8.34.0)(typescript@5.1.6):
resolution: {integrity: sha512-fEV0R9gGmfpDeRzJXn+fGQKcl0inIeYobmmUWijZh9zA7bxJ8clPhV9up2ZQzATxAiFAECqPQyMDB4o4B81AaA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -1617,10 +1621,10 @@ packages:
dependencies:
'@typescript-eslint/scope-manager': 5.51.0
'@typescript-eslint/types': 5.51.0
- '@typescript-eslint/typescript-estree': 5.51.0(typescript@4.9.5)
+ '@typescript-eslint/typescript-estree': 5.51.0(typescript@5.1.6)
debug: 4.3.4(supports-color@8.1.1)
eslint: 8.34.0
- typescript: 4.9.5
+ typescript: 5.1.6
transitivePeerDependencies:
- supports-color
dev: true
@@ -1641,7 +1645,7 @@ packages:
'@typescript-eslint/visitor-keys': 5.59.1
dev: true
- /@typescript-eslint/type-utils@5.51.0(eslint@8.34.0)(typescript@4.9.5):
+ /@typescript-eslint/type-utils@5.51.0(eslint@8.34.0)(typescript@5.1.6):
resolution: {integrity: sha512-QHC5KKyfV8sNSyHqfNa0UbTbJ6caB8uhcx2hYcWVvJAZYJRBo5HyyZfzMdRx8nvS+GyMg56fugMzzWnojREuQQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -1651,12 +1655,12 @@ packages:
typescript:
optional: true
dependencies:
- '@typescript-eslint/typescript-estree': 5.51.0(typescript@4.9.5)
- '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/typescript-estree': 5.51.0(typescript@5.1.6)
+ '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
debug: 4.3.4(supports-color@8.1.1)
eslint: 8.34.0
- tsutils: 3.21.0(typescript@4.9.5)
- typescript: 4.9.5
+ tsutils: 3.21.0(typescript@5.1.6)
+ typescript: 5.1.6
transitivePeerDependencies:
- supports-color
dev: true
@@ -1671,7 +1675,7 @@ packages:
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
dev: true
- /@typescript-eslint/typescript-estree@5.51.0(typescript@4.9.5):
+ /@typescript-eslint/typescript-estree@5.51.0(typescript@5.1.6):
resolution: {integrity: sha512-TSkNupHvNRkoH9FMA3w7TazVFcBPveAAmb7Sz+kArY6sLT86PA5Vx80cKlYmd8m3Ha2SwofM1KwraF24lM9FvA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -1686,13 +1690,13 @@ packages:
globby: 11.1.0
is-glob: 4.0.3
semver: 7.3.8
- tsutils: 3.21.0(typescript@4.9.5)
- typescript: 4.9.5
+ tsutils: 3.21.0(typescript@5.1.6)
+ typescript: 5.1.6
transitivePeerDependencies:
- supports-color
dev: true
- /@typescript-eslint/typescript-estree@5.59.1(typescript@4.9.5):
+ /@typescript-eslint/typescript-estree@5.59.1(typescript@5.1.6):
resolution: {integrity: sha512-lYLBBOCsFltFy7XVqzX0Ju+Lh3WPIAWxYpmH/Q7ZoqzbscLiCW00LeYCdsUnnfnj29/s1WovXKh2gwCoinHNGA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -1707,13 +1711,13 @@ packages:
globby: 11.1.0
is-glob: 4.0.3
semver: 7.3.8
- tsutils: 3.21.0(typescript@4.9.5)
- typescript: 4.9.5
+ tsutils: 3.21.0(typescript@5.1.6)
+ typescript: 5.1.6
transitivePeerDependencies:
- supports-color
dev: true
- /@typescript-eslint/utils@5.51.0(eslint@8.34.0)(typescript@4.9.5):
+ /@typescript-eslint/utils@5.51.0(eslint@8.34.0)(typescript@5.1.6):
resolution: {integrity: sha512-76qs+5KWcaatmwtwsDJvBk4H76RJQBFe+Gext0EfJdC3Vd2kpY2Pf//OHHzHp84Ciw0/rYoGTDnIAr3uWhhJYw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -1723,7 +1727,7 @@ packages:
'@types/semver': 7.3.13
'@typescript-eslint/scope-manager': 5.51.0
'@typescript-eslint/types': 5.51.0
- '@typescript-eslint/typescript-estree': 5.51.0(typescript@4.9.5)
+ '@typescript-eslint/typescript-estree': 5.51.0(typescript@5.1.6)
eslint: 8.34.0
eslint-scope: 5.1.1
eslint-utils: 3.0.0(eslint@8.34.0)
@@ -1733,7 +1737,7 @@ packages:
- typescript
dev: true
- /@typescript-eslint/utils@5.59.1(eslint@8.34.0)(typescript@4.9.5):
+ /@typescript-eslint/utils@5.59.1(eslint@8.34.0)(typescript@5.1.6):
resolution: {integrity: sha512-MkTe7FE+K1/GxZkP5gRj3rCztg45bEhsd8HYjczBuYm+qFHP5vtZmjx3B0yUCDotceQ4sHgTyz60Ycl225njmA==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -1744,7 +1748,7 @@ packages:
'@types/semver': 7.3.13
'@typescript-eslint/scope-manager': 5.59.1
'@typescript-eslint/types': 5.59.1
- '@typescript-eslint/typescript-estree': 5.59.1(typescript@4.9.5)
+ '@typescript-eslint/typescript-estree': 5.59.1(typescript@5.1.6)
eslint: 8.34.0
eslint-scope: 5.1.1
semver: 7.3.8
@@ -1769,7 +1773,7 @@ packages:
eslint-visitor-keys: 3.3.0
dev: true
- /@vercel/style-guide@4.0.2(@next/eslint-plugin-next@13.3.3-canary.1)(eslint@8.34.0)(jest@29.4.2)(prettier@2.8.4)(typescript@4.9.5):
+ /@vercel/style-guide@4.0.2(@next/eslint-plugin-next@13.3.3-canary.1)(eslint@8.34.0)(jest@29.4.2)(prettier@2.8.4)(typescript@5.1.6):
resolution: {integrity: sha512-FroL+oOePzhw7n/I+f7zr4WNroGHT/+2TlW6WH9+CVSjMNsEyu7Qstj2mI5gWIBjT1Y2ZImKPppCzI2cIYmNZw==}
engines: {node: '>=16'}
peerDependencies:
@@ -1791,25 +1795,25 @@ packages:
'@babel/eslint-parser': 7.21.3(@babel/core@7.20.12)(eslint@8.34.0)
'@next/eslint-plugin-next': 13.3.3-canary.1
'@rushstack/eslint-patch': 1.2.0
- '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5)
- '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.1.6)
+ '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
eslint: 8.34.0
eslint-config-prettier: 8.6.0(eslint@8.34.0)
eslint-import-resolver-alias: 1.1.2(eslint-plugin-import@2.27.5)
eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@5.51.0)(eslint-plugin-import@2.27.5)(eslint@8.34.0)
eslint-plugin-eslint-comments: 3.2.0(eslint@8.34.0)
eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.51.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.34.0)
- eslint-plugin-jest: 27.2.1(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(jest@29.4.2)(typescript@4.9.5)
+ eslint-plugin-jest: 27.2.1(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(jest@29.4.2)(typescript@5.1.6)
eslint-plugin-jsx-a11y: 6.7.1(eslint@8.34.0)
eslint-plugin-playwright: 0.11.2(eslint-plugin-jest@27.2.1)(eslint@8.34.0)
eslint-plugin-react: 7.32.2(eslint@8.34.0)
eslint-plugin-react-hooks: 4.6.0(eslint@8.34.0)
- eslint-plugin-testing-library: 5.10.3(eslint@8.34.0)(typescript@4.9.5)
+ eslint-plugin-testing-library: 5.10.3(eslint@8.34.0)(typescript@5.1.6)
eslint-plugin-tsdoc: 0.2.17
eslint-plugin-unicorn: 43.0.2(eslint@8.34.0)
prettier: 2.8.4
prettier-plugin-packagejson: 2.4.3(prettier@2.8.4)
- typescript: 4.9.5
+ typescript: 5.1.6
transitivePeerDependencies:
- eslint-import-resolver-node
- eslint-import-resolver-webpack
@@ -1910,7 +1914,7 @@ packages:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
dev: true
- /aria-hidden@1.2.2(@types/react@18.0.27)(react@18.2.0):
+ /aria-hidden@1.2.2(@types/react@18.2.20)(react@18.2.0):
resolution: {integrity: sha512-6y/ogyDTk/7YAe91T3E2PR1ALVKyM2QbTio5HwM+N1Q6CMlCKhvClyIjkckBswa0f2xJhjsfzIGa1yVSe1UMVA==}
engines: {node: '>=10'}
peerDependencies:
@@ -1920,7 +1924,7 @@ packages:
'@types/react':
optional: true
dependencies:
- '@types/react': 18.0.27
+ '@types/react': 18.2.20
react: 18.2.0
tslib: 2.5.0
dev: false
@@ -2319,7 +2323,7 @@ packages:
resolution: {integrity: sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==}
dev: true
- /class-variance-authority@0.6.0(typescript@4.9.5):
+ /class-variance-authority@0.6.0(typescript@5.1.6):
resolution: {integrity: sha512-qdRDgfjx3GRb9fpwpSvn+YaidnT7IUJNe4wt5/SWwM+PmUwJUhQRk/8zAyNro0PmVfmen2635UboTjIBXXxy5A==}
peerDependencies:
typescript: '>= 4.5.5 < 6'
@@ -2328,7 +2332,7 @@ packages:
optional: true
dependencies:
clsx: 1.2.1
- typescript: 4.9.5
+ typescript: 5.1.6
dev: false
/clean-regexp@1.0.0:
@@ -2834,7 +2838,7 @@ packages:
eslint-plugin-react: 7.32.2(eslint@8.34.0)
dev: true
- /eslint-config-standard-with-typescript@23.0.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint-plugin-import@2.27.5)(eslint-plugin-n@15.7.0)(eslint-plugin-promise@6.1.1)(eslint@8.34.0)(typescript@4.9.5):
+ /eslint-config-standard-with-typescript@23.0.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint-plugin-import@2.27.5)(eslint-plugin-n@15.7.0)(eslint-plugin-promise@6.1.1)(eslint@8.34.0)(typescript@5.1.6):
resolution: {integrity: sha512-iaaWifImn37Z1OXbNW1es7KI+S7D408F9ys0bpaQf2temeBWlvb0Nc5qHkOgYaRb5QxTZT32GGeN1gtswASOXA==}
peerDependencies:
'@typescript-eslint/eslint-plugin': ^5.0.0
@@ -2844,14 +2848,14 @@ packages:
eslint-plugin-promise: ^6.0.0
typescript: '*'
dependencies:
- '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5)
- '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.1.6)
+ '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
eslint: 8.34.0
eslint-config-standard: 17.0.0(eslint-plugin-import@2.27.5)(eslint-plugin-n@15.7.0)(eslint-plugin-promise@6.1.1)(eslint@8.34.0)
eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.51.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.34.0)
eslint-plugin-n: 15.7.0(eslint@8.34.0)
eslint-plugin-promise: 6.1.1(eslint@8.34.0)
- typescript: 4.9.5
+ typescript: 5.1.6
transitivePeerDependencies:
- supports-color
dev: true
@@ -2934,7 +2938,7 @@ packages:
eslint-import-resolver-webpack:
optional: true
dependencies:
- '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
debug: 3.2.7(supports-color@8.1.1)
eslint: 8.34.0
eslint-import-resolver-node: 0.3.7
@@ -2984,7 +2988,7 @@ packages:
'@typescript-eslint/parser':
optional: true
dependencies:
- '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
array-includes: 3.1.6
array.prototype.flat: 1.3.1
array.prototype.flatmap: 1.3.1
@@ -3007,7 +3011,7 @@ packages:
- supports-color
dev: true
- /eslint-plugin-jest@27.2.1(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(jest@29.4.2)(typescript@4.9.5):
+ /eslint-plugin-jest@27.2.1(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(jest@29.4.2)(typescript@5.1.6):
resolution: {integrity: sha512-l067Uxx7ZT8cO9NJuf+eJHvt6bqJyz2Z29wykyEdz/OtmcELQl2MQGQLX8J94O1cSJWAwUSEvCjwjA7KEK3Hmg==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
peerDependencies:
@@ -3020,8 +3024,8 @@ packages:
jest:
optional: true
dependencies:
- '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5)
- '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.1.6)
+ '@typescript-eslint/utils': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
eslint: 8.34.0
jest: 29.4.2(@types/node@18.13.0)
transitivePeerDependencies:
@@ -3081,7 +3085,7 @@ packages:
optional: true
dependencies:
eslint: 8.34.0
- eslint-plugin-jest: 27.2.1(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(jest@29.4.2)(typescript@4.9.5)
+ eslint-plugin-jest: 27.2.1(@typescript-eslint/eslint-plugin@5.51.0)(eslint@8.34.0)(jest@29.4.2)(typescript@5.1.6)
dev: true
/eslint-plugin-prettier@4.2.1(eslint-config-prettier@8.6.0)(eslint@8.34.0)(prettier@2.8.4):
@@ -3154,13 +3158,13 @@ packages:
tailwindcss: 3.3.2
dev: true
- /eslint-plugin-testing-library@5.10.3(eslint@8.34.0)(typescript@4.9.5):
+ /eslint-plugin-testing-library@5.10.3(eslint@8.34.0)(typescript@5.1.6):
resolution: {integrity: sha512-0yhsKFsjHLud5PM+f2dWr9K3rqYzMy4cSHs3lcmFYMa1CdSzRvHGgXvsFarBjZ41gU8jhTdMIkg8jHLxGJqLqw==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0, npm: '>=6'}
peerDependencies:
eslint: ^7.5.0 || ^8.0.0
dependencies:
- '@typescript-eslint/utils': 5.59.1(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/utils': 5.59.1(eslint@8.34.0)(typescript@5.1.6)
eslint: 8.34.0
transitivePeerDependencies:
- supports-color
@@ -5625,7 +5629,7 @@ packages:
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
dev: true
- /react-remove-scroll-bar@2.3.4(@types/react@18.0.27)(react@18.2.0):
+ /react-remove-scroll-bar@2.3.4(@types/react@18.2.20)(react@18.2.0):
resolution: {integrity: sha512-63C4YQBUt0m6ALadE9XV56hV8BgJWDmmTPY758iIJjfQKt2nYwoUrPk0LXRXcB/yIj82T1/Ixfdpdk68LwIB0A==}
engines: {node: '>=10'}
peerDependencies:
@@ -5635,13 +5639,13 @@ packages:
'@types/react':
optional: true
dependencies:
- '@types/react': 18.0.27
+ '@types/react': 18.2.20
react: 18.2.0
- react-style-singleton: 2.2.1(@types/react@18.0.27)(react@18.2.0)
+ react-style-singleton: 2.2.1(@types/react@18.2.20)(react@18.2.0)
tslib: 2.5.0
dev: false
- /react-remove-scroll@2.5.5(@types/react@18.0.27)(react@18.2.0):
+ /react-remove-scroll@2.5.5(@types/react@18.2.20)(react@18.2.0):
resolution: {integrity: sha512-ImKhrzJJsyXJfBZ4bzu8Bwpka14c/fQt0k+cyFp/PBhTfyDnU5hjOtM4AG/0AMyy8oKzOTR0lDgJIM7pYXI0kw==}
engines: {node: '>=10'}
peerDependencies:
@@ -5651,16 +5655,16 @@ packages:
'@types/react':
optional: true
dependencies:
- '@types/react': 18.0.27
+ '@types/react': 18.2.20
react: 18.2.0
- react-remove-scroll-bar: 2.3.4(@types/react@18.0.27)(react@18.2.0)
- react-style-singleton: 2.2.1(@types/react@18.0.27)(react@18.2.0)
+ react-remove-scroll-bar: 2.3.4(@types/react@18.2.20)(react@18.2.0)
+ react-style-singleton: 2.2.1(@types/react@18.2.20)(react@18.2.0)
tslib: 2.5.0
- use-callback-ref: 1.3.0(@types/react@18.0.27)(react@18.2.0)
- use-sidecar: 1.1.2(@types/react@18.0.27)(react@18.2.0)
+ use-callback-ref: 1.3.0(@types/react@18.2.20)(react@18.2.0)
+ use-sidecar: 1.1.2(@types/react@18.2.20)(react@18.2.0)
dev: false
- /react-style-singleton@2.2.1(@types/react@18.0.27)(react@18.2.0):
+ /react-style-singleton@2.2.1(@types/react@18.2.20)(react@18.2.0):
resolution: {integrity: sha512-ZWj0fHEMyWkHzKYUr2Bs/4zU6XLmq9HsgBURm7g5pAVfyn49DgUiNgY2d4lXRlYSiCif9YBGpQleewkcqddc7g==}
engines: {node: '>=10'}
peerDependencies:
@@ -5670,7 +5674,7 @@ packages:
'@types/react':
optional: true
dependencies:
- '@types/react': 18.0.27
+ '@types/react': 18.2.20
get-nonce: 1.0.1
invariant: 2.2.4
react: 18.2.0
@@ -6307,7 +6311,7 @@ packages:
/ts-interface-checker@0.1.13:
resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==}
- /ts-jest@29.0.5(@babel/core@7.20.12)(jest@29.4.2)(typescript@4.9.5):
+ /ts-jest@29.0.5(@babel/core@7.20.12)(jest@29.4.2)(typescript@5.1.6):
resolution: {integrity: sha512-PL3UciSgIpQ7f6XjVOmbi96vmDHUqAyqDr8YxzopDqX3kfgYtX1cuNeBjP+L9sFXi6nzsGGA6R3fP3DDDJyrxA==}
engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
hasBin: true
@@ -6337,22 +6341,22 @@ packages:
lodash.memoize: 4.1.2
make-error: 1.3.6
semver: 7.3.8
- typescript: 4.9.5
+ typescript: 5.1.6
yargs-parser: 21.1.1
dev: true
- /ts-standard@12.0.2(typescript@4.9.5):
+ /ts-standard@12.0.2(typescript@5.1.6):
resolution: {integrity: sha512-XX2wrB9fKKTfBj4yD3ABm9iShzZcS2iWcPK8XzlBvuL20+wMiLgiz/k5tXgZwTaYq5wRhbks1Y9PelhujF/9ag==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
hasBin: true
peerDependencies:
typescript: '*'
dependencies:
- '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@4.9.5)
- '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@4.9.5)
+ '@typescript-eslint/eslint-plugin': 5.51.0(@typescript-eslint/parser@5.51.0)(eslint@8.34.0)(typescript@5.1.6)
+ '@typescript-eslint/parser': 5.51.0(eslint@8.34.0)(typescript@5.1.6)
eslint: 8.34.0
eslint-config-standard-jsx: 11.0.0(eslint-plugin-react@7.32.2)(eslint@8.34.0)
- eslint-config-standard-with-typescript: 23.0.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint-plugin-import@2.27.5)(eslint-plugin-n@15.7.0)(eslint-plugin-promise@6.1.1)(eslint@8.34.0)(typescript@4.9.5)
+ eslint-config-standard-with-typescript: 23.0.0(@typescript-eslint/eslint-plugin@5.51.0)(eslint-plugin-import@2.27.5)(eslint-plugin-n@15.7.0)(eslint-plugin-promise@6.1.1)(eslint@8.34.0)(typescript@5.1.6)
eslint-plugin-import: 2.27.5(@typescript-eslint/parser@5.51.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.34.0)
eslint-plugin-n: 15.7.0(eslint@8.34.0)
eslint-plugin-promise: 6.1.1(eslint@8.34.0)
@@ -6360,7 +6364,7 @@ packages:
minimist: 1.2.8
pkg-conf: 4.0.0
standard-engine: 15.0.0
- typescript: 4.9.5
+ typescript: 5.1.6
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
@@ -6383,14 +6387,14 @@ packages:
/tslib@2.5.0:
resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==}
- /tsutils@3.21.0(typescript@4.9.5):
+ /tsutils@3.21.0(typescript@5.1.6):
resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==}
engines: {node: '>= 6'}
peerDependencies:
typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta'
dependencies:
tslib: 1.14.1
- typescript: 4.9.5
+ typescript: 5.1.6
dev: true
/tunnel-agent@0.6.0:
@@ -6448,9 +6452,9 @@ packages:
is-typed-array: 1.1.10
dev: true
- /typescript@4.9.5:
- resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
- engines: {node: '>=4.2.0'}
+ /typescript@5.1.6:
+ resolution: {integrity: sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==}
+ engines: {node: '>=14.17'}
hasBin: true
/unbox-primitive@1.0.2:
@@ -6488,7 +6492,7 @@ packages:
punycode: 2.3.0
dev: true
- /use-callback-ref@1.3.0(@types/react@18.0.27)(react@18.2.0):
+ /use-callback-ref@1.3.0(@types/react@18.2.20)(react@18.2.0):
resolution: {integrity: sha512-3FT9PRuRdbB9HfXhEq35u4oZkvpJ5kuYbpqhCfmiZyReuRgpnhDlbr2ZEnnuS0RrJAPn6l23xjFg9kpDM+Ms7w==}
engines: {node: '>=10'}
peerDependencies:
@@ -6498,12 +6502,12 @@ packages:
'@types/react':
optional: true
dependencies:
- '@types/react': 18.0.27
+ '@types/react': 18.2.20
react: 18.2.0
tslib: 2.5.0
dev: false
- /use-sidecar@1.1.2(@types/react@18.0.27)(react@18.2.0):
+ /use-sidecar@1.1.2(@types/react@18.2.20)(react@18.2.0):
resolution: {integrity: sha512-epTbsLuzZ7lPClpz2TyryBfztm7m+28DlEv2ZCQ3MDr5ssiwyOwGH/e5F9CkfWjJ1t4clvI58yF822/GUkjjhw==}
engines: {node: '>=10'}
peerDependencies:
@@ -6513,7 +6517,7 @@ packages:
'@types/react':
optional: true
dependencies:
- '@types/react': 18.0.27
+ '@types/react': 18.2.20
detect-node-es: 1.1.0
react: 18.2.0
tslib: 2.5.0
diff --git a/src/app/[product]/client.tsx b/src/app/[product]/client.tsx
new file mode 100644
index 0000000..08b4b6c
--- /dev/null
+++ b/src/app/[product]/client.tsx
@@ -0,0 +1,20 @@
+"use client";
+
+import type {Product} from "~/product/types";
+
+import {useRouter} from "next/navigation";
+
+import ProductCard from "~/product/components/ProductCard";
+import {useCart} from "~/cart/context/client";
+
+export default function ProductPageClient({product}: {product: Product}) {
+ const [, {addItem}] = useCart();
+ const router = useRouter();
+
+ function handleAddToCart(product: Product) {
+ addItem(Date.now(), {...product, quantity: 1});
+ router.push("/");
+ }
+
+ return ;
+}
diff --git a/src/app/[product]/page.tsx b/src/app/[product]/page.tsx
new file mode 100644
index 0000000..d9c4b71
--- /dev/null
+++ b/src/app/[product]/page.tsx
@@ -0,0 +1,11 @@
+import api from "~/product/api";
+
+import ProductPageClient from "./client";
+
+const ProductPage = async ({params: {product}}: {params: {product: string}}) => {
+ const data = await api.fetch(product);
+
+ return ;
+};
+
+export default ProductPage;
diff --git a/src/app/_components/providers.tsx b/src/app/_components/providers.tsx
deleted file mode 100644
index 2193101..0000000
--- a/src/app/_components/providers.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-"use client";
-
-import {ThemeProvider} from "next-themes";
-
-export default function Providers({children}: {children: React.ReactNode}) {
- return (
-
- {children}
-
- );
-}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index e3a2c56..cd28782 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -3,9 +3,9 @@ import type {Metadata} from "next";
import api from "~/store/api";
import WhatsappIcon from "~/ui/components/icons/whatsapp";
import InstagramIcon from "~/ui/components/icons/instagram";
-
-import Providers from "./_components/providers";
-import {ThemeToggle} from "./_components/theme-toggle";
+import CartProvider from "~/cart/context";
+import ThemeProvider from "~/theme/context";
+import ThemeToggle from "~/theme/components/ThemeToggle";
import "./globals.css";
@@ -27,7 +27,7 @@ const RootLayout = async ({children}: {children: React.ReactNode}) => {
-
+
{
- {children}
+
+ {children}
+
-
+
diff --git a/src/app/mocks/[mock]/page.tsx b/src/app/mocks/[mock]/page.tsx
index a5027f6..83ab0f5 100644
--- a/src/app/mocks/[mock]/page.tsx
+++ b/src/app/mocks/[mock]/page.tsx
@@ -2,9 +2,8 @@ import productApi from "~/product/api";
import cartApi from "~/cart/api";
import storeApi from "~/store/api";
import StoreScreen from "~/store/screens/Store";
-import CartProvider from "~/cart/context";
-const IndexMockRoute = async ({
+const IndexMockPage = async ({
params: {mock},
}: {
params: {
@@ -15,11 +14,7 @@ const IndexMockRoute = async ({
const store = await storeApi.mock.fetch(mock);
const fields = await cartApi.mock.list(mock);
- return (
-
-
-
- );
+ return ;
};
-export default IndexMockRoute;
+export default IndexMockPage;
diff --git a/src/app/page.tsx b/src/app/page.tsx
index e9e7207..46085d4 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,7 +1,6 @@
import productApi from "~/product/api";
import cartApi from "~/cart/api";
import storeApi from "~/store/api";
-import CartProvider from "~/cart/context";
import StoreScreen from "~/store/screens/Store";
const IndexRoute = async () => {
@@ -9,11 +8,7 @@ const IndexRoute = async () => {
const fields = await cartApi.list();
const store = await storeApi.fetch();
- return (
-
-
-
- );
+ return ;
};
export default IndexRoute;
diff --git a/src/modules/cart/components/CartDrawer/CartDrawer.tsx b/src/modules/cart/components/CartDrawer/CartDrawer.tsx
index f5f04c9..52460d9 100644
--- a/src/modules/cart/components/CartDrawer/CartDrawer.tsx
+++ b/src/modules/cart/components/CartDrawer/CartDrawer.tsx
@@ -16,7 +16,7 @@ import {
import {Button} from "~/ui/components/control/button";
import WhatsappIcon from "~/ui/components/icons/whatsapp";
-import {useCart} from "../../context";
+import {useCart} from "../../context/client";
import Details from "./Details";
import Fields from "./Fields";
diff --git a/src/modules/cart/components/CartDrawer/__tests__/CartDrawer.test.tsx b/src/modules/cart/components/CartDrawer/__tests__/CartDrawer.test.tsx
index 39d295b..f265691 100644
--- a/src/modules/cart/components/CartDrawer/__tests__/CartDrawer.test.tsx
+++ b/src/modules/cart/components/CartDrawer/__tests__/CartDrawer.test.tsx
@@ -4,7 +4,7 @@ import * as React from "react";
import {render, screen, within} from "@testing-library/react";
import CartDrawer from "../CartDrawer";
-import * as cartContext from "../../../context";
+import * as cartContext from "../../../context/client";
jest.mock("../../../context");
diff --git a/src/modules/cart/context.tsx b/src/modules/cart/context/client.tsx
similarity index 89%
rename from src/modules/cart/context.tsx
rename to src/modules/cart/context/client.tsx
index ee83eb2..bf8ca14 100644
--- a/src/modules/cart/context.tsx
+++ b/src/modules/cart/context/client.tsx
@@ -1,12 +1,12 @@
"use client";
-import type {Cart, CartItem, Checkout, Field} from "./types";
+import type {Cart, CartItem, Checkout, Field} from "../types";
import {useState, useMemo, useCallback, useContext, createContext} from "react";
import {parseCurrency} from "~/currency/utils";
-import {getCartMessage, getCartTotal} from "./utils";
+import {getCartMessage, getCartTotal} from "../utils";
interface Context {
state: {
@@ -26,7 +26,7 @@ interface Context {
const CartContext = createContext({} as Context);
-function CartProvider(props: {fields: Field[]; children: React.ReactNode}) {
+function CartProviderClient(props: {fields: Field[]; children: React.ReactNode}) {
const [checkout, setCheckout] = useState(() => new Map());
const [cart, setCart] = useState(() => new Map());
const total = useMemo(() => parseCurrency(getCartTotal(cart)), [cart]);
@@ -90,4 +90,4 @@ export function useCart(): [Context["state"], Context["actions"]] {
return [state, actions];
}
-export default CartProvider;
+export default CartProviderClient;
diff --git a/src/modules/cart/context/index.tsx b/src/modules/cart/context/index.tsx
new file mode 100644
index 0000000..666d90f
--- /dev/null
+++ b/src/modules/cart/context/index.tsx
@@ -0,0 +1,11 @@
+import api from "~/cart/api";
+
+import CartProviderClient from "./client";
+
+const CartProvider = async ({children}: {children: React.ReactNode}) => {
+ const fields = await api.list();
+
+ return {children};
+};
+
+export default CartProvider;
diff --git a/src/modules/product/api.ts b/src/modules/product/api.ts
index 5ba5b33..e3e08ea 100644
--- a/src/modules/product/api.ts
+++ b/src/modules/product/api.ts
@@ -1,6 +1,7 @@
import type {Option as IOption, Product as IProduct} from "./types";
import Papa from "papaparse";
+import {notFound} from "next/navigation";
interface RawOption extends IOption {
type: "option";
@@ -103,7 +104,7 @@ function normalize(data: (RawProduct | RawOption | RawUnknown)[]) {
return normalized;
}
-export default {
+const api = {
list: async (): Promise => {
return fetch(process.env.PRODUCTS_CSV!).then(async (response) => {
const csv = await response.text();
@@ -121,6 +122,14 @@ export default {
});
});
},
+ fetch: async (id: IProduct["id"]): Promise => {
+ const products = await api.list();
+ const product = products.find((product) => product.id === id);
+
+ if (!product) return notFound();
+
+ return product;
+ },
mock: {
list: (mock: string): Promise =>
import(`./mocks/${mock}.json`).then((result: {default: (RawProduct | RawOption)[]}) =>
@@ -128,3 +137,5 @@ export default {
),
},
};
+
+export default api;
diff --git a/src/modules/product/components/ProductCard.tsx b/src/modules/product/components/ProductCard.tsx
index d0ab8f1..6146a66 100644
--- a/src/modules/product/components/ProductCard.tsx
+++ b/src/modules/product/components/ProductCard.tsx
@@ -1,3 +1,5 @@
+"use client";
+
import type {CartItem} from "~/cart/types";
import type {Product} from "../types";
diff --git a/src/modules/store/screens/Store.tsx b/src/modules/store/screens/Store.tsx
index f7ccaed..cd8f4c0 100644
--- a/src/modules/store/screens/Store.tsx
+++ b/src/modules/store/screens/Store.tsx
@@ -10,7 +10,7 @@ import {SearchIcon, X, Table, StretchHorizontal, ChevronDown} from "lucide-react
import {Button} from "~/ui/components/control/button";
import CartDrawer from "~/cart/components/CartDrawer";
-import {useCart} from "~/cart/context";
+import {useCart} from "~/cart/context/client";
import ProductCard from "~/product/components/ProductCard";
import {Input} from "~/ui/components/form/input";
import {Toggle} from "~/ui/components/form/toggle";
diff --git a/src/app/_components/theme-toggle.tsx b/src/modules/theme/components/ThemeToggle.tsx
similarity index 93%
rename from src/app/_components/theme-toggle.tsx
rename to src/modules/theme/components/ThemeToggle.tsx
index 3044fa7..e6b00bf 100644
--- a/src/app/_components/theme-toggle.tsx
+++ b/src/modules/theme/components/ThemeToggle.tsx
@@ -4,7 +4,7 @@ import {useTheme} from "next-themes";
import {Button} from "~/ui/components/control/button";
-export function ThemeToggle() {
+export default function ThemeToggle() {
const {setTheme, theme} = useTheme();
return (
diff --git a/src/modules/theme/context.tsx b/src/modules/theme/context.tsx
new file mode 100644
index 0000000..49ae87d
--- /dev/null
+++ b/src/modules/theme/context.tsx
@@ -0,0 +1,11 @@
+"use client";
+
+import {ThemeProvider as NextThemesProvider} from "next-themes";
+
+export default function ThemeProvider({children}: {children: React.ReactNode}) {
+ return (
+
+ {children}
+
+ );
+}
diff --git a/src/pages/api/revalidate.ts b/src/pages/api/revalidate.ts
deleted file mode 100644
index 6f3f5e1..0000000
--- a/src/pages/api/revalidate.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import type {NextApiRequest, NextApiResponse} from "next";
-
-export default async function handler(req: NextApiRequest, res: NextApiResponse) {
- if (req.query.secret === process.env.REVALIDATE_SECRET) {
- await res.revalidate("/");
-
- return res.json({revalidate: true});
- }
-
- return res.status(401).end();
-}