From c09ce2b2b53447c48539ce45c1c889e541b684de Mon Sep 17 00:00:00 2001 From: Damian Harateh Date: Tue, 20 Apr 2021 01:30:38 +0100 Subject: [PATCH] Basic validation for New Event Type to prevent unexpected behaviour Previously, when creating a new event type, user was still allowed to create a new event type, even if the event length's field was empty. This would cause a prisma error, since it would receive NaN and no event would have been added, but the page still reloaded. Therefore, a very basic validation to address this, at least in the short-term. --- pages/availability/index.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pages/availability/index.tsx b/pages/availability/index.tsx index 10ab9534..88d93964 100644 --- a/pages/availability/index.tsx +++ b/pages/availability/index.tsx @@ -61,8 +61,9 @@ export default function Availability(props) { } }); - console.log(response); - Router.reload(); + if (enteredTitle && enteredLength) { + Router.reload(); + } } async function updateStartEndTimesHandler(event) { @@ -217,6 +218,7 @@ export default function Availability(props) { + {/* TODO: Add an error message when required input fields empty*/}