From e6d630f05c4ecd8e48e0405e7701ccce7c877acf Mon Sep 17 00:00:00 2001 From: Alex Hoopes Date: Mon, 6 Sep 2021 00:27:23 -0700 Subject: [PATCH 1/3] ALL-18: Extract string values for yes/no and food options Refactoring to avoid typos and make the next step of fixing this bug easier. --- src/components/RSVPForm.jsx | 4 ++-- src/components/select-options/FoodOptions.jsx | 12 +++++++++--- src/components/select-options/YesNoOptions.jsx | 9 +++++++-- src/components/select-options/index.js | 6 ++++-- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/components/RSVPForm.jsx b/src/components/RSVPForm.jsx index dbee637..eb9bb59 100644 --- a/src/components/RSVPForm.jsx +++ b/src/components/RSVPForm.jsx @@ -4,7 +4,7 @@ import { generateErrorModal, generateSuccessModal } from '../helpers' import { Fragment, useState } from 'react' import Button from './Button' import Checkbox from './Checkbox' -import { FoodOptions, YesNoOptions } from './select-options' +import { FoodOptions, YesNoOptions, YesNoValues } from './select-options' import SelectBox from './SelectBox' import TextBox from './TextBox' @@ -42,7 +42,7 @@ function RSVPForm({ guest }) { const newRsvp = event.target.value setRsvp(newRsvp) - if (newRsvp === 'Yes') { + if (newRsvp === YesNoValues.YES) { setRsvpDate(new Date().toISOString().split('T')[0]) } else { setRsvpDate(new Date('2000-01-01').toISOString().split('T')[0]) diff --git a/src/components/select-options/FoodOptions.jsx b/src/components/select-options/FoodOptions.jsx index a8bec3c..818941b 100644 --- a/src/components/select-options/FoodOptions.jsx +++ b/src/components/select-options/FoodOptions.jsx @@ -1,12 +1,18 @@ import { Fragment } from 'react' +export const FoodValues = { + NO_RESTRICTIONS: 'No Restrictions', + GLUTEN_FREE: 'GlutenFree', + VEGAN: 'Vegan', +} + function FoodOptions() { return ( - - - + + + ) } diff --git a/src/components/select-options/YesNoOptions.jsx b/src/components/select-options/YesNoOptions.jsx index 1449565..a13472b 100644 --- a/src/components/select-options/YesNoOptions.jsx +++ b/src/components/select-options/YesNoOptions.jsx @@ -1,11 +1,16 @@ import { Fragment } from 'react' +export const YesNoValues = { + YES: 'Yes', + NO: 'No' +} + function YesNoOptions() { return ( - - + + ) } diff --git a/src/components/select-options/index.js b/src/components/select-options/index.js index 9e47be6..6559fea 100644 --- a/src/components/select-options/index.js +++ b/src/components/select-options/index.js @@ -1,7 +1,9 @@ -import FoodOptions from './FoodOptions' -import YesNoOptions from './YesNoOptions' +import FoodOptions, { FoodValues } from './FoodOptions' +import YesNoOptions, { YesNoValues } from './YesNoOptions' export { FoodOptions, + FoodValues, YesNoOptions, + YesNoValues, } From ee24ffa6081a32d0579a4ed7231116c7aa662746 Mon Sep 17 00:00:00 2001 From: Alex Hoopes Date: Mon, 6 Sep 2021 00:28:39 -0700 Subject: [PATCH 2/3] ALL-18: Allow user to submit form immediately if RSVPing "No" --- src/components/RSVPForm.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/RSVPForm.jsx b/src/components/RSVPForm.jsx index eb9bb59..92f50e7 100644 --- a/src/components/RSVPForm.jsx +++ b/src/components/RSVPForm.jsx @@ -50,7 +50,10 @@ function RSVPForm({ guest }) { } const isSubmitDisabled = () => { - return !rsvp || !dinnerOption + if (!rsvp) return true + if (rsvp === YesNoValues.NO) return false + + return !dinnerOption } const handleSubmit = async (event) => { From 2b637e3985b6994d32956ed7ac5d3e07a437acd2 Mon Sep 17 00:00:00 2001 From: Alex Hoopes Date: Mon, 6 Sep 2021 00:41:38 -0700 Subject: [PATCH 3/3] ALL-19: Display user's first and last name on RSVP form --- src/components/RSVPForm.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/RSVPForm.jsx b/src/components/RSVPForm.jsx index 92f50e7..b91ce89 100644 --- a/src/components/RSVPForm.jsx +++ b/src/components/RSVPForm.jsx @@ -87,6 +87,7 @@ function RSVPForm({ guest }) { return (
+

RSVP Information for {guest.firstName} {guest.lastName}