Skip to content

Commit 90dd68d

Browse files
committed
Alert the share error if thrown
1 parent 4294d39 commit 90dd68d

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

components/ShareMenu/shareMenu.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@ export default function ShareMenu(props) {
1616

1717
const handleShareClick = (e) => {
1818
setRecipientEmail("");
19-
shareNote(router.query.id, recipientEmail, abortController).then(
20-
(response) =>
19+
shareNote(router.query.id, recipientEmail, abortController)
20+
.then((response) =>
2121
setNoteSharees([
2222
...noteSharees,
2323
{
2424
email: recipientEmail,
2525
user_id: response.data.recipient_id,
2626
},
2727
])
28-
);
28+
)
29+
.catch(alert);
2930
};
3031

3132
const handleRecipientEmailChange = (e) => setRecipientEmail(e.target.value);
32-
33-
const handleExitClick = e => {
33+
34+
const handleExitClick = (e) => {
3435
if (props.setShowShareMenu) {
3536
props.setShowShareMenu(false);
3637
}
@@ -45,7 +46,9 @@ export default function ShareMenu(props) {
4546
return (
4647
<div className={shareMenu.shareMenu}>
4748
<h1>Share</h1>
48-
<button className={shareMenu.exit} onClick={handleExitClick}>X</button>
49+
<button className={shareMenu.exit} onClick={handleExitClick}>
50+
X
51+
</button>
4952
<ShareeList
5053
noteSharees={noteSharees}
5154
setNoteSharees={setNoteSharees}
@@ -58,7 +61,12 @@ export default function ShareMenu(props) {
5861
placeholder="Recipient's email"
5962
aria-placeholder="Recipient's email"
6063
/>
61-
<button className={shareMenu.shareButton} onClick={handleShareClick}>Share</button>
64+
<button
65+
className={shareMenu.shareButton}
66+
onClick={handleShareClick}
67+
>
68+
Share
69+
</button>
6270
</div>
6371
);
6472
}

0 commit comments

Comments
 (0)