dwindown
|
26eb7cb898
|
feat: Implement push notification settings backend and UI
## ✅ Push Notification Settings - Fully Functional
### Backend (PHP)
**PushNotificationHandler Updates:**
- Added `SETTINGS_KEY` constant
- `ensure_default_settings()` - Initialize defaults
- `get_default_settings()` - Return default config
- `get_settings()` - Fetch current settings
- `update_settings()` - Save settings
**Default Settings:**
```php
[
'use_logo' => true,
'use_product_images' => true,
'use_gravatar' => false,
'click_action' => '/wp-admin/admin.php?page=woonoow#/orders',
'require_interaction' => false,
'silent' => false,
]
```
**NotificationsController:**
- `GET /notifications/push/settings` - Fetch settings
- `POST /notifications/push/settings` - Update settings
- Permission-protected endpoints
### Frontend (React)
**ChannelConfig Component:**
- Fetches push settings on open
- Real-time state management
- Connected switches and inputs
- Save mutation with loading state
- Toast notifications for success/error
- Disabled state during save
**Settings Available:**
1. **Branding**
- Use Store Logo
- Use Product Images
- Use Customer Gravatar
2. **Behavior**
- Click Action URL (input)
- Require Interaction
- Silent Notifications
### Features
✅ **Backend Storage** - Settings saved in wp_options
✅ **REST API** - GET and POST endpoints
✅ **Frontend UI** - Full CRUD interface
✅ **State Management** - React Query integration
✅ **Loading States** - Skeleton and button states
✅ **Error Handling** - Toast notifications
✅ **Default Values** - Sensible defaults
---
**Next: Email channel toggle** 📧
|
2025-11-11 15:15:02 +07:00 |
|
dwindown
|
200245491f
|
fix: Perfect notification system UX improvements
## 🎯 All 5 Issues Fixed
### Issue 1: Channel toggles work independently ✅
- Each channel toggle works independently
- No automatic disabling of other channels
- Backend already handles this correctly
### Issue 2: Push subscription state fixed ✅
- Added proper VAPID key conversion (urlBase64ToUint8Array)
- Better service worker registration handling
- Improved error logging
- State updates correctly after subscription
### Issue 3: Removed Push from addon discovery ✅
- Push Notifications removed from "Extend with Addons" section
- Only shows WhatsApp, Telegram, and SMS
- Push is clearly shown as built-in channel
### Issue 4: Templates page now uses accordion ✅
- Collapsed by default to save space
- Shows template count per channel
- Shows custom template count badge
- Expands on click to show all templates
- Much more scalable for 5+ channels
### Issue 5: Configure button opens channel-specific settings ✅
- **Email**: Redirects to WooCommerce email settings
- SMTP configuration
- Email templates
- Sender settings
- **Push Notifications**: Custom configuration dialog
- Branding options (logo, product images, gravatar)
- Behavior settings (click action, require interaction, silent)
- Visual configuration UI
- **Addon Channels**: Generic configuration dialog
- Ready for addon-specific settings
## New Components
**ChannelConfig.tsx** - Smart configuration dialog:
- Detects channel type
- Email → WooCommerce redirect
- Push → Custom settings UI
- Addons → Extensible placeholder
## UI Improvements
**Templates Page:**
- Accordion with channel icons
- Badge showing total templates
- Badge showing custom count
- Cleaner, more compact layout
**Channels Page:**
- Configure button for all channels
- Push subscription toggle
- Better state management
- Channel-specific configuration
---
**All UX issues resolved!** 🎉
|
2025-11-11 14:22:12 +07:00 |
|