fix: Match Customer Channels to Staff layout and fix event filtering

## 🐛 Bug Fixes

### Customer/Channels.tsx
-  Matched layout to Staff Channels
-  Added "Extend with Addons" section
-  WhatsApp, Telegram, SMS addon cards
-  Consistent UI with Staff page
-  Removed confusing SMS "Coming Soon" inline card

### NotificationsController.php
-  Fixed `get_staff_events()` filtering logic
-  Fixed `get_customer_events()` filtering logic
-  Now uses `recipient_type` field instead of `reset()` on channels
-  Customer events will now show correctly

### Issues Fixed
1.  Customer Channels inconsistent with Staff →  Now matches
2.  Customer Events showing "No Events" →  Now filters correctly

---

**Result:** Both Staff and Customer pages now have consistent UI and working event filtering! 🎉
This commit is contained in:
dwindown
2025-11-11 20:29:24 +07:00
parent 24307a0fc9
commit aea1f48d5d
3 changed files with 197 additions and 80 deletions

View File

@@ -317,12 +317,11 @@ class NotificationsController {
public function get_staff_events(WP_REST_Request $request) {
$all_events = $this->get_all_events();
// Filter events where default recipient is 'admin' or 'staff'
// Filter events where recipient_type is 'staff'
$staff_events = [];
foreach ($all_events as $category => $events) {
$filtered = array_filter($events, function($event) {
$first_channel = reset($event['channels']);
return in_array($first_channel['recipient'] ?? 'admin', ['admin', 'staff']);
return ($event['recipient_type'] ?? 'staff') === 'staff';
});
if (!empty($filtered)) {
@@ -342,12 +341,11 @@ class NotificationsController {
public function get_customer_events(WP_REST_Request $request) {
$all_events = $this->get_all_events();
// Filter events where default recipient is 'customer'
// Filter events where recipient_type is 'customer'
$customer_events = [];
foreach ($all_events as $category => $events) {
$filtered = array_filter($events, function($event) {
$first_channel = reset($event['channels']);
return ($first_channel['recipient'] ?? 'admin') === 'customer';
return ($event['recipient_type'] ?? 'staff') === 'customer';
});
if (!empty($filtered)) {