Skip to content

Commit

Permalink
save if rules read to context step4
Browse files Browse the repository at this point in the history
  • Loading branch information
kathyychenn committed May 21, 2024
1 parent 7912676 commit 08d3691
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
27 changes: 21 additions & 6 deletions frontend/src/components/Step4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,18 @@ export const Step4: React.FC<StepProps> = ({ next }: StepProps) => {
const { formData, setFormData } = useContext(FormContext);

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setFormData((prevFormData) => ({
...prevFormData,
[name]: value,
}));
const { name, value, type, checked } = e.target;
if (type === "checkbox") {
setFormData((prevFormData) => ({
...prevFormData,
[name]: checked,
}));
} else {
setFormData((prevFormData) => ({
...prevFormData,
[name]: value,
}));
}
};

const handleSelect = (option: string) => {
Expand Down Expand Up @@ -199,7 +206,15 @@ export const Step4: React.FC<StepProps> = ({ next }: StepProps) => {
</p>

<label htmlFor="select" className={styles.checkboxLabel}>
<input className={styles.select} type="checkbox" id="select" required />
<input
className={styles.select}
name="readRules"
type="checkbox"
id="select"
onChange={handleInputChange}
checked={formData.readRules}
required
/>
<span>
Click here to acknowledge you have read and understood the rules and regulations
</span>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/contexts/FormContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type FormData = {
dateCertified: string;
convictedOfFelony: string;
extraExplanation: string;
readRules: boolean;

SchoolsAttended: SchoolsAttended[];
ProfessionalMemberships: ProfessionalMemberships[];
Expand Down Expand Up @@ -123,6 +124,7 @@ const initialFormData: FormData = {
dateCertified: "",
convictedOfFelony: "",
extraExplanation: "",
readRules: false,

SchoolsAttended: [],
ProfessionalMemberships: [],
Expand Down

0 comments on commit 08d3691

Please sign in to comment.