Test Notification Processing in agent

This commit is contained in:
headlessdev
2025-04-23 21:34:52 +02:00
parent b2c47a07a6
commit 861eab8050
5 changed files with 154 additions and 25 deletions

View File

@@ -19,7 +19,9 @@ import axios from "axios"
import Cookies from "js-cookie"
import { Button } from "@/components/ui/button"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { AlertCircle, Check, Palette, User, Bell, AtSign, Send, MessageSquare, Trash2 } from "lucide-react"
import { AlertCircle, Check, Palette, User, Bell, AtSign, Send, MessageSquare, Trash2, Play } from "lucide-react"
import { Toaster } from "@/components/ui/sonner"
import { toast } from "sonner"
import {
AlertDialog,
@@ -254,6 +256,17 @@ export default function Settings() {
getNotificationText()
}, [])
const testNotification = async (id: number) => {
try {
const response = await axios.post("/api/notifications/test", {
notificationId: id,
})
toast.success("Notification will be sent in a few seconds.")
} catch (error: any) {
toast.error(error.response.data.error)
}
}
return (
<SidebarProvider>
<AppSidebar />
@@ -763,15 +776,25 @@ export default function Settings() {
</p>
</div>
</div>
<Button
variant="ghost"
size="sm"
className="hover:bg-muted/20"
onClick={() => deleteNotification(notification.id)}
>
<Trash2 className="h-4 w-4 mr-1" />
Remove
</Button>
<div className="flex items-center gap-2">
<Button
variant="outline"
size="sm"
className="hover:bg-muted/20"
onClick={() => testNotification(notification.id)}
>
<Play className="h-4 w-4 mr-1" />
Test
</Button>
<Button
variant="ghost"
size="sm"
className="hover:bg-muted/20"
onClick={() => deleteNotification(notification.id)}
>
<Trash2 className="h-4 w-4 mr-1" />
</Button>
</div>
</div>
))
) : (
@@ -789,6 +812,7 @@ export default function Settings() {
)}
</div>
</div>
<Toaster />
</CardContent>
</Card>
</div>