Skip to content

Commit 08750f6

Browse files
authored
Review Registration Personal Info (#223)
* Rebase * Address PR comments, organize code to remove duplication * Lint * Rebase * Address PR comments, organize code to remove duplication * Lint * Lint * Add visited verification on review summary page. * Add new dependency after resolving merge conflict. * Address comments
1 parent 8bfee97 commit 08750f6

File tree

12 files changed

+952
-103
lines changed

12 files changed

+952
-103
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react";
2+
import { AccordionButton, AccordionIcon, Box, Text } from "@chakra-ui/react";
3+
4+
type GeneralAccordionButtonProps = {
5+
title: string;
6+
};
7+
8+
const GeneralAccordionButton = ({
9+
title,
10+
}: GeneralAccordionButtonProps): React.ReactElement => {
11+
return (
12+
<AccordionButton
13+
borderRadius="20px"
14+
bg="primary.green.600"
15+
_hover={{ bg: "primary.green.600" }}
16+
>
17+
<Box flex="1" textAlign="left">
18+
<Text
19+
color="text.white.100"
20+
textStyle={{
21+
sm: "xSmallMedium",
22+
md: "bodyBold",
23+
lg: "displayLarge",
24+
}}
25+
p={2}
26+
>
27+
{title}
28+
</Text>
29+
</Box>
30+
<AccordionIcon color="white" fontSize="2.5em" />
31+
</AccordionButton>
32+
);
33+
};
34+
35+
export default GeneralAccordionButton;

frontend/src/components/common/formQuestions/QuestionsAccordionItem.tsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import React from "react";
22

3-
import {
4-
AccordionButton,
5-
AccordionIcon,
6-
AccordionItem,
7-
AccordionPanel,
8-
Box,
9-
Text,
10-
} from "@chakra-ui/react";
3+
import { AccordionItem, AccordionPanel } from "@chakra-ui/react";
114

125
import {
136
CreateFormQuestionRequest,
147
FormQuestion,
158
} from "../../../types/CampsTypes";
169
import QuestionCard from "./QuestionCard";
10+
import GeneralAccordionButton from "../GeneralAccordionButton";
1711
import RegistrationQuestionCard from "../../pages/CampCreation/RegistrationForm/RegistrationQuestionCard";
1812
import NoRegistrationQuestionsCard from "../../pages/CampCreation/RegistrationForm/NoRegistrationQuestionsCard";
1913

@@ -42,18 +36,7 @@ const QuestionsAccordionItem = ({
4236

4337
return (
4438
<AccordionItem border="none" marginBottom="40px">
45-
<AccordionButton
46-
borderRadius="20px"
47-
bg="primary.green.600"
48-
_hover={{ bg: "primary.green.600" }}
49-
>
50-
<Box flex="1" textAlign="left">
51-
<Text color="text.white.100" textStyle="heading" p={2}>
52-
{accordionTitle}
53-
</Text>
54-
</Box>
55-
<AccordionIcon color="white" fontSize="2.5em" />
56-
</AccordionButton>
39+
<GeneralAccordionButton title={accordionTitle} />
5740

5841
{isTemplatePage ? (
5942
<AccordionPanel>

frontend/src/components/pages/RegistrantExperience/RegistrationSteps/PersonalInfo/personalInfoReducer.tsx

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,59 @@ export const checkRelationToCamper = (relation: string): boolean => {
151151
return !!relation;
152152
};
153153

154+
export const checkCamperCardComplete = (
155+
camp: CampResponse,
156+
camper: RegistrantExperienceCamper,
157+
): boolean => {
158+
return (
159+
checkFirstName(camper.firstName) &&
160+
checkLastName(camper.lastName) &&
161+
checkAge(camper.age, camp.ageUpper, camp.ageLower)
162+
);
163+
};
164+
165+
export const checkContactCardComplete = (
166+
camper: RegistrantExperienceCamper,
167+
): boolean => {
168+
if (camper.contacts.length > 2 || camper.contacts.length < 1) {
169+
return false; // Need to have either 1 or 2 contacts only
170+
}
171+
// Check primary contact card
172+
const primaryContact = camper.contacts[0];
173+
if (
174+
!(
175+
checkFirstName(primaryContact.firstName) &&
176+
checkLastName(primaryContact.lastName) &&
177+
checkEmail(primaryContact.email) &&
178+
checkPhoneNumber(primaryContact.phoneNumber) &&
179+
checkRelationToCamper(primaryContact.relationshipToCamper)
180+
)
181+
) {
182+
return false;
183+
}
184+
// Check secondary contact card
185+
if (camper.contacts.length > 1) {
186+
const secondaryContact = camper.contacts[1];
187+
if (
188+
(secondaryContact.firstName ||
189+
secondaryContact.lastName ||
190+
secondaryContact.email ||
191+
secondaryContact.phoneNumber ||
192+
secondaryContact.relationshipToCamper) &&
193+
!(
194+
checkFirstName(secondaryContact.firstName) &&
195+
checkLastName(secondaryContact.lastName) &&
196+
checkEmail(secondaryContact.email) &&
197+
checkPhoneNumber(secondaryContact.phoneNumber) &&
198+
checkRelationToCamper(secondaryContact.relationshipToCamper)
199+
)
200+
) {
201+
return false;
202+
}
203+
}
204+
return true;
205+
};
206+
154207
export const checkPersonalInfoFilled = (
155208
campers: RegistrantExperienceCamper[],
156209
camp: CampResponse | undefined,
@@ -162,53 +215,14 @@ export const checkPersonalInfoFilled = (
162215

163216
/* eslint-disable-next-line */
164217
for (const camper of campers) {
165-
// Check camper card
166-
if (
167-
!(
168-
checkFirstName(camper.firstName) &&
169-
checkLastName(camper.lastName) &&
170-
checkAge(camper.age, camp.ageUpper, camp.ageLower)
171-
)
172-
)
173-
return false;
174-
175-
// Check contact cards
176-
if (camper.contacts.length > 2 || camper.contacts.length < 1) {
177-
return false; // Need to have either 1 or 2 contacts only
178-
}
179-
// Check primary contact card
180-
const primaryContact = camper.contacts[0];
181218
if (
182219
!(
183-
checkFirstName(primaryContact.firstName) &&
184-
checkLastName(primaryContact.lastName) &&
185-
checkEmail(primaryContact.email) &&
186-
checkPhoneNumber(primaryContact.phoneNumber) &&
187-
checkRelationToCamper(primaryContact.relationshipToCamper)
220+
checkCamperCardComplete(camp, camper) &&
221+
checkContactCardComplete(camper)
188222
)
189223
) {
190224
return false;
191225
}
192-
// Check secondary contact card
193-
if (camper.contacts.length > 1) {
194-
const secondaryContact = camper.contacts[1];
195-
if (
196-
(secondaryContact.firstName ||
197-
secondaryContact.lastName ||
198-
secondaryContact.email ||
199-
secondaryContact.phoneNumber ||
200-
secondaryContact.relationshipToCamper) &&
201-
!(
202-
checkFirstName(secondaryContact.firstName) &&
203-
checkLastName(secondaryContact.lastName) &&
204-
checkEmail(secondaryContact.email) &&
205-
checkPhoneNumber(secondaryContact.phoneNumber) &&
206-
checkRelationToCamper(secondaryContact.relationshipToCamper)
207-
)
208-
) {
209-
return false;
210-
}
211-
}
212226
}
213227

214228
// Check required personal info and contact info questions

frontend/src/components/pages/RegistrantExperience/RegistrationSteps/RegistrationFooter.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type RegistrationFooterProps = {
88
isCurrentStepCompleted: boolean;
99
registrationLoading: boolean;
1010
handleStepNavigation: (stepsToMove: number) => void;
11+
isPaymentSummary: boolean;
1112
isWaitlistRegistration: boolean;
1213
};
1314

@@ -17,6 +18,7 @@ const RegistrationFooter = ({
1718
isCurrentStepCompleted,
1819
registrationLoading,
1920
handleStepNavigation,
21+
isPaymentSummary,
2022
isWaitlistRegistration,
2123
}: RegistrationFooterProps): React.ReactElement => {
2224
const toast = useToast();
@@ -75,7 +77,8 @@ const RegistrationFooter = ({
7577
loadingText="Submitting"
7678
onClick={onNextStep}
7779
>
78-
{currentStep === RegistrantExperienceSteps.ReviewRegistrationPage
80+
{currentStep === RegistrantExperienceSteps.ReviewRegistrationPage &&
81+
isPaymentSummary
7982
? "Go to checkout"
8083
: "Next"}
8184
</Button>

frontend/src/components/pages/RegistrantExperience/RegistrationSteps/ReviewRegistration/ReviewInformation.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)