# HashRouter Fixes Complete
**Date:** Nov 26, 2025 2:59 PM GMT+7
---
## โ
Issues Fixed
### 1. View Cart Button in Toast - HashRouter Compatible
**Problem:** Toast "View Cart" button was using `window.location.href` which doesn't work with HashRouter.
**Files Fixed:**
- `customer-spa/src/pages/Shop/index.tsx`
- `customer-spa/src/pages/Product/index.tsx`
**Changes:**
```typescript
// Before (Shop page)
onClick: () => window.location.href = '/cart'
// After
onClick: () => navigate('/cart')
```
**Added:** `useNavigate` import from `react-router-dom`
---
### 2. Header Links - HashRouter Compatible
**Problem:** All header links were using `` which causes full page reload instead of client-side navigation.
**File Fixed:**
- `customer-spa/src/layouts/BaseLayout.tsx`
**Changes:**
**All Layouts Fixed:**
- Classic Layout
- Modern Layout
- Boutique Layout
- Launch Layout
**Before:**
```tsx
Cart
Account
Shop
```
**After:**
```tsx
Cart
Account
Shop
```
**Added:** `import { Link } from 'react-router-dom'`
---
### 3. Store Logo โ Store Title
**Problem:** Header showed "Store Logo" placeholder text instead of actual site title.
**File Fixed:**
- `customer-spa/src/layouts/BaseLayout.tsx`
**Changes:**
**Before:**
```tsx
Store Logo
```
**After:**
```tsx
{(window as any).woonoowCustomer?.siteTitle || 'Store Title'}
```
**Behavior:**
- Shows actual site title from `window.woonoowCustomer.siteTitle`
- Falls back to "Store Title" if not set
- Consistent with Admin SPA behavior
---
### 4. Clear Cart Dialog - Modern UI
**Problem:** Cart page was using raw browser `confirm()` alert for Clear Cart confirmation.
**Files:**
- Created: `customer-spa/src/components/ui/dialog.tsx`
- Updated: `customer-spa/src/pages/Cart/index.tsx`
**Changes:**
**Dialog Component:**
- Copied from Admin SPA
- Uses Radix UI Dialog primitive
- Modern, accessible UI
- Consistent with Admin SPA
**Cart Page:**
```typescript
// Before
const handleClearCart = () => {
if (window.confirm('Are you sure?')) {
clearCart();
}
};
// After
const [showClearDialog, setShowClearDialog] = useState(false);
const handleClearCart = () => {
clearCart();
setShowClearDialog(false);
toast.success('Cart cleared');
};
// Dialog UI
```
---
## ๐ Summary
| Issue | Status | Files Modified |
|-------|--------|----------------|
| **View Cart Toast** | โ
Fixed | Shop.tsx, Product.tsx |
| **Header Links** | โ
Fixed | BaseLayout.tsx (all layouts) |
| **Store Title** | โ
Fixed | BaseLayout.tsx (all layouts) |
| **Clear Cart Dialog** | โ
Fixed | dialog.tsx (new), Cart.tsx |
---
## ๐งช Testing
### Test View Cart Button
1. Add product to cart from shop page
2. Click "View Cart" in toast
3. Should navigate to `/shop#/cart` (no page reload)
### Test Header Links
1. Click "Cart" in header
2. Should navigate to `/shop#/cart` (no page reload)
3. Click "Shop" in header
4. Should navigate to `/shop#/` (no page reload)
5. Click "Account" in header
6. Should navigate to `/shop#/my-account` (no page reload)
### Test Store Title
1. Check header shows site title (not "Store Logo")
2. If no title set, shows "Store Title"
3. Title is clickable and navigates to shop
### Test Clear Cart Dialog
1. Add items to cart
2. Click "Clear Cart" button
3. Should show dialog (not browser alert)
4. Click "Cancel" - dialog closes, cart unchanged
5. Click "Clear Cart" - dialog closes, cart cleared, toast shows
---
## ๐ฏ Benefits
### HashRouter Navigation
- โ
No page reloads
- โ
Faster navigation
- โ
Better UX
- โ
Preserves SPA state
- โ
Works with direct URLs
### Modern Dialog
- โ
Better UX than browser alert
- โ
Accessible (keyboard navigation)
- โ
Consistent with Admin SPA
- โ
Customizable styling
- โ
Animation support
### Store Title
- โ
Shows actual site name
- โ
Professional appearance
- โ
Consistent with Admin SPA
- โ
Configurable
---
## ๐ Notes
1. **All header links now use HashRouter** - Consistent navigation throughout
2. **Dialog component available** - Can be reused for other confirmations
3. **Store title dynamic** - Reads from `window.woonoowCustomer.siteTitle`
4. **No breaking changes** - All existing functionality preserved
---
## ๐ Next Steps
Continue with:
1. Debug cart page access issue
2. Add product variations support
3. Build checkout page
**All HashRouter-related issues are now resolved!** โ