import React, { useState } from 'react'; import { Head } from '@inertiajs/react'; import AdminLayout from '../../../Layouts/AdminLayout'; import { Megaphone, Plus, Trash2, Send, CheckCircle2 } from 'lucide-react'; export default function Announcements() { const [announcements, setAnnouncements] = useState([ { id: 1, title: 'New Visa Regulations Update', content: 'The Ministry of Human Resources and Emiratisation has announced updated guidelines for domestic worker sponsorship starting this month.', audience: 'Both', created_at: 'May 10, 2026', }, { id: 2, title: 'Enhanced OCR Verification Active', content: 'We have deployed upgraded OCR passport verification to ensure 100% legal compliance for all worker profiles on the platform.', audience: 'Employers', created_at: 'May 1, 2026', }, ]); const [isFormOpen, setIsFormOpen] = useState(false); const [newAnnouncement, setNewAnnouncement] = useState({ title: '', content: '', audience: 'Both' }); const [toastMessage, setToastMessage] = useState(null); const showToast = (message) => { setToastMessage(message); setTimeout(() => setToastMessage(null), 3000); }; const handleCreate = (e) => { e.preventDefault(); const newEntry = { id: announcements.length + 1, title: newAnnouncement.title, content: newAnnouncement.content, audience: newAnnouncement.audience, created_at: 'Just now', }; setAnnouncements([newEntry, ...announcements]); setNewAnnouncement({ title: '', content: '', audience: 'Both' }); setIsFormOpen(false); showToast('Announcement sent successfully'); }; const handleDelete = (id) => { setAnnouncements(announcements.filter(a => a.id !== id)); showToast('Announcement deleted'); }; return ( {/* Toast Notification */} {toastMessage && (
{toastMessage}
)}

Platform Announcements

Broadcast messages to employers and workers.

{isFormOpen && (

Compose Message

setNewAnnouncement({ ...newAnnouncement, title: e.target.value })} className="w-full px-4 py-2.5 rounded-xl border border-slate-300 text-sm focus:ring-2 focus:ring-[#185FA5]/20 focus:border-[#185FA5] outline-none transition-all" placeholder="Enter announcement title..." />
)}
{announcements.length === 0 ? (

No announcements published yet.

) : ( announcements.map((ann) => (

{ann.title}

To: {ann.audience}

{ann.content}

Published: {ann.created_at}
)) )}
); }