-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements and form validation (#15)
* Improvements and form validation * Fix notification contents * Fix duplicate api calls * Improve notification handling * Only request suggestions on analyze * Minimize api calls * Implement edit comment
- Loading branch information
1 parent
9244add
commit 6efbbdf
Showing
25 changed files
with
275 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
import React from 'react'; | ||
import useNavigation from '../hooks/useNavigation'; | ||
import React, { useEffect, useState } from 'react'; | ||
import Store from '../core/store'; | ||
import useStore from '../hooks/useStore'; | ||
import NotificationPopup from './NotificationPopup'; | ||
|
||
export default function NotificationContainer() { | ||
const { notification } = useStore(); | ||
const navigate = useNavigation(); | ||
const store = useStore() as Store; | ||
const [hide, setHide] = useState<boolean>(false); | ||
|
||
const close = () => { | ||
setHide(true); | ||
store.setNotification(null); | ||
}; | ||
|
||
// hide notification after 5s | ||
useEffect(() => { | ||
if (store.notification) { | ||
setHide(false); | ||
const timer = setTimeout(close, 5000); | ||
return () => clearTimeout(timer); | ||
} | ||
}, [store.notification]); | ||
|
||
if (!notification) { | ||
if (!store.notification || hide) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<NotificationPopup | ||
notification={notification} | ||
onClose={() => navigate({ notification: 'clear' })} | ||
notification={store.notification} | ||
onClose={close} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useState } from 'react'; | ||
import { Roa } from '../../core/types'; | ||
import useNavigation from '../../hooks/useNavigation'; | ||
import useTranslations from '../../hooks/useTranslations'; | ||
|
||
interface EditProps { | ||
onClose: () => void, | ||
roa?: Roa, | ||
} | ||
|
||
export default function Edit({ onClose, roa }: EditProps) { | ||
const t = useTranslations(); | ||
const navigate = useNavigation(); | ||
const [comment, setComment] = useState(roa?.comment || ''); | ||
|
||
return ( | ||
<> | ||
<h3>{t.caDetails.addRoa}</h3> | ||
<form | ||
onSubmit={(e) => { | ||
e.preventDefault(); | ||
if (comment !== roa?.comment) { | ||
navigate({ comment }); | ||
} else { | ||
onClose(); | ||
} | ||
}} | ||
> | ||
<div> | ||
<label htmlFor="comment required"> | ||
{t.caDetails.comment} | ||
</label> | ||
<input | ||
name="comment" | ||
value={comment} | ||
onChange={(e) => setComment(e.target.value)} | ||
/> | ||
</div> | ||
</form> | ||
<div className="actions"> | ||
<button | ||
className="button outline" | ||
onClick={onClose} | ||
> | ||
{t.common.cancel} | ||
</button> | ||
<button | ||
type="submit" | ||
className="button" | ||
> | ||
{t.common.confirm} | ||
</button> | ||
</div> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.