Skip to content

Commit 6cc43a4

Browse files
committed
Fix EditModal.tsx and DeleteModal.tsx
1 parent 94dbdd6 commit 6cc43a4

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

components/DeleteModal.tsx

+5-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { deleteGift } from '~/utils/apiRequests';
55
import { useMutation, useQueryClient } from '@tanstack/react-query';
66
import SvgSpinner from '~/icons/spinner';
77
import { useShowErrorToast } from '~/hooks/useShowErrorToast';
8+
import { handleErrorToast } from '~/utils/handleToasts';
9+
import { handleError } from '~/utils/handleError';
810

911
type DeleteModal = {
1012
gift: Gift;
@@ -51,15 +53,11 @@ export function DeleteModal({ gift, closeModal }: DeleteModal) {
5153
<Button
5254
className={`m-6 mt-0 h-8 w-20 p-0 text-sm disabled:w-24 disabled:pr-4`}
5355
disabled={isPending}
54-
onClick={async () => {
56+
onClick={() => {
5557
try {
56-
await mutateAsync();
58+
void mutateAsync();
5759
} catch (e) {
58-
/*
59-
this catch's idea is to prevent fatal error from occuring which would break the whole site
60-
useShowErrorToast(error) handles the showing of the error
61-
*/
62-
return;
60+
handleErrorToast(handleError(e));
6361
}
6462
}}
6563
>

components/EditModal.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Input } from './Input';
77
import { useMutation, useQueryClient } from '@tanstack/react-query';
88
import SvgSpinner from '~/icons/spinner';
99
import { useShowErrorToast } from '~/hooks/useShowErrorToast';
10+
import { handleErrorToast } from '~/utils/handleToasts';
11+
import { handleError } from '~/utils/handleError';
1012

1113
type EditModal = {
1214
gift: Gift;
@@ -35,6 +37,7 @@ export function EditModal({ gift, closeModal }: EditModal) {
3537
gift: giftName,
3638
});
3739
} catch (e) {
40+
handleErrorToast(handleError(e));
3841
return;
3942
}
4043

@@ -78,7 +81,7 @@ export function EditModal({ gift, closeModal }: EditModal) {
7881
className="ml-6 mt-0 h-8 w-20 p-0 text-sm disabled:w-24 disabled:pr-4"
7982
type="submit"
8083
disabled={isPending}
81-
onClick={(e) => handleEdit(e)}
84+
onClick={(e) => void handleEdit(e)}
8285
>
8386
Tallenna
8487
{isPending && (

0 commit comments

Comments
 (0)