website cleanup
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { useEffectiveDriverId } from '@/hooks/useEffectiveDriverId';
|
||||
import { useNotifications } from '@/components/notifications/NotificationProvider';
|
||||
import type { NotificationVariant } from '@/components/notifications/notificationTypes';
|
||||
import {
|
||||
AlertCircle,
|
||||
AlertTriangle,
|
||||
@@ -104,6 +106,7 @@ type LoginMode = 'none' | 'driver' | 'sponsor';
|
||||
|
||||
export default function DevToolbar() {
|
||||
const router = useRouter();
|
||||
const { addNotification } = useNotifications();
|
||||
const [isExpanded, setIsExpanded] = useState(false);
|
||||
const [isMinimized, setIsMinimized] = useState(false);
|
||||
const [selectedType, setSelectedType] = useState<DemoNotificationType>('protest_filed');
|
||||
@@ -180,6 +183,64 @@ export default function DevToolbar() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const handleSendNotification = async () => {
|
||||
setSending(true);
|
||||
try {
|
||||
const actionUrlByType: Record<DemoNotificationType, string> = {
|
||||
protest_filed: '/races',
|
||||
defense_requested: '/races',
|
||||
vote_required: '/leagues',
|
||||
race_performance_summary: '/races',
|
||||
race_final_results: '/races',
|
||||
};
|
||||
|
||||
const titleByType: Record<DemoNotificationType, string> = {
|
||||
protest_filed: 'Protest Filed Against You',
|
||||
defense_requested: 'Defense Requested',
|
||||
vote_required: 'Vote Required',
|
||||
race_performance_summary: 'Race Performance Summary',
|
||||
race_final_results: 'Race Final Results',
|
||||
};
|
||||
|
||||
const messageByType: Record<DemoNotificationType, string> = {
|
||||
protest_filed: 'A protest has been filed against you. Please review the incident details.',
|
||||
defense_requested: 'A steward requests your defense. Please respond within the deadline.',
|
||||
vote_required: 'A protest vote is pending. Please review and vote.',
|
||||
race_performance_summary: 'Your race is complete. View your provisional results.',
|
||||
race_final_results: 'Stewarding is closed. Your final results are available.',
|
||||
};
|
||||
|
||||
const notificationTypeByDemoType: Record<DemoNotificationType, string> = {
|
||||
protest_filed: 'protest_filed',
|
||||
defense_requested: 'protest_defense_requested',
|
||||
vote_required: 'protest_vote_required',
|
||||
race_performance_summary: 'race_performance_summary',
|
||||
race_final_results: 'race_final_results',
|
||||
};
|
||||
|
||||
const variant: NotificationVariant = selectedUrgency === 'modal' ? 'modal' : 'toast';
|
||||
|
||||
addNotification({
|
||||
type: notificationTypeByDemoType[selectedType],
|
||||
title: titleByType[selectedType],
|
||||
message: messageByType[selectedType],
|
||||
variant,
|
||||
actionUrl: actionUrlByType[selectedType],
|
||||
data: {
|
||||
driverId: currentDriverId,
|
||||
demo: true,
|
||||
},
|
||||
});
|
||||
|
||||
setLastSent(`${selectedType}-${selectedUrgency}`);
|
||||
setTimeout(() => setLastSent(null), 3000);
|
||||
} catch (error) {
|
||||
console.error('Failed to send demo notification:', error);
|
||||
} finally {
|
||||
setSending(false);
|
||||
}
|
||||
};
|
||||
|
||||
// const handleSendNotification = async () => {
|
||||
// setSending(true);
|
||||
// try {
|
||||
@@ -559,4 +620,4 @@ export default function DevToolbar() {
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user