From f16b158c7f389ed9702692ae65e96bc52dba922b Mon Sep 17 00:00:00 2001 From: Ben Grant Date: Wed, 16 Jun 2021 00:30:19 +1000 Subject: [PATCH] Backup error for blank name field --- crabfit-frontend/public/i18n/en/event.json | 1 + crabfit-frontend/src/pages/Event/Event.tsx | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/crabfit-frontend/public/i18n/en/event.json b/crabfit-frontend/public/i18n/en/event.json index 38f1863..2287e52 100644 --- a/crabfit-frontend/public/i18n/en/event.json +++ b/crabfit-frontend/public/i18n/en/event.json @@ -23,6 +23,7 @@ "timezone": "Your time zone", "errors": { + "name_required": "Your name is needed to store your availability.", "password_incorrect": "Password is incorrect. Check your name is spelled right.", "unknown": "Failed to login. Please try again." }, diff --git a/crabfit-frontend/src/pages/Event/Event.tsx b/crabfit-frontend/src/pages/Event/Event.tsx index 1505d6a..c9dfa4b 100644 --- a/crabfit-frontend/src/pages/Event/Event.tsx +++ b/crabfit-frontend/src/pages/Event/Event.tsx @@ -226,8 +226,14 @@ const Event = (props) => { }, [timezone]); const onSubmit = async data => { + if (!data.name || data.name.length === 0) { + setFocus('name'); + return setError(t('event:form.errors.name_required')); + } + setIsLoginLoading(true); setError(null); + try { const response = await api.post(`/event/${id}/people/${data.name}`, { person: {