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 ```
This commit is contained in:
51
customer-spa/src/App.tsx
Normal file
51
customer-spa/src/App.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import React from 'react';
|
||||
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { Toaster } from 'sonner';
|
||||
|
||||
// Pages (will be created)
|
||||
import Shop from './pages/Shop';
|
||||
import Product from './pages/Product';
|
||||
import Cart from './pages/Cart';
|
||||
import Checkout from './pages/Checkout';
|
||||
import Account from './pages/Account';
|
||||
|
||||
// Create QueryClient instance
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
staleTime: 1000 * 60 * 5, // 5 minutes
|
||||
refetchOnWindowFocus: false,
|
||||
retry: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BrowserRouter basename="/shop">
|
||||
<Routes>
|
||||
{/* Shop Routes */}
|
||||
<Route path="/" element={<Shop />} />
|
||||
<Route path="/product/:id" element={<Product />} />
|
||||
|
||||
{/* Cart & Checkout */}
|
||||
<Route path="/cart" element={<Cart />} />
|
||||
<Route path="/checkout" element={<Checkout />} />
|
||||
|
||||
{/* My Account */}
|
||||
<Route path="/account/*" element={<Account />} />
|
||||
|
||||
{/* Fallback */}
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
|
||||
{/* Toast notifications */}
|
||||
<Toaster position="top-right" richColors />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
Reference in New Issue
Block a user