From 70010ce8ee3e708c9c56d48949c9ab5d6f384b5d Mon Sep 17 00:00:00 2001 From: headlessdev Date: Thu, 17 Apr 2025 17:27:01 +0200 Subject: [PATCH] Set Notification Text Functionality --- app/dashboard/settings/Settings.tsx | 54 +++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/app/dashboard/settings/Settings.tsx b/app/dashboard/settings/Settings.tsx index 98ed016..32edb68 100644 --- a/app/dashboard/settings/Settings.tsx +++ b/app/dashboard/settings/Settings.tsx @@ -53,6 +53,9 @@ import { Textarea } from "@/components/ui/textarea"; interface NotificationsResponse { notifications: any[]; } +interface NotificationResponse { + notification_text?: string; +} export default function Settings() { const { theme, setTheme } = useTheme(); @@ -84,6 +87,8 @@ export default function Settings() { const [notifications, setNotifications] = useState([]) + const [notificationText, setNotificationText] = useState("") + const changeEmail = async () => { setEmailErrorVisible(false); setEmailSuccess(false); @@ -217,6 +222,35 @@ export default function Settings() { }, []) + const getNotificationText = async () => { + try { + const response = await axios.post('/api/settings/get_notification_text', {}); + if (response.status === 200) { + if (response.data.notification_text) { + setNotificationText(response.data.notification_text); + } else { + setNotificationText("The application !name (!url) is now !status."); + } + } + } catch (error: any) { + alert(error.response.data.error); + } + }; + + const editNotificationText = async () => { + try { + const response = await axios.post('/api/settings/notification_text', { + text: notificationText + }); + } catch (error: any) { + alert(error.response.data.error); + } + } + + useEffect(() => { + getNotificationText() + }, []) + return ( @@ -531,16 +565,24 @@ export default function Settings() { Customize Notification Text -
-
- -