diff --git a/admin-spa/src/routes/Settings/Notifications/Customer.tsx b/admin-spa/src/routes/Settings/Notifications/Customer.tsx index a18fac5..55924b5 100644 --- a/admin-spa/src/routes/Settings/Notifications/Customer.tsx +++ b/admin-spa/src/routes/Settings/Notifications/Customer.tsx @@ -7,7 +7,6 @@ import { __ } from '@/lib/i18n'; import { ChevronLeft } from 'lucide-react'; import CustomerChannels from './Customer/Channels'; import CustomerEvents from './Customer/Events'; -import NotificationTemplates from './Templates'; export default function CustomerNotifications() { const [searchParams] = useSearchParams(); @@ -16,7 +15,7 @@ export default function CustomerNotifications() { // Check for tab query param useEffect(() => { const tabParam = searchParams.get('tab'); - if (tabParam && ['channels', 'events', 'templates'].includes(tabParam)) { + if (tabParam && ['channels', 'events'].includes(tabParam)) { setActiveTab(tabParam); } }, [searchParams]); @@ -35,10 +34,9 @@ export default function CustomerNotifications() { } > - + {__('Channels')} {__('Events')} - {__('Templates')} @@ -48,10 +46,6 @@ export default function CustomerNotifications() { - - - - ); diff --git a/admin-spa/src/routes/Settings/Notifications/Customer/Events.tsx b/admin-spa/src/routes/Settings/Notifications/Customer/Events.tsx index 63c82dc..592e13e 100644 --- a/admin-spa/src/routes/Settings/Notifications/Customer/Events.tsx +++ b/admin-spa/src/routes/Settings/Notifications/Customer/Events.tsx @@ -1,11 +1,12 @@ import React from 'react'; +import { useNavigate } from 'react-router-dom'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { api } from '@/lib/api'; import { SettingsCard } from '../../components/SettingsCard'; import { Switch } from '@/components/ui/switch'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; -import { RefreshCw, Mail, MessageCircle, Send, Bell } from 'lucide-react'; +import { RefreshCw, Mail, MessageCircle, Send, Bell, Settings } from 'lucide-react'; import { toast } from 'sonner'; import { __ } from '@/lib/i18n'; @@ -33,6 +34,7 @@ interface NotificationChannel { } export default function CustomerEvents() { + const navigate = useNavigate(); const queryClient = useQueryClient(); // Fetch customer events @@ -90,6 +92,10 @@ export default function CustomerEvents() { }); }; + const openTemplateEditor = (eventId: string, channelId: string) => { + navigate(`/settings/notifications/edit-template?event=${eventId}&channel=${channelId}&recipient=customer`); + }; + if (eventsLoading || channelsLoading) { return (
@@ -147,11 +153,23 @@ export default function CustomerEvents() { )}
- handleToggle(event.id, channel.id, isEnabled, recipient)} - disabled={updateMutation.isPending} - /> +
+ {isEnabled && channel.enabled && ( + + )} + handleToggle(event.id, channel.id, isEnabled, recipient)} + disabled={updateMutation.isPending} + /> +
); })} diff --git a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx index 27d0f8b..ed96fb9 100644 --- a/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx +++ b/admin-spa/src/routes/Settings/Notifications/EditTemplate.tsx @@ -423,7 +423,7 @@ export default function EditTemplate() { // Determine if staff or customer based on event category const isStaffEvent = template.event_category === 'staff' || eventId?.includes('admin') || eventId?.includes('staff'); const page = isStaffEvent ? 'staff' : 'customer'; - navigate(`/settings/notifications/${page}?tab=templates`); + navigate(`/settings/notifications/${page}?tab=events`); }} className="gap-2" title={__('Back')} diff --git a/admin-spa/src/routes/Settings/Notifications/Staff.tsx b/admin-spa/src/routes/Settings/Notifications/Staff.tsx index d10c160..af3f27e 100644 --- a/admin-spa/src/routes/Settings/Notifications/Staff.tsx +++ b/admin-spa/src/routes/Settings/Notifications/Staff.tsx @@ -7,7 +7,6 @@ import { __ } from '@/lib/i18n'; import { ChevronLeft } from 'lucide-react'; import StaffChannels from './Staff/Channels'; import StaffEvents from './Staff/Events'; -import NotificationTemplates from './Templates'; export default function StaffNotifications() { const [searchParams] = useSearchParams(); @@ -16,7 +15,7 @@ export default function StaffNotifications() { // Check for tab query param useEffect(() => { const tabParam = searchParams.get('tab'); - if (tabParam && ['channels', 'events', 'templates'].includes(tabParam)) { + if (tabParam && ['channels', 'events'].includes(tabParam)) { setActiveTab(tabParam); } }, [searchParams]); @@ -35,10 +34,9 @@ export default function StaffNotifications() { } > - + {__('Channels')} {__('Events')} - {__('Templates')} @@ -48,10 +46,6 @@ export default function StaffNotifications() { - - - - ); diff --git a/admin-spa/src/routes/Settings/Notifications/Staff/Events.tsx b/admin-spa/src/routes/Settings/Notifications/Staff/Events.tsx index 6f433e1..55c3bc8 100644 --- a/admin-spa/src/routes/Settings/Notifications/Staff/Events.tsx +++ b/admin-spa/src/routes/Settings/Notifications/Staff/Events.tsx @@ -1,11 +1,12 @@ import React from 'react'; +import { useNavigate } from 'react-router-dom'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { api } from '@/lib/api'; import { SettingsCard } from '../../components/SettingsCard'; import { Switch } from '@/components/ui/switch'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; -import { RefreshCw, Mail, MessageCircle, Send, Bell } from 'lucide-react'; +import { RefreshCw, Mail, MessageCircle, Send, Bell, Settings } from 'lucide-react'; import { toast } from 'sonner'; import { __ } from '@/lib/i18n'; @@ -33,6 +34,7 @@ interface NotificationChannel { } export default function NotificationEvents() { + const navigate = useNavigate(); const queryClient = useQueryClient(); // Fetch staff events @@ -88,6 +90,10 @@ export default function NotificationEvents() { }); }; + const openTemplateEditor = (eventId: string, channelId: string) => { + navigate(`/settings/notifications/edit-template?event=${eventId}&channel=${channelId}&recipient=staff`); + }; + if (eventsLoading || channelsLoading) { return (
@@ -166,11 +172,23 @@ export default function NotificationEvents() { )}
- toggleChannel(event.id, channel.id, channelEnabled)} - disabled={!channel.enabled || updateMutation.isPending} - /> +
+ {channelEnabled && channel.enabled && ( + + )} + toggleChannel(event.id, channel.id, channelEnabled)} + disabled={!channel.enabled || updateMutation.isPending} + /> +
); })} @@ -225,11 +243,23 @@ export default function NotificationEvents() { )} - toggleChannel(event.id, channel.id, channelEnabled)} - disabled={!channel.enabled || updateMutation.isPending} - /> +
+ {channelEnabled && channel.enabled && ( + + )} + toggleChannel(event.id, channel.id, channelEnabled)} + disabled={!channel.enabled || updateMutation.isPending} + /> +
); })} @@ -284,11 +314,23 @@ export default function NotificationEvents() { )} - toggleChannel(event.id, channel.id, channelEnabled)} - disabled={!channel.enabled || updateMutation.isPending} - /> +
+ {channelEnabled && channel.enabled && ( + + )} + toggleChannel(event.id, channel.id, channelEnabled)} + disabled={!channel.enabled || updateMutation.isPending} + /> +
); })}