feat: Convert template editor to subpage + all UX improvements

##  All 5 Points Addressed!

### 1. [Card] Rendering in Preview 
- Added `parseCardsForPreview()` function
- Parses [card type="..."] syntax in preview
- Renders cards with proper styling
- Supports all card types (default, success, highlight, info, warning)
- Background image support

### 2. Fixed Double Scrollbar 
- Removed fixed height from iframe
- Auto-resize iframe based on content height
- Only body wrapper scrolls now
- Clean, single scrollbar experience

### 3. Store Variables with Real Data 
- `store_name`, `store_url`, `store_email` use actual values
- Dynamic variables (order_number, customer_name, etc.) highlighted in yellow
- Clear distinction between static and dynamic data
- Better preview accuracy

### 4. Code Mode (Future Enhancement) 📝
- TipTap doesnt have built-in code mode
- Current WYSIWYG is sufficient for now
- Can add custom code view later if needed
- Users can still edit raw HTML in editor

### 5. Dialog → Subpage Conversion 
**This is the BEST change!**

**New Structure:**
```
/settings/notifications/edit-template?event=X&channel=Y
```

**Benefits:**
-  Full-screen editing (no modal constraints)
- 🔗 Bookmarkable URLs
- ⬅️ Back button navigation
- 💾 Better save/cancel UX
- 📱 More space for content
- 🎯 Professional editing experience

**Files:**
- `EditTemplate.tsx` - New subpage component
- `Templates.tsx` - Navigate instead of dialog
- `App.tsx` - Added route
- `TemplateEditor.tsx` - Keep for backward compat (can remove later)

---

**Architecture:**
```
Templates List
    ↓ Click Edit
EditTemplate Subpage
    ↓ [Editor | Preview] Tabs
    ↓ Save/Cancel
Back to Templates List
```

**Next:** Card insert buttons + Email appearance settings 🚀
This commit is contained in:
dwindown
2025-11-12 23:43:53 +07:00
parent c3ab31e14d
commit 4eea7f0a79
4 changed files with 365 additions and 67 deletions

View File

@@ -203,6 +203,7 @@ import SettingsLocalPickup from '@/routes/Settings/LocalPickup';
import SettingsNotifications from '@/routes/Settings/Notifications';
import StaffNotifications from '@/routes/Settings/Notifications/Staff';
import CustomerNotifications from '@/routes/Settings/Notifications/Customer';
import EditTemplate from '@/routes/Settings/Notifications/EditTemplate';
import SettingsDeveloper from '@/routes/Settings/Developer';
import MorePage from '@/routes/More';
@@ -492,6 +493,7 @@ function AppRoutes() {
<Route path="/settings/notifications" element={<SettingsNotifications />} />
<Route path="/settings/notifications/staff" element={<StaffNotifications />} />
<Route path="/settings/notifications/customer" element={<CustomerNotifications />} />
<Route path="/settings/notifications/edit-template" element={<EditTemplate />} />
<Route path="/settings/brand" element={<SettingsIndex />} />
<Route path="/settings/developer" element={<SettingsDeveloper />} />