Files
WooNooW/customer-spa/README.md
dwindown 909bddb23d feat: Create customer-spa core foundation (Sprint 1)
Sprint 1 - Foundation Complete! 

Created Core Files:
 src/main.tsx - Entry point
 src/App.tsx - Main app with routing
 src/index.css - Global styles (TailwindCSS)
 index.html - Development HTML

Pages Created (Placeholders):
 pages/Shop/index.tsx - Product listing
 pages/Product/index.tsx - Product detail
 pages/Cart/index.tsx - Shopping cart
 pages/Checkout/index.tsx - Checkout process
 pages/Account/index.tsx - My Account with sub-routes

Library Setup:
 lib/api/client.ts - API client with endpoints
 lib/cart/store.ts - Cart state management (Zustand)
 types/index.ts - TypeScript definitions

Configuration:
 .gitignore - Ignore node_modules, dist, logs
 README.md - Documentation

Features Implemented:

1. Routing (React Router v7)
   - /shop - Product listing
   - /shop/product/:id - Product detail
   - /shop/cart - Shopping cart
   - /shop/checkout - Checkout
   - /shop/account/* - My Account (dashboard, orders, profile)

2. API Client
   - Fetch wrapper with error handling
   - WordPress nonce authentication
   - Endpoints for shop, cart, checkout, account
   - TypeScript typed responses

3. Cart State (Zustand)
   - Add/update/remove items
   - Cart drawer (open/close)
   - LocalStorage persistence
   - Quantity management
   - Coupon support

4. Type Definitions
   - Product, Order, Customer types
   - Address, ShippingMethod, PaymentMethod
   - Cart, CartItem types
   - Window interface for WordPress globals

5. React Query Setup
   - QueryClient configured
   - 5-minute stale time
   - Retry on error
   - No refetch on window focus

6. Toast Notifications
   - Sonner toast library
   - Top-right position
   - Rich colors

Tech Stack:
- React 18 + TypeScript
- Vite (port 5174)
- React Router v7
- TanStack Query
- Zustand (state)
- TailwindCSS
- shadcn/ui
- React Hook Form + Zod

Dependencies Installed:
 437 packages installed
 All peer dependencies resolved
 Ready for development

Next Steps (Sprint 2):
- Implement Shop page with product grid
- Create ProductCard component
- Add filters and search
- Implement pagination
- Connect to WordPress API

Ready to run:
```bash
cd customer-spa
npm run dev
# Opens https://woonoow.local:5174
```
2025-11-21 13:53:38 +07:00

99 lines
2.6 KiB
Markdown

# WooNooW Customer SPA
Modern React-based storefront and customer portal for WooNooW.
## Features
- **Product Catalog** - Browse products with filters and search
- **Shopping Cart** - Add to cart with real-time updates
- **Checkout** - Single-page checkout with address autocomplete
- **My Account** - Order history, profile, and addresses
- **Mobile-First** - Responsive design for all devices
- **PWA Ready** - Offline support and app-like experience
## Development
```bash
# Install dependencies
npm install
# Start dev server (https://woonoow.local:5174)
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lint
```
## Project Structure
```
customer-spa/
├── src/
│ ├── pages/ # Page components (Shop, Cart, Checkout, Account)
│ ├── components/ # Reusable UI components
│ ├── lib/
│ │ ├── api/ # API client and endpoints
│ │ ├── cart/ # Cart state management (Zustand)
│ │ ├── checkout/ # Checkout logic
│ │ └── tracking/ # Analytics and pixel tracking
│ ├── hooks/ # Custom React hooks
│ ├── contexts/ # React contexts
│ └── types/ # TypeScript type definitions
├── public/ # Static assets
└── dist/ # Build output (generated)
```
## Tech Stack
- **React 18** - UI framework
- **TypeScript** - Type safety
- **Vite** - Build tool
- **React Router** - Routing
- **TanStack Query** - Data fetching
- **Zustand** - State management
- **TailwindCSS** - Styling
- **shadcn/ui** - UI components
- **React Hook Form** - Form handling
- **Zod** - Schema validation
## API Integration
The SPA communicates with WordPress via REST API endpoints:
- `/wp-json/woonoow/v1/shop/*` - Product catalog
- `/wp-json/woonoow/v1/cart/*` - Shopping cart
- `/wp-json/woonoow/v1/checkout/*` - Checkout process
- `/wp-json/woonoow/v1/account/*` - Customer account
## Deployment Modes
### 1. Shortcode Mode (Default)
Works with any WordPress theme via shortcodes:
- `[woonoow_shop]`
- `[woonoow_cart]`
- `[woonoow_checkout]`
- `[woonoow_account]`
### 2. Full SPA Mode
Takes over entire frontend for maximum performance.
### 3. Hybrid Mode
SSR for product pages (SEO), SPA for cart/checkout/account.
## SEO & Tracking
- **SEO-Friendly** - Server-side rendering for product pages
- **Analytics** - Google Analytics, GTM support
- **Pixels** - Facebook, TikTok, Pinterest pixel support
- **PixelMySite** - Full compatibility
## License
Proprietary - Part of WooNooW plugin