From 0cdc1947c130bd2dbbf991b4dd7451725acaec5c Mon Sep 17 00:00:00 2001 From: Trevor Buckner Date: Wed, 18 Sep 2024 14:45:17 -0400 Subject: [PATCH] Linting --- .../notificationAdd/notificationAdd.jsx | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/client/admin/notificationUtils/notificationAdd/notificationAdd.jsx b/client/admin/notificationUtils/notificationAdd/notificationAdd.jsx index 951a25e6b..1aaf11945 100644 --- a/client/admin/notificationUtils/notificationAdd/notificationAdd.jsx +++ b/client/admin/notificationUtils/notificationAdd/notificationAdd.jsx @@ -24,21 +24,21 @@ const NotificationAdd = ()=>{ const stopAt = new Date(stopAtRef.current.value); // Basic validation - if (!dismissKey || !title || !text || isNaN(startAt.getTime()) || isNaN(stopAt.getTime())) { - setState((prevState) => ({ + if(!dismissKey || !title || !text || isNaN(startAt.getTime()) || isNaN(stopAt.getTime())) { + setState((prevState)=>({ ...prevState, - error: 'All fields are required', + error : 'All fields are required', })); return; } - if (startAt >= stopAt) { - setState((prevState) => ({ + if(startAt >= stopAt) { + setState((prevState)=>({ ...prevState, - error: 'End date must be after the start date!', + error : 'End date must be after the start date!', })); return; } - + const data = { dismissKey, title, @@ -50,8 +50,7 @@ const NotificationAdd = ()=>{ try { setState((prevState)=>({ ...prevState, searching: true, error: null })); const response = await request.post('/admin/notification/add').send(data); - console.log(response.body); - const update = { notificationResult: `Notification successfully created.` }; + console.log(response.body); // Reset form fields dismissKeyRef.current.value = ''; @@ -60,11 +59,11 @@ const NotificationAdd = ()=>{ setState((prevState)=>({ ...prevState, - ...update, - searching : false, + notificationResult : `Notification successfully created.`, + searching : false, })); } catch (error) { - console.log(error.response.body.message); + console.log(error.response.body.message); setState((prevState)=>({ ...prevState, error : `Error saving notification: ${error.response.body.message}`, @@ -78,22 +77,21 @@ const NotificationAdd = ()=>{

Add Notification