Notification Name

This commit is contained in:
headlessdev 2025-04-27 14:56:40 +02:00
parent 807d4d6ca9
commit 65f8e16fbc

View File

@ -62,6 +62,7 @@ export default function Settings() {
const [emailSuccess, setEmailSuccess] = useState<boolean>(false) const [emailSuccess, setEmailSuccess] = useState<boolean>(false)
const [notificationType, setNotificationType] = useState<string>("") const [notificationType, setNotificationType] = useState<string>("")
const [notificationName, setNotificationName] = useState<string>("")
const [smtpHost, setSmtpHost] = useState<string>("") const [smtpHost, setSmtpHost] = useState<string>("")
const [smtpPort, setSmtpPort] = useState<number>(0) const [smtpPort, setSmtpPort] = useState<number>(0)
const [smtpSecure, setSmtpSecure] = useState<boolean>(false) const [smtpSecure, setSmtpSecure] = useState<boolean>(false)
@ -168,6 +169,7 @@ export default function Settings() {
const addNotification = async () => { const addNotification = async () => {
try { try {
const response = await axios.post("/api/notifications/add", { const response = await axios.post("/api/notifications/add", {
name: notificationName,
type: notificationType, type: notificationType,
smtpHost: smtpHost, smtpHost: smtpHost,
smtpPort: smtpPort, smtpPort: smtpPort,
@ -450,6 +452,13 @@ export default function Settings() {
<AlertDialogContent> <AlertDialogContent>
<AlertDialogTitle>Add Notification</AlertDialogTitle> <AlertDialogTitle>Add Notification</AlertDialogTitle>
<AlertDialogDescription> <AlertDialogDescription>
<div className="space-y-4">
<Input
type="text"
id="notificationName"
placeholder="Notification Name (optional)"
onChange={(e) => setNotificationName(e.target.value)}
/>
<Select value={notificationType} onValueChange={(value: string) => setNotificationType(value)}> <Select value={notificationType} onValueChange={(value: string) => setNotificationType(value)}>
<SelectTrigger className="w-full"> <SelectTrigger className="w-full">
<SelectValue placeholder="Notification Type" /> <SelectValue placeholder="Notification Type" />
@ -656,6 +665,7 @@ export default function Settings() {
</div> </div>
)} )}
</Select> </Select>
</div>
</AlertDialogDescription> </AlertDialogDescription>
<AlertDialogFooter> <AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogCancel>Cancel</AlertDialogCancel>
@ -765,7 +775,7 @@ export default function Settings() {
</div> </div>
)} )}
<div className="space-y-1"> <div className="space-y-1">
<h3 className="font-medium capitalize">{notification.type}</h3> <h3 className="font-medium capitalize">{notification.name && notification.name !== "" ? notification.name : notification.type}</h3>
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground">
{notification.type === "smtp" && "Email notifications"} {notification.type === "smtp" && "Email notifications"}
{notification.type === "telegram" && "Telegram bot alerts"} {notification.type === "telegram" && "Telegram bot alerts"}