@akinon/projectzero 2.0.0-beta.12 → 2.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -23
- package/app-template/.env.example +1 -0
- package/app-template/.github/instructions/account.instructions.md +749 -0
- package/app-template/.github/instructions/checkout.instructions.md +678 -0
- package/app-template/.github/instructions/default.instructions.md +279 -0
- package/app-template/.github/instructions/edge-cases.instructions.md +73 -0
- package/app-template/.github/instructions/routing.instructions.md +603 -0
- package/app-template/.github/instructions/settings.instructions.md +338 -0
- package/app-template/.gitignore +3 -0
- package/app-template/AGENTS.md +7 -0
- package/app-template/CHANGELOG.md +1348 -310
- package/app-template/Procfile +1 -1
- package/app-template/akinon.json +0 -3
- package/app-template/build.sh +10 -0
- package/app-template/docs/advanced-usage.md +101 -0
- package/app-template/docs/sentry-usage.md +35 -0
- package/app-template/next-env.d.ts +1 -0
- package/app-template/{next.config.ts → next.config.mjs} +6 -6
- package/app-template/package.json +58 -51
- package/app-template/postcss.config.mjs +1 -4
- package/app-template/public/locales/en/checkout.json +6 -0
- package/app-template/public/locales/en/common.json +50 -1
- package/app-template/public/locales/en/product.json +62 -1
- package/app-template/public/locales/tr/checkout.json +6 -0
- package/app-template/public/locales/tr/common.json +50 -1
- package/app-template/public/locales/tr/product.json +63 -0
- package/app-template/public/masterpass-javascript-sdk-web.min.js +1 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/[...prettyurl]/page.tsx +9 -9
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/layout.tsx +2 -2
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/[id]/cancellation/page.tsx +6 -6
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/[id]/page.tsx +6 -6
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/page.tsx +1 -1
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/profile/page.tsx +2 -2
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/address/stores/page.tsx +2 -2
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/auth/page.tsx +1 -1
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/basket/page.tsx +2 -2
- package/app-template/src/app/[pz]/category/[pk]/page.tsx +27 -0
- package/app-template/src/app/[pz]/flat-page/[pk]/page.tsx +23 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/forms/[pk]/generate/page.tsx +2 -3
- package/app-template/src/app/[pz]/group-product/[pk]/page.tsx +93 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/landing-page/[pk]/page.tsx +2 -4
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/layout.tsx +3 -10
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/list/page.tsx +2 -4
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/not-found.tsx +5 -7
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/orders/completed/[token]/page.tsx +6 -4
- package/app-template/src/app/[pz]/product/[pk]/page.tsx +102 -0
- package/app-template/src/app/[pz]/special-page/[pk]/page.tsx +35 -0
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/email-set-primary/[[...id]]/page.tsx +3 -4
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/registration/account-confirm-email/[[...id]]/page.tsx +3 -3
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/reset/[[...id]]/page.tsx +6 -12
- package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/xml-sitemap/[node]/route.ts +2 -2
- package/app-template/src/app/api/auth/[...nextauth]/route.ts +3 -0
- package/app-template/src/app/api/form/[...id]/route.ts +1 -7
- package/app-template/src/app/api/image-proxy/route.ts +1 -0
- package/app-template/src/app/api/product-categories/route.ts +1 -0
- package/app-template/src/app/api/similar-product-list/route.ts +1 -0
- package/app-template/src/app/api/similar-products/route.ts +1 -0
- package/app-template/src/app/api/virtual-try-on/limited-categories/route.ts +1 -0
- package/app-template/src/app/api/virtual-try-on/route.ts +1 -0
- package/app-template/src/assets/globals.scss +4 -133
- package/app-template/src/auth.ts +3 -0
- package/app-template/src/components/__tests__/badge.test.tsx +2 -2
- package/app-template/src/components/__tests__/link.test.tsx +2 -0
- package/app-template/src/components/accordion.tsx +23 -20
- package/app-template/src/components/button.tsx +1 -1
- package/app-template/src/components/carousel-core.tsx +4 -11
- package/app-template/src/components/checkbox.tsx +1 -1
- package/app-template/src/components/currency-select.tsx +1 -0
- package/app-template/src/components/file-input.tsx +27 -7
- package/app-template/src/components/generate-form-fields.tsx +49 -10
- package/app-template/src/components/input.tsx +11 -5
- package/app-template/src/components/modal.tsx +32 -16
- package/app-template/src/components/pagination.tsx +1 -0
- package/app-template/src/components/price.tsx +1 -1
- package/app-template/src/components/pwa-tags.tsx +1 -0
- package/app-template/src/components/select.tsx +39 -27
- package/app-template/src/components/shimmer.tsx +1 -1
- package/app-template/src/components/types/index.ts +25 -1
- package/app-template/src/hooks/use-fav-button.tsx +4 -8
- package/app-template/src/hooks/use-product-cart.ts +77 -0
- package/app-template/src/hooks/use-stock-alert.ts +74 -0
- package/app-template/src/plugins.js +12 -2
- package/app-template/src/redux/middlewares/category.ts +5 -4
- package/app-template/src/redux/store.ts +21 -1
- package/app-template/src/routes/index.ts +2 -1
- package/app-template/src/settings.js +3 -1
- package/app-template/src/types/index.ts +74 -3
- package/app-template/src/types/next-auth.d.ts +2 -2
- package/app-template/src/utils/variant-validation.ts +41 -0
- package/app-template/src/views/account/address-form.tsx +8 -4
- package/app-template/src/views/account/contact-form.tsx +2 -2
- package/app-template/src/views/account/content-header.tsx +4 -3
- package/app-template/src/views/account/faq/faq-tabs.tsx +8 -2
- package/app-template/src/views/account/order.tsx +1 -1
- package/app-template/src/views/account/orders/order-cancellation-item.tsx +1 -1
- package/app-template/src/views/anonymous-tracking/order-detail/index.tsx +1 -1
- package/app-template/src/views/basket/basket-item.tsx +6 -1
- package/app-template/src/views/basket/summary.tsx +16 -0
- package/app-template/src/views/breadcrumb.tsx +2 -2
- package/app-template/src/views/category/category-info.tsx +2 -1
- package/app-template/src/views/category/filters/index.tsx +1 -1
- package/app-template/src/views/checkout/auth.tsx +1 -1
- package/app-template/src/views/checkout/layout/header.tsx +1 -1
- package/app-template/src/views/checkout/steps/payment/options/credit-card/index.tsx +1 -1
- package/app-template/src/views/checkout/steps/payment/options/store-credit.tsx +121 -0
- package/app-template/src/views/checkout/steps/payment/payment-option-buttons.tsx +4 -4
- package/app-template/src/views/checkout/steps/shipping/address-box.tsx +3 -3
- package/app-template/src/views/checkout/steps/shipping/addresses.tsx +1 -1
- package/app-template/src/views/checkout/summary.tsx +12 -2
- package/app-template/src/views/find-in-store/index.tsx +2 -2
- package/app-template/src/views/header/action-menu.tsx +2 -6
- package/app-template/src/views/header/band.tsx +2 -2
- package/app-template/src/views/header/index.tsx +1 -1
- package/app-template/src/views/header/mini-basket.tsx +2 -2
- package/app-template/src/views/header/mobile-menu.tsx +6 -6
- package/app-template/src/views/header/navbar.tsx +1 -1
- package/app-template/src/views/header/pwa-back-button.tsx +1 -1
- package/app-template/src/views/header/search/index.tsx +13 -3
- package/app-template/src/views/header/search/results.tsx +1 -1
- package/app-template/src/views/header/user-menu.tsx +1 -3
- package/app-template/src/views/login/index.tsx +14 -13
- package/app-template/src/views/otp-login/index.tsx +11 -6
- package/app-template/src/views/product/layout.tsx +15 -1
- package/app-template/src/views/product/product-actions.tsx +165 -0
- package/app-template/src/views/product/product-info.tsx +69 -261
- package/app-template/src/views/product/product-share.tsx +56 -0
- package/app-template/src/views/product/product-variants.tsx +26 -0
- package/app-template/src/views/product/slider.tsx +22 -1
- package/app-template/src/views/product-pointer-banner-item.tsx +1 -1
- package/app-template/src/views/register/index.tsx +17 -21
- package/app-template/src/views/sales-contract-modal/index.tsx +17 -17
- package/app-template/src/widgets/footer-info.tsx +1 -1
- package/app-template/src/widgets/footer-menu.tsx +7 -3
- package/app-template/src/widgets/footer-subscription/index.tsx +1 -1
- package/app-template/src/widgets/home-stories-eng.tsx +43 -35
- package/app-template/tailwind.config.js +129 -1
- package/app-template/tsconfig.json +29 -11
- package/codemods/migrate-segments/index.js +591 -0
- package/commands/plugins.ts +62 -14
- package/dist/commands/plugins.js +62 -14
- package/package.json +1 -1
- package/app-template/src/app/[commerce]/[locale]/[currency]/category/[pk]/page.tsx +0 -22
- package/app-template/src/app/[commerce]/[locale]/[currency]/flat-page/[pk]/page.tsx +0 -20
- package/app-template/src/app/[commerce]/[locale]/[currency]/group-product/[pk]/page.tsx +0 -74
- package/app-template/src/app/[commerce]/[locale]/[currency]/product/[pk]/page.tsx +0 -84
- package/app-template/src/app/[commerce]/[locale]/[currency]/special-page/[pk]/page.tsx +0 -27
- package/app-template/src/pages/api/auth/[...nextauth].ts +0 -3
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/address/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/change-email/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/change-password/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/contact/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/coupons/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/email-verification/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/faq/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/favourite-products/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/my-quotations/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/[id]/layout.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/account/orders/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/anonymous-tracking/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/auth/oauth-login/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/basket-b2b/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/category/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/client-root.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/contact-us/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/error.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/flat-page/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/group-product/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/landing-page/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/list/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/orders/checkout/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/orders/completed/[token]/layout.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/special-page/[pk]/loading.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/template.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/users/password/reset/page.tsx +0 -0
- /package/app-template/src/app/{[commerce]/[locale]/[currency] → [pz]}/xml-sitemap/route.ts +0 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Project Zero Next.js App - Developer Instructions
|
|
6
|
+
|
|
7
|
+
## Project Overview
|
|
8
|
+
|
|
9
|
+
This is a **standalone Project Zero Next.js application** - a headless e-commerce storefront built on top of Akinon Commerce Cloud. This app can be cloned and run independently using the `packages/projectzero` command line tool.
|
|
10
|
+
|
|
11
|
+
## Key Characteristics
|
|
12
|
+
|
|
13
|
+
- **Standalone Application**: Can be cloned with `packages/projectzero` CLI and run independently
|
|
14
|
+
- **Next.js 14.2.25**: Uses App Router with dynamic routes
|
|
15
|
+
- **TypeScript**: With relaxed strict mode
|
|
16
|
+
- **E-commerce Focus**: Complete storefront with basket, checkout, payments, user management
|
|
17
|
+
|
|
18
|
+
## Project Structure
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
apps/projectzeronext/
|
|
22
|
+
├── src/
|
|
23
|
+
│ ├── app/[commerce]/[locale]/[currency]/ # App Router pages
|
|
24
|
+
│ ├── components/ # App-specific UI components
|
|
25
|
+
│ ├── views/ # Page-specific view components
|
|
26
|
+
│ ├── hooks/ # Custom React hooks
|
|
27
|
+
│ ├── redux/ # App-specific Redux slices
|
|
28
|
+
│ ├── types/ # App-specific TypeScript types
|
|
29
|
+
│ ├── utils/ # Utility functions
|
|
30
|
+
│ ├── settings.js # Application configuration
|
|
31
|
+
│ ├── routes/ # Route definitions
|
|
32
|
+
│ └── middleware.ts # Next.js middleware
|
|
33
|
+
├── public/ # Static assets
|
|
34
|
+
├── config/ # Configuration files
|
|
35
|
+
├── docs/ # Documentation
|
|
36
|
+
├── package.json # Dependencies and scripts
|
|
37
|
+
├── next.config.mjs # Next.js configuration
|
|
38
|
+
├── tailwind.config.js # TailwindCSS configuration
|
|
39
|
+
└── tsconfig.json # TypeScript configuration
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Core Dependencies
|
|
43
|
+
|
|
44
|
+
### Essential Packages
|
|
45
|
+
|
|
46
|
+
- `@akinon/next`: Core e-commerce functionality (version ^1.93.0)
|
|
47
|
+
- `next`: Next.js framework (14.2.25)
|
|
48
|
+
- `react` & `react-dom`: React framework
|
|
49
|
+
- `@reduxjs/toolkit`: State management
|
|
50
|
+
- `next-auth`: Authentication
|
|
51
|
+
- `react-hook-form`: Form handling
|
|
52
|
+
- `yup`: Form validation
|
|
53
|
+
|
|
54
|
+
### UI & Styling
|
|
55
|
+
|
|
56
|
+
- `tailwindcss`: Utility-first CSS framework
|
|
57
|
+
- `clsx` & `tailwind-merge`: Conditional styling
|
|
58
|
+
- `lucide-react`: Icon library
|
|
59
|
+
|
|
60
|
+
### Plugin Packages
|
|
61
|
+
|
|
62
|
+
The app includes various `pz-*` plugin packages for extended functionality:
|
|
63
|
+
|
|
64
|
+
- `pz-akifast`, `pz-b2b`, `pz-basket-gift-pack`
|
|
65
|
+
- `pz-bkm`, `pz-checkout-gift-pack`, `pz-click-collect`
|
|
66
|
+
- Payment providers: `pz-apple-pay`, `pz-gpay`, `pz-masterpass`, etc.
|
|
67
|
+
|
|
68
|
+
## Architecture Patterns
|
|
69
|
+
|
|
70
|
+
### Route Structure
|
|
71
|
+
|
|
72
|
+
- Dynamic routes: `/[commerce]/[locale]/[currency]/`
|
|
73
|
+
- App Router with server and client components
|
|
74
|
+
- Middleware for routing and internationalization
|
|
75
|
+
|
|
76
|
+
### Data Fetching
|
|
77
|
+
|
|
78
|
+
- **RTK Query** for API calls
|
|
79
|
+
- Server components for initial data
|
|
80
|
+
- Client components with hooks for interactivity
|
|
81
|
+
- Example patterns:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// Server component data fetching
|
|
85
|
+
const basketData = await getBasket();
|
|
86
|
+
|
|
87
|
+
// Client component hooks
|
|
88
|
+
const { data: basket } = useGetBasketQuery();
|
|
89
|
+
const [addToBasket] = useAddProductToBasketMutation();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### State Management
|
|
93
|
+
|
|
94
|
+
- **Redux Toolkit** with key slices:
|
|
95
|
+
- `checkout`: Multi-step checkout flow
|
|
96
|
+
- `basket`: Shopping cart state
|
|
97
|
+
- `header`: Navigation state
|
|
98
|
+
- `root`: Global app state
|
|
99
|
+
- Use `useAppSelector` and `useAppDispatch`
|
|
100
|
+
|
|
101
|
+
### Component Architecture
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
// Theme components (app-specific)
|
|
105
|
+
import { Button, Input } from '@theme/components';
|
|
106
|
+
|
|
107
|
+
// Core components (from @akinon/next)
|
|
108
|
+
import { Image } from '@akinon/next/components/image';
|
|
109
|
+
|
|
110
|
+
// Plugin system
|
|
111
|
+
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Forms & Validation
|
|
115
|
+
|
|
116
|
+
Standard pattern with React Hook Form + Yup:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
const schema = (t) =>
|
|
120
|
+
yup.object().shape({
|
|
121
|
+
email: yup.string().email().required(t('error.required')),
|
|
122
|
+
password: yup.string().min(6).required(t('error.required'))
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const {
|
|
126
|
+
register,
|
|
127
|
+
handleSubmit,
|
|
128
|
+
formState: { errors }
|
|
129
|
+
} = useForm({
|
|
130
|
+
resolver: yupResolver(schema(t))
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## E-commerce Features
|
|
135
|
+
|
|
136
|
+
### Core Functionality
|
|
137
|
+
|
|
138
|
+
- **Product Catalog**: Browse, search, filter products
|
|
139
|
+
- **Basket Management**: Add/remove items, quantity updates
|
|
140
|
+
- **Checkout Flow**: Multi-step process (auth → shipping → payment → confirmation)
|
|
141
|
+
- **User Accounts**: Registration, login, order history
|
|
142
|
+
- **Payment Integration**: Multiple payment providers
|
|
143
|
+
- **Order Management**: Track orders, view history
|
|
144
|
+
|
|
145
|
+
### Internationalization
|
|
146
|
+
|
|
147
|
+
- Multi-language support with `useLocalization()` hook
|
|
148
|
+
- Dynamic locale routing: `/[locale]/`
|
|
149
|
+
- Translation keys: `t('checkout.auth.title')`
|
|
150
|
+
- Settings configuration in `src/settings.js`
|
|
151
|
+
|
|
152
|
+
### Authentication
|
|
153
|
+
|
|
154
|
+
- NextAuth.js integration
|
|
155
|
+
- Session management with `useSession()`
|
|
156
|
+
- Protected routes via middleware
|
|
157
|
+
- User account features
|
|
158
|
+
|
|
159
|
+
## Development Guidelines
|
|
160
|
+
|
|
161
|
+
### File Naming & Structure
|
|
162
|
+
|
|
163
|
+
- Components: PascalCase (`ProductCard.tsx`)
|
|
164
|
+
- Pages: kebab-case in App Router directories
|
|
165
|
+
- Hooks: camelCase starting with `use` (`useBasket.ts`)
|
|
166
|
+
- Types: PascalCase with descriptive names (`ProductType.ts`)
|
|
167
|
+
|
|
168
|
+
### Import Conventions
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
// Path aliases (configured in tsconfig.json)
|
|
172
|
+
import { Button } from '@theme/components'; // App components
|
|
173
|
+
import { Image } from '@akinon/next/components'; // Core components
|
|
174
|
+
import { useLocalization } from '@akinon/next/hooks'; // Core hooks
|
|
175
|
+
import { ProductType } from '@akinon/next/types'; // Core types
|
|
176
|
+
import { routes } from '@root/routes'; // App routes
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Styling Guidelines
|
|
180
|
+
|
|
181
|
+
- **TailwindCSS** for all styling
|
|
182
|
+
- Use `clsx` and `twMerge` for conditional classes
|
|
183
|
+
- Responsive design: mobile-first approach
|
|
184
|
+
- Theme customization in `tailwind.config.js`
|
|
185
|
+
|
|
186
|
+
### Performance Best Practices
|
|
187
|
+
|
|
188
|
+
- Lazy loading with `LazyComponent`
|
|
189
|
+
- Next.js `Image` component for optimized images
|
|
190
|
+
- Code splitting with dynamic imports
|
|
191
|
+
- Intersection Observer for viewport-based loading
|
|
192
|
+
|
|
193
|
+
## Development Commands
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Development
|
|
197
|
+
yarn dev # Start development server
|
|
198
|
+
yarn build # Build for production
|
|
199
|
+
yarn start # Start production server
|
|
200
|
+
|
|
201
|
+
# Code Quality
|
|
202
|
+
yarn lint # Run ESLint
|
|
203
|
+
yarn lint:fix # Fix ESLint issues
|
|
204
|
+
yarn type-check # TypeScript type checking
|
|
205
|
+
|
|
206
|
+
# Testing
|
|
207
|
+
yarn test # Run Jest tests
|
|
208
|
+
yarn test:watch # Run tests in watch mode
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Configuration Files
|
|
212
|
+
|
|
213
|
+
### Key Config Files
|
|
214
|
+
|
|
215
|
+
- `next.config.mjs`: Next.js configuration
|
|
216
|
+
- `tailwind.config.js`: TailwindCSS theme and plugins
|
|
217
|
+
- `src/settings.js`: App-specific settings (commerce, locales, etc.)
|
|
218
|
+
- `src/middleware.ts`: Route handling and internationalization
|
|
219
|
+
- `package.json`: Dependencies and scripts
|
|
220
|
+
|
|
221
|
+
### Environment Variables
|
|
222
|
+
|
|
223
|
+
Configure in `.env.local`:
|
|
224
|
+
|
|
225
|
+
- `NEXTAUTH_SECRET`: Authentication secret
|
|
226
|
+
- `NEXTAUTH_URL`: Application URL
|
|
227
|
+
- Commerce API endpoints
|
|
228
|
+
- Payment provider configurations
|
|
229
|
+
|
|
230
|
+
## Plugin System
|
|
231
|
+
|
|
232
|
+
### Using Plugins
|
|
233
|
+
|
|
234
|
+
```tsx
|
|
235
|
+
import PluginModule, { Component } from '@akinon/next/components/plugin-module';
|
|
236
|
+
|
|
237
|
+
// Conditional plugin rendering
|
|
238
|
+
<PluginModule component={Component.BasketGiftPack} props={{ basket }} />;
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Available Plugins
|
|
242
|
+
|
|
243
|
+
- **Payment**: Apple Pay, Google Pay, BKM, Masterpass
|
|
244
|
+
- **Checkout**: Gift packs, click & collect, one-click checkout
|
|
245
|
+
- **Business**: B2B features, multi-basket, saved cards
|
|
246
|
+
- **Regional**: Tabby, Tamara (MENA region)
|
|
247
|
+
|
|
248
|
+
## Important Notes
|
|
249
|
+
|
|
250
|
+
### Critical Middleware
|
|
251
|
+
|
|
252
|
+
- **Never remove** `withPzDefault` middleware - essential for app functionality
|
|
253
|
+
- Middleware handles routing, locale detection, commerce resolution
|
|
254
|
+
|
|
255
|
+
### State Management
|
|
256
|
+
|
|
257
|
+
- Checkout uses multi-step Redux flow
|
|
258
|
+
- Basket state syncs with backend APIs
|
|
259
|
+
- User session integrates with NextAuth
|
|
260
|
+
|
|
261
|
+
### SEO & Analytics
|
|
262
|
+
|
|
263
|
+
- GTM integration for e-commerce tracking
|
|
264
|
+
- Server-side rendering for SEO
|
|
265
|
+
- Structured data for products
|
|
266
|
+
|
|
267
|
+
### Deployment
|
|
268
|
+
|
|
269
|
+
- Can be deployed standalone
|
|
270
|
+
- Supports various hosting platforms
|
|
271
|
+
- Environment-specific configurations
|
|
272
|
+
|
|
273
|
+
When working with this app, always consider:
|
|
274
|
+
|
|
275
|
+
1. **E-commerce context**: Every feature impacts the shopping experience
|
|
276
|
+
2. **Plugin architecture**: Use modular approach for features
|
|
277
|
+
3. **Internationalization**: Support multiple languages/regions
|
|
278
|
+
4. **Performance**: Optimize for mobile commerce
|
|
279
|
+
5. **Standalone nature**: App should work independently when cloned
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
applyTo: '**'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Edge Cases & Troubleshooting Instructions
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This document contains common edge cases, bugs, and troubleshooting steps encountered in Project Zero Next.js development. These are real-world issues that have caused development delays and should be checked first when similar problems occur.
|
|
10
|
+
|
|
11
|
+
## Checkout Flow Edge Cases
|
|
12
|
+
|
|
13
|
+
### 1. Order Selection Page Request Timing
|
|
14
|
+
|
|
15
|
+
**Problem:** `orderselectionpage` request should NOT be called after `walletselectionpage` or `walletpaymentpage` requests.
|
|
16
|
+
|
|
17
|
+
This causes checkout flow to break after wallet payment steps, order selection shows incorrect state, and payment flow gets reset unexpectedly. After `walletselectionpage` or `walletpaymentpage` requests are made, `orderselectionpage` request should not be called. Always check the sequence of checkout API calls.
|
|
18
|
+
|
|
19
|
+
### 2. Guest Login with URL Parameters
|
|
20
|
+
|
|
21
|
+
**Problem:** Adding `?page=IndexPage` to checkout URLs breaks guest login functionality.
|
|
22
|
+
|
|
23
|
+
Guest login fails on checkout URLs with `?page=IndexPage` but works fine without the parameter. This parameter interferes with authentication middleware routing. Avoid adding unnecessary URL parameters to checkout flows.
|
|
24
|
+
|
|
25
|
+
### 3. Agreement Error After 3D Payment Redirect
|
|
26
|
+
|
|
27
|
+
**Problem:** "You must accept agreement to continue" error appears after 3D payment or redirections, but the issue is NOT related to agreements.
|
|
28
|
+
|
|
29
|
+
Agreement error occurs after successful 3D payment and checkout flow breaks after external redirections. The error message is misleading - actually `preOrder` data gets reset/lost during payment redirections. Don't assume agreement errors are actually about agreements.
|
|
30
|
+
|
|
31
|
+
### 4. Address Visibility with fetchCheckout
|
|
32
|
+
|
|
33
|
+
**Problem:** When `fetchCheckout` request includes `page=IndexPage` parameter, addresses don't show in checkout and the entire flow breaks.
|
|
34
|
+
|
|
35
|
+
Addresses are missing from checkout page, shipping options don't load, and checkout flow is completely broken. Avoid adding unnecessary parameters to core checkout requests and validate that all checkout data loads properly.
|
|
36
|
+
|
|
37
|
+
## Plugin & Configuration Edge Cases
|
|
38
|
+
|
|
39
|
+
### 5. Attribute-Based Shipping Options Typo
|
|
40
|
+
|
|
41
|
+
**Problem:** `attribute_based_shipping_options` was incorrectly entered as `atribute_based` (missing 't') in brand configurations.
|
|
42
|
+
|
|
43
|
+
Shipping options don't work for specific brands and debugging is difficult because the setting exists but is misspelled. This can cause days of debugging. Always double-check configuration property names.
|
|
44
|
+
|
|
45
|
+
### 6. Apple Pay Plugin Configuration
|
|
46
|
+
|
|
47
|
+
**Problem:** Apple Pay can work as both `confirmation` and `wallet` payment types, but for the plugin to work properly, it should NOT be configured as `confirmation` type.
|
|
48
|
+
|
|
49
|
+
Apple Pay flow breaks in certain scenarios, payment confirmation issues occur, and plugin conflicts with checkout flow. Always configure Apple Pay as wallet type.
|
|
50
|
+
|
|
51
|
+
## Build & Development Edge Cases
|
|
52
|
+
|
|
53
|
+
### 7. Build Failures Due to yarn.lock Corruption
|
|
54
|
+
|
|
55
|
+
**Problem:** Build fails with apparent TypeScript errors in `@akinon/next` components, but the real issue is a corrupted `yarn.lock` file.
|
|
56
|
+
|
|
57
|
+
Build fails with nonsensical type errors, components from `@akinon/next` are flagged with errors, and multiple versions of the same package exist in lock file.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Check for duplicate packages in yarn.lock
|
|
61
|
+
yarn list --pattern "@akinon/next" --depth=0
|
|
62
|
+
|
|
63
|
+
# If multiple versions exist, clean up
|
|
64
|
+
rm yarn.lock
|
|
65
|
+
rm -rf node_modules
|
|
66
|
+
yarn install
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Regularly check `yarn.lock` for duplicate dependencies and use `yarn dedupe` after adding new packages.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
**Remember:** Edge cases often have misleading error messages. Always investigate the root cause rather than fixing symptoms. The most time-consuming bugs are usually simple configuration or timing issues.
|