From 77e91161d6fb8205b2db58c5155d58485a3b9ef5 Mon Sep 17 00:00:00 2001 From: codevictory Date: Thu, 16 Dec 2021 22:38:30 +0200 Subject: [PATCH] Complete version of the registration form. --- src/components/RegForm.scss | 67 ++++- src/components/RegForm.tsx | 277 ++++++++++++------ src/components/utils.ts | 4 - src/constants/localization/registration/en.ts | 28 ++ src/constants/localization/registration/fi.ts | 29 +- src/pages/Registration.scss | 3 +- 6 files changed, 308 insertions(+), 100 deletions(-) diff --git a/src/components/RegForm.scss b/src/components/RegForm.scss index 88b7045..a9d2be9 100644 --- a/src/components/RegForm.scss +++ b/src/components/RegForm.scss @@ -1,18 +1,73 @@ +@import '../colors.scss'; + form#registration { max-width: 24.5em; padding: 1em; -} - -.nameBar { display: flex; - justify-content: space-between; - align-items: baseline; + flex-direction: column; + align-items: center; } .visitors { + display: flex; + width: 72vw; + flex-wrap: wrap; + justify-content: space-evenly; +} + +.visitor { + display: flex; + flex-direction: column; + align-items: center; margin-top: 1em; margin-bottom: 1em; padding: 1em; border-radius: 5px; - background-color: rgb(235, 235, 235); + background-color: $background; + width: 400px; + font-family: 'Montserrat-Medium'; + + label { + color: $brown-text !important; + } + + input, + label, + span { + font-size: 1.3rem; + } + + .ant-form-item { + width: 100%; + } +} + +.addVisitorButton { + font-family: 'Montserrat-Medium'; + color: $green-text !important; + font-size: 1.5rem !important; + height: unset !important; + background-color: transparent; + text-transform: uppercase; + border-width: 0.2rem; + border-color: $green-text; + + :hover { + background-color: $background !important; + } +} + +.submitButton { + font-family: 'Montserrat-Medium'; + color: $green-text !important; + font-size: 2rem !important; + height: unset !important; + background-color: transparent; + text-transform: uppercase; + border-width: 0.2rem; + border-color: $green-text; + + :hover { + background-color: $background !important; + } } diff --git a/src/components/RegForm.tsx b/src/components/RegForm.tsx index 2023689..2cede5d 100644 --- a/src/components/RegForm.tsx +++ b/src/components/RegForm.tsx @@ -1,111 +1,212 @@ -import { Button, Checkbox, Col, Form, Input, Row, Select } from 'antd'; +import { Button, Form, Input, Select } from 'antd'; import { useParams } from 'react-router'; -import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; -import "./RegForm.scss"; +import './RegForm.scss'; import { addVisitor } from '../api'; -import { arrayToString, capFirstLetter } from './utils'; +import { arrayToString } from './utils'; import { Visitor } from '../model/visitor'; +import { FormattedMessage, useIntl } from 'react-intl'; +import { useState } from 'react'; const { Option } = Select; interface ParamTypes { - id: string; + id: string; } interface FormValues { - visitors: Visitor[]; + visitors: Visitor[]; } -const preferences = ["vegan", "vegetarian", "everything goes"].map(preference => { - return +const preferences = ['vegan', 'vegetarian', 'murder'].map((preference) => { + return ( + + ); }); -const allergies = ["lactose", "dairy", "gluten", "wheat"].map(allergy => { - return +const allergies = ['lactose', 'dairy', 'gluten', 'wheat'].map((allergy) => { + return ( + + ); }); +const welcomeDrinks = ['alcoholBubbles', 'alcoholFreeBubbles'].map( + (welcomeDrink) => { + return ( + + ); + } +); + export const RegForm = () => { - const { id } = useParams(); + const { id } = useParams(); + const intl = useIntl(); + const [visitorCount, setVisitorCount] = useState(0); - const onFinish = (values: FormValues) => { - values.visitors.map(visitor => { - addVisitor({ - ...visitor, - allergies: visitor.allergies ? arrayToString(visitor.allergies) : "", - services: visitor.services ? arrayToString(visitor.services) : "", - preferences: visitor.preferences ?? "", - invitationId: visitor.invitationId = atob(id), - }); - }); - } + const onFinish = (values: FormValues) => { + values.visitors.map((visitor) => { + addVisitor({ + ...visitor, + allergies: visitor.allergies ? arrayToString(visitor.allergies) : '', + services: visitor.services ? arrayToString(visitor.services) : '', + preferences: visitor.preferences ?? '', + invitationId: (visitor.invitationId = atob(id)), + }); + }); + }; - const [form] = Form.useForm(); + const [form] = Form.useForm(); - return ( -
- - {(fields, { add, remove }) => ( - <> - { - fields.map(field => ( -
-
- - - - remove(field.name)} className="deleteButton" /> -
- - - - - - - - - - - - Ride - - - - - Accomodation - - - - - -
- ))} - - - - - )} -
+ return ( + + + {(fields, { add, remove }) => ( + <> +
+ {fields.map((field) => ( +
+ + + + + + + + + + + + + +
+ ))} +
- + - - ); -}; \ No newline at end of file + + )} +
+ {visitorCount == 0 ? ( + + + + ) : ( + + + + )} + + ); +}; diff --git a/src/components/utils.ts b/src/components/utils.ts index 69db299..98bd195 100644 --- a/src/components/utils.ts +++ b/src/components/utils.ts @@ -1,7 +1,3 @@ -export const capFirstLetter = (str: string) => { - return str.charAt(0).toUpperCase() + str.slice(1); -} - export const arrayToString = (str: string) => { return str.toString().replaceAll(",", ", "); } \ No newline at end of file diff --git a/src/constants/localization/registration/en.ts b/src/constants/localization/registration/en.ts index 63c7dcf..2e2151d 100644 --- a/src/constants/localization/registration/en.ts +++ b/src/constants/localization/registration/en.ts @@ -4,4 +4,32 @@ export const registration: Record = { "registration.about": "We will be updating the program and menu in lintujamaslo.net", "registration.saveTheLink": "Save the link", "registration.fillInBefore": "Please fill the visitors in before 27th of June", + "registration.addVisitor": "Add visitor", + + "registration.form.submit": "Submit", + "registration.form.decline": "Decline invitation", + "registration.form.remove": "Remove", + + "registration.form.name": "Name", + "registration.form.name.placeholder": "Full or nickname", + "registration.form.name.missing": "Missing name", + + "registration.form.allergies": "Food allergies", + "registration.form.allergies.placeholder": "Lactose, wheat...", + "registration.form.allergies.lactose": "Lactose", + "registration.form.allergies.dairy": "Dairy", + "registration.form.allergies.gluten": "Gluten", + "registration.form.allergies.wheat": "Wheat", + + "registration.form.preferences": "Food preferences", + "registration.form.preferences.placeholder": "Vegan...", + "registration.form.preferences.vegan": "Vegan", + "registration.form.preferences.vegetarian": "Vegetarian", + "registration.form.preferences.murder": "Murder", + + "registration.form.welcomeDrinks": "Welcome drink", + "registration.form.welcomeDrinks.placeholder": "What fancy you?", + "registration.form.welcomeDrinks.missing": "Missing welcome drink", + "registration.form.welcomeDrinks.alcoholBubbles": "Alcohol bubbles", + "registration.form.welcomeDrinks.alcoholFreeBubbles": "Alcohol-free bubbles" } \ No newline at end of file diff --git a/src/constants/localization/registration/fi.ts b/src/constants/localization/registration/fi.ts index e487960..2f6109a 100644 --- a/src/constants/localization/registration/fi.ts +++ b/src/constants/localization/registration/fi.ts @@ -3,5 +3,32 @@ export const registration: Record = { "registration.questions": "Jos sinulla on mitään kysymyksiä\nsienistä\nvaarallisista pedoista", "registration.about": "Päivitämme menua ja ohjelmaa osoitteeseen lintujamaslo.net", "registration.saveTheLink": "Laita linkki talteen", - "registration.fillInBefore": "Lisääthän teiltä osallistuvat henkilöt viimeistään 27th of June", + "registration.fillInBefore": "Lisääthän teiltä osallistuvat henkilöt viimeistään 27. kesäkuuta", + "registration.addVisitor": "Lisää osallistuja", + + "registration.form.submit": "Vahvista", + "registration.form.decline": "Kieltäydyn kutsusta", + "registration.form.remove": "Poista", + + "registration.form.name": "Nimi", + "registration.form.name.placeholder": "Koko tai lempinimi", + "registration.form.name.missing": "Nimi puuttuu", + "registration.form.allergies": "Ruoka-allergiat", + "registration.form.allergies.placeholder": "Laktoosi, vehnä...", + "registration.form.allergies.lactose": "Laktoosi", + "registration.form.allergies.dairy": "Maitotuotteet", + "registration.form.allergies.gluten": "Gluteeni", + "registration.form.allergies.wheat": "Vehnä", + + "registration.form.preferences": "Erikoisruokavalio", + "registration.form.preferences.placeholder": "Vegaaninen...", + "registration.form.preferences.vegan": "Vegaani", + "registration.form.preferences.vegetarian": "Kasvissyöjä", + "registration.form.preferences.murder": "Murha", + + "registration.form.welcomeDrinks": "Tervetuliasmalja", + "registration.form.welcomeDrinks.placeholder": "Mitä saisi olla?", + "registration.form.welcomeDrinks.missing": "Tervetulias malja puuttuu", + "registration.form.welcomeDrinks.alcoholBubbles": "Holillista kuplivaa", + "registration.form.welcomeDrinks.alcoholFreeBubbles": "Holitonta kuplivaa" } \ No newline at end of file diff --git a/src/pages/Registration.scss b/src/pages/Registration.scss index 217ade7..ccb0aef 100644 --- a/src/pages/Registration.scss +++ b/src/pages/Registration.scss @@ -5,13 +5,13 @@ align-items: center; flex-direction: column; white-space: pre-line; - text-transform: uppercase; .Registration-main { display: flex; flex-direction: column; align-items: center; max-width: 50%; + text-transform: uppercase; img { max-width: 60%; @@ -27,6 +27,7 @@ .Registration-desc { max-width: 23rem; margin-top: 3rem; + text-transform: uppercase; h2 { text-align: center; color: $brown-text !important;