From 422f577e0bb6936186fc894a4a85957d2caa3a77 Mon Sep 17 00:00:00 2001 From: bombies Date: Sat, 28 Oct 2023 20:47:36 -0500 Subject: [PATCH] Fix bug with possible null optimistic mutator --- .../dreams/forms/tags/AddTagForm.tsx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/(site)/(internal)/dashboard/components/dreams/forms/tags/AddTagForm.tsx b/src/app/(site)/(internal)/dashboard/components/dreams/forms/tags/AddTagForm.tsx index 4e29c79..03f3b1d 100644 --- a/src/app/(site)/(internal)/dashboard/components/dreams/forms/tags/AddTagForm.tsx +++ b/src/app/(site)/(internal)/dashboard/components/dreams/forms/tags/AddTagForm.tsx @@ -50,21 +50,21 @@ const AddTagForm: FC = ({onSuccess}) => { const onSubmit: SubmitHandler = async (data) => { if (!session?.user) return; - - await toast.promise(tags.optimisticData - .addOptimisticData(() => handleCreation(data), { - id: '', - ...data, - createdAt: new Date(), - updatedAt: new Date(), - userId: session.user.id - }), - { - loading: "Adding new tag...", - success: "Successfully added that tag!", - error: "Could not add that tag!" - } - ) + if (tags.optimisticData.addOptimisticData) + await toast.promise(tags.optimisticData + .addOptimisticData(() => handleCreation(data), { + id: '', + ...data, + createdAt: new Date(), + updatedAt: new Date(), + userId: session.user.id + }), + { + loading: "Adding new tag...", + success: "Successfully added that tag!", + error: "Could not add that tag!" + } + ) }