mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-30 08:52:38 +00:00
Linting
This commit is contained in:
@@ -24,17 +24,17 @@ const NotificationAdd = ()=>{
|
|||||||
const stopAt = new Date(stopAtRef.current.value);
|
const stopAt = new Date(stopAtRef.current.value);
|
||||||
|
|
||||||
// Basic validation
|
// Basic validation
|
||||||
if (!dismissKey || !title || !text || isNaN(startAt.getTime()) || isNaN(stopAt.getTime())) {
|
if(!dismissKey || !title || !text || isNaN(startAt.getTime()) || isNaN(stopAt.getTime())) {
|
||||||
setState((prevState) => ({
|
setState((prevState)=>({
|
||||||
...prevState,
|
...prevState,
|
||||||
error: 'All fields are required',
|
error : 'All fields are required',
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (startAt >= stopAt) {
|
if(startAt >= stopAt) {
|
||||||
setState((prevState) => ({
|
setState((prevState)=>({
|
||||||
...prevState,
|
...prevState,
|
||||||
error: 'End date must be after the start date!',
|
error : 'End date must be after the start date!',
|
||||||
}));
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -50,8 +50,7 @@ const NotificationAdd = ()=>{
|
|||||||
try {
|
try {
|
||||||
setState((prevState)=>({ ...prevState, searching: true, error: null }));
|
setState((prevState)=>({ ...prevState, searching: true, error: null }));
|
||||||
const response = await request.post('/admin/notification/add').send(data);
|
const response = await request.post('/admin/notification/add').send(data);
|
||||||
console.log(response.body);
|
console.log(response.body);
|
||||||
const update = { notificationResult: `Notification successfully created.` };
|
|
||||||
|
|
||||||
// Reset form fields
|
// Reset form fields
|
||||||
dismissKeyRef.current.value = '';
|
dismissKeyRef.current.value = '';
|
||||||
@@ -60,11 +59,11 @@ const NotificationAdd = ()=>{
|
|||||||
|
|
||||||
setState((prevState)=>({
|
setState((prevState)=>({
|
||||||
...prevState,
|
...prevState,
|
||||||
...update,
|
notificationResult : `Notification successfully created.`,
|
||||||
searching : false,
|
searching : false,
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error.response.body.message);
|
console.log(error.response.body.message);
|
||||||
setState((prevState)=>({
|
setState((prevState)=>({
|
||||||
...prevState,
|
...prevState,
|
||||||
error : `Error saving notification: ${error.response.body.message}`,
|
error : `Error saving notification: ${error.response.body.message}`,
|
||||||
@@ -78,22 +77,21 @@ const NotificationAdd = ()=>{
|
|||||||
<h2>Add Notification</h2>
|
<h2>Add Notification</h2>
|
||||||
|
|
||||||
<label className='field'>
|
<label className='field'>
|
||||||
Dismiss Key:
|
Dismiss Key:
|
||||||
<input className='fieldInput' type='text' ref={dismissKeyRef} required
|
<input className='fieldInput' type='text' ref={dismissKeyRef} required
|
||||||
placeholder='GOOGLEDRIVENOTIF'
|
placeholder='GOOGLEDRIVENOTIF'
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className='field'>
|
<label className='field'>
|
||||||
Title:
|
Title:
|
||||||
<input className='fieldInput' type='text' ref={titleRef} required
|
<input className='fieldInput' type='text' ref={titleRef} required
|
||||||
placeholder='Stop using Google Drive as image host'
|
placeholder='Stop using Google Drive as image host'
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className='field'>
|
<label className='field'>
|
||||||
Text:
|
Text:
|
||||||
<textarea className='fieldInput' type='text' ref={textRef} required
|
<textarea className='fieldInput' type='text' ref={textRef} required
|
||||||
placeholder='Google Drive is not an image hosting site, you should not use it as such.'
|
placeholder='Google Drive is not an image hosting site, you should not use it as such.'
|
||||||
>
|
>
|
||||||
@@ -101,22 +99,20 @@ const NotificationAdd = ()=>{
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className='field'>
|
<label className='field'>
|
||||||
Start Date:
|
Start Date:
|
||||||
|
|
||||||
<input type='date' className='fieldInput' ref={startAtRef} required/>
|
<input type='date' className='fieldInput' ref={startAtRef} required/>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label className='field'>
|
<label className='field'>
|
||||||
End Date:
|
End Date:
|
||||||
<input type='date' className='fieldInput' ref={stopAtRef} required
|
<input type='date' className='fieldInput' ref={stopAtRef} required/>
|
||||||
/>
|
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div className='notificationResult'>{state.notificationResult}</div>
|
<div className='notificationResult'>{state.notificationResult}</div>
|
||||||
|
|
||||||
<button className='notificationSave' onClick={saveNotification} disabled={state.searching}>
|
<button className='notificationSave' onClick={saveNotification} disabled={state.searching}>
|
||||||
<i className={`fas ${state.searching ? 'fa-spin fa-spinner' : 'fa-save'}`} />
|
<i className={`fas ${state.searching ? 'fa-spin fa-spinner' : 'fa-save'}`}/>
|
||||||
Save Notification
|
Save Notification
|
||||||
</button>
|
</button>
|
||||||
{state.error && <div className='error'>{state.error}</div>}
|
{state.error && <div className='error'>{state.error}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user