feat: add customer login page in SPA
- Created Login/index.tsx with styled form - Added /auth/customer-login API endpoint (no admin perms required) - Registered route in Routes.php - Added /login route in customer-spa App.tsx - Account page now redirects to SPA login instead of wp-login.php - Login supports redirect param for post-login navigation
This commit is contained in:
@@ -15,6 +15,7 @@ import Checkout from './pages/Checkout';
|
||||
import ThankYou from './pages/ThankYou';
|
||||
import Account from './pages/Account';
|
||||
import Wishlist from './pages/Wishlist';
|
||||
import Login from './pages/Login';
|
||||
|
||||
// Create QueryClient instance
|
||||
const queryClient = new QueryClient({
|
||||
@@ -30,7 +31,7 @@ const queryClient = new QueryClient({
|
||||
// Get theme config from window (injected by PHP)
|
||||
const getThemeConfig = () => {
|
||||
const config = (window as any).woonoowCustomer?.theme;
|
||||
|
||||
|
||||
// Default config if not provided
|
||||
return config || {
|
||||
mode: 'full',
|
||||
@@ -65,28 +66,31 @@ const getInitialRoute = () => {
|
||||
function AppRoutes() {
|
||||
const initialRoute = getInitialRoute();
|
||||
console.log('[WooNooW Customer] Using initial route:', initialRoute);
|
||||
|
||||
|
||||
return (
|
||||
<BaseLayout>
|
||||
<Routes>
|
||||
{/* Root route redirects to initial route based on SPA mode */}
|
||||
<Route path="/" element={<Navigate to={initialRoute} replace />} />
|
||||
|
||||
|
||||
{/* Shop Routes */}
|
||||
<Route path="/shop" element={<Shop />} />
|
||||
<Route path="/product/:slug" element={<Product />} />
|
||||
|
||||
|
||||
{/* Cart & Checkout */}
|
||||
<Route path="/cart" element={<Cart />} />
|
||||
<Route path="/checkout" element={<Checkout />} />
|
||||
<Route path="/order-received/:orderId" element={<ThankYou />} />
|
||||
|
||||
|
||||
{/* Wishlist - Public route accessible to guests */}
|
||||
<Route path="/wishlist" element={<Wishlist />} />
|
||||
|
||||
|
||||
{/* Login */}
|
||||
<Route path="/login" element={<Login />} />
|
||||
|
||||
{/* My Account */}
|
||||
<Route path="/my-account/*" element={<Account />} />
|
||||
|
||||
|
||||
{/* Fallback to initial route */}
|
||||
<Route path="*" element={<Navigate to={initialRoute} replace />} />
|
||||
</Routes>
|
||||
@@ -98,14 +102,14 @@ function App() {
|
||||
const themeConfig = getThemeConfig();
|
||||
const appearanceSettings = getAppearanceSettings();
|
||||
const toastPosition = (appearanceSettings?.general?.toast_position || 'top-right') as any;
|
||||
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<ThemeProvider config={themeConfig}>
|
||||
<HashRouter>
|
||||
<AppRoutes />
|
||||
</HashRouter>
|
||||
|
||||
|
||||
{/* Toast notifications - position from settings */}
|
||||
<Toaster position={toastPosition} richColors />
|
||||
</ThemeProvider>
|
||||
|
||||
Reference in New Issue
Block a user