mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-03-31 05:18:12 +00:00
Linting
This commit is contained in:
@@ -24,17 +24,17 @@ 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;
|
||||
}
|
||||
@@ -51,7 +51,6 @@ const NotificationAdd = ()=>{
|
||||
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.` };
|
||||
|
||||
// Reset form fields
|
||||
dismissKeyRef.current.value = '';
|
||||
@@ -60,7 +59,7 @@ const NotificationAdd = ()=>{
|
||||
|
||||
setState((prevState)=>({
|
||||
...prevState,
|
||||
...update,
|
||||
notificationResult : `Notification successfully created.`,
|
||||
searching : false,
|
||||
}));
|
||||
} catch (error) {
|
||||
@@ -81,7 +80,6 @@ const NotificationAdd = ()=>{
|
||||
Dismiss Key:
|
||||
<input className='fieldInput' type='text' ref={dismissKeyRef} required
|
||||
placeholder='GOOGLEDRIVENOTIF'
|
||||
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -102,20 +100,18 @@ const NotificationAdd = ()=>{
|
||||
|
||||
<label className='field'>
|
||||
Start Date:
|
||||
|
||||
<input type='date' className='fieldInput' ref={startAtRef} required/>
|
||||
</label>
|
||||
|
||||
<label className='field'>
|
||||
End Date:
|
||||
<input type='date' className='fieldInput' ref={stopAtRef} required
|
||||
/>
|
||||
<input type='date' className='fieldInput' ref={stopAtRef} required/>
|
||||
</label>
|
||||
|
||||
<div className='notificationResult'>{state.notificationResult}</div>
|
||||
|
||||
<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
|
||||
</button>
|
||||
{state.error && <div className='error'>{state.error}</div>}
|
||||
|
||||
Reference in New Issue
Block a user