2025-05-25 21:43:42 +02:00
|
|
|
import { Bell, CheckCircle2, Clock, X } from "lucide-react"
|
|
|
|
|
import useNotifications from "@/hooks/useNotifications";
|
|
|
|
|
import { useState } from "react";
|
|
|
|
|
import { useEffect } from "react";
|
|
|
|
|
|
|
|
|
|
interface TestNotificationProps {
|
|
|
|
|
notificationTestId: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function TestNotification({ notificationTestId }: TestNotificationProps) {
|
|
|
|
|
|
|
|
|
|
const { getNotificationTest, notificationTest } = useNotifications();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const checkNotificationTest = async () => {
|
|
|
|
|
console.log(notificationTestId);
|
|
|
|
|
await getNotificationTest(notificationTestId);
|
|
|
|
|
}
|
2025-05-25 21:03:37 +02:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<dialog id="test_notification" className="modal">
|
2025-05-25 21:13:35 +02:00
|
|
|
<div className="modal-box w-11/12 max-w-3xl border-l-4 border-success bg-base-100 shadow-xl">
|
|
|
|
|
<div className="flex items-center gap-4 mb-6">
|
|
|
|
|
<div className="bg-success/10 text-success rounded-full p-3 flex items-center justify-center">
|
|
|
|
|
<Bell className="h-7 w-7" />
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<h3 className="font-bold text-2xl">Test Notification</h3>
|
|
|
|
|
<p className="text-sm text-base-content/70">Verify your notification settings</p>
|
2025-05-25 21:03:37 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-25 21:13:35 +02:00
|
|
|
<div className="bg-base-200/50 p-6 rounded-xl mb-6">
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
<p className="text-base-content/90">
|
|
|
|
|
A notification test has been sent to the selected notification provider.
|
|
|
|
|
</p>
|
|
|
|
|
<p className="text-sm text-base-content/70">
|
|
|
|
|
You can click the button below to check the status of the notification test.
|
|
|
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-3 mt-6">
|
2025-05-25 21:43:42 +02:00
|
|
|
<button className="btn btn-success gap-2" onClick={checkNotificationTest}>
|
2025-05-25 21:13:35 +02:00
|
|
|
<Clock className="h-4 w-4" />
|
|
|
|
|
Check Status
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center gap-2 px-4 py-2 bg-base-300 rounded-lg">
|
|
|
|
|
<span className="text-sm font-medium">Status:</span>
|
2025-05-25 21:43:42 +02:00
|
|
|
{!notificationTest?.sent && !notificationTest?.success && (
|
2025-05-25 21:13:35 +02:00
|
|
|
<div className="flex items-center gap-1.5 text-warning">
|
|
|
|
|
<Clock className="h-4 w-4" />
|
2025-05-25 21:43:42 +02:00
|
|
|
<span className="text-sm">Pending</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{notificationTest?.sent && !notificationTest?.success && (
|
|
|
|
|
<div className="flex items-center gap-1.5 text-error">
|
|
|
|
|
<X className="h-4 w-4" />
|
|
|
|
|
<span className="text-sm">Failed</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
{notificationTest?.sent && notificationTest?.success && (
|
|
|
|
|
<div className="flex items-center gap-1.5 text-success">
|
|
|
|
|
<CheckCircle2 className="h-4 w-4" />
|
|
|
|
|
<span className="text-sm">Success</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2025-05-25 21:13:35 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-05-25 21:03:37 +02:00
|
|
|
</div>
|
2025-05-25 21:43:42 +02:00
|
|
|
<div className="modal-action">
|
|
|
|
|
<form method="dialog" className="flex gap-3 w-full justify-end">
|
|
|
|
|
<button className="btn btn-outline">Close</button>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2025-05-25 21:03:37 +02:00
|
|
|
</div>
|
|
|
|
|
</dialog>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|