Toast notification au lieu de alert pour renvoi invitation
This commit is contained in:
@@ -9,6 +9,7 @@ export default function GuestsList() {
|
||||
const [filterDate, setFilterDate] = useState('all')
|
||||
const [search, setSearch] = useState('')
|
||||
const [myOnly, setMyOnly] = useState(false)
|
||||
const [toast, setToast] = useState(null)
|
||||
|
||||
const load = () => {
|
||||
authFetch('/api/guests').then((r) => (r.ok ? r.json() : [])).then(setGuests)
|
||||
@@ -25,11 +26,13 @@ export default function GuestsList() {
|
||||
const handleSendInvitation = async (id) => {
|
||||
const r = await authFetch(`/api/guests/${id}/send-invitation`, { method: 'POST' })
|
||||
if (r.ok) {
|
||||
alert('Email envoyé avec succès !')
|
||||
setToast("L'invitation a bien été renvoyée" )
|
||||
setTimeout(() => setToast(null), 3000)
|
||||
load()
|
||||
} else {
|
||||
const err = await r.json()
|
||||
alert(err.error || "Erreur lors de l'envoi")
|
||||
setToast(err.error || "Erreur lors de l'envoi")
|
||||
setTimeout(() => setToast(null), 3000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +178,11 @@ export default function GuestsList() {
|
||||
))}
|
||||
{sortedDates.length === 0 && <p className="text-center text-gray-400 py-8">{myOnly ? 'Aucun invité de votre part' : 'Aucun invite pour cette periode'}</p>}
|
||||
</div>
|
||||
{toast && (
|
||||
<div className="fixed bottom-6 left-1/2 -translate-x-1/2 bg-emerald-600 text-white px-6 py-3 rounded-xl shadow-lg text-sm font-medium z-50 animate-fadeIn">
|
||||
{toast}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user