Skip to content

Commit

Permalink
custom error message for mismatched emails
Browse files Browse the repository at this point in the history
  • Loading branch information
kathyychenn committed May 9, 2024
1 parent 1c25282 commit be13fef
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 44 deletions.
55 changes: 40 additions & 15 deletions frontend/src/components/Step1.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useState } from "react";

import devices from "../constants/devices.json";
import genders from "../constants/genders.json";

Expand All @@ -8,6 +10,18 @@ type Step1Props = {
};

export function Step1({ onSubmit }: Step1Props) {
const [email, setEmail] = useState<string>("");
const [confirmEmail, setConfirmEmail] = useState<string>("");

const handleConfirmEmailChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setConfirmEmail(e.target.value);
e.target.setCustomValidity(""); // Reset custom validity on input change
};

const handleInvalid = (event: React.InvalidEvent<HTMLInputElement>) => {
event.target.setCustomValidity("Email addresses do not match");
};

const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
event.preventDefault();
onSubmit();
Expand All @@ -20,7 +34,7 @@ export function Step1({ onSubmit }: Step1Props) {
<ul>
<li className={styles.bulletPoint}>
<p className={styles.listText}>
<strong className={styles.red}>
<strong className={styles.boldRed}>
Do NOT submit an application until ready to begin sitting for the IDEX California®
Examination.
</strong>
Expand Down Expand Up @@ -115,7 +129,12 @@ export function Step1({ onSubmit }: Step1Props) {
<div className={styles.inputBox}>
<label className={styles.inputTitle}>
Gender<span className={styles.boldRed}>*</span>
<select className={styles.inputText} id="drop" defaultValue={"default"} required>
<select
className={styles.inputText}
id="genderDrop"
defaultValue={"default"}
required
>
<option value="default" className={styles.optionDefault} disabled>
Select One
</option>
Expand Down Expand Up @@ -146,7 +165,12 @@ export function Step1({ onSubmit }: Step1Props) {
Email Address<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
type="text"
type="email"
name="email"
value={email}
onChange={(e) => {
setEmail(e.target.value);
}}
placeholder="Enter Email Address"
required
/>
Expand All @@ -155,7 +179,7 @@ export function Step1({ onSubmit }: Step1Props) {
<div className={styles.inputBox}>
<label className={styles.inputTitle}>
Phone Type<span className={styles.boldRed}>*</span>
<select className={styles.inputText} defaultValue={"default"} id="drop" required>
<select className={styles.inputText} defaultValue={"default"} id="phoneDrop" required>
<option value="default" className={styles.optionDefault} disabled>
Select Phone Type
</option>
Expand All @@ -176,8 +200,13 @@ export function Step1({ onSubmit }: Step1Props) {
Confirm Email Address<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
type="text"
type="email"
name="confirmEmail"
placeholder="Enter Email Address"
value={confirmEmail}
onInvalid={handleInvalid}
onChange={handleConfirmEmailChange}
pattern={email}
required
/>
</label>
Expand All @@ -187,8 +216,9 @@ export function Step1({ onSubmit }: Step1Props) {
Phone Number<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
type="text"
type="tel"
placeholder="Enter Phone Number"
pattern="[0-9]{10}"
required
/>
</label>
Expand Down Expand Up @@ -228,19 +258,14 @@ export function Step1({ onSubmit }: Step1Props) {
</div>
<div className={styles.inputBox}>
<label className={styles.inputTitle}>
Zip<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
type="text"
placeholder="Enter Zip Code"
required
/>
Zip
<input className={styles.inputText} type="number" placeholder="Enter Zip Code" />
</label>
</div>
<div className={styles.inputBox}>
<label className={styles.inputTitle}>
County<span className={styles.boldRed}>*</span>
<input className={styles.inputText} type="text" placeholder="Enter County" required />
County
<input className={styles.inputText} type="text" placeholder="Enter County" />
</label>
</div>
<div className={styles.inputBox}>
Expand Down
47 changes: 20 additions & 27 deletions frontend/src/components/Step2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function SchoolSection({ pathNumber }: { pathNumber: number }) {
<h3 className={styles.subTitle}>{"School " + school.id}</h3>
{school.id > 1 && (
<button
type="button"
className={styles.deleteButton}
onClick={() => {
deleteSchool(school.id);
Expand Down Expand Up @@ -154,6 +155,7 @@ function SchoolSection({ pathNumber }: { pathNumber: number }) {
type="text"
name={`startDate${index}`}
placeholder="mm/yyyy"
pattern="^(0[1-9]|1[0-2])/(19|20)\d{2}$"
required={isRequired}
/>
</label>
Expand All @@ -167,6 +169,7 @@ function SchoolSection({ pathNumber }: { pathNumber: number }) {
type="text"
name={`endDate${index}`}
placeholder="mm/yyyy"
pattern="^(0[1-9]|1[0-2])/(19|20)\d{2}$"
required={isRequired}
/>
</label>
Expand Down Expand Up @@ -236,6 +239,7 @@ function ProfessionalAssociationSection() {
<div className={styles.titleContainer}>
<h3 className={styles.subTitle}>{"Membership " + association.id}</h3>
<button
type="button"
className={styles.deleteButton}
onClick={() => {
deleteAssociation(association.id);
Expand Down Expand Up @@ -317,6 +321,7 @@ function NationalExamSection() {
Date of National Exam<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
name="exam-date"
type="text"
placeholder="mm/dd/yyyy"
pattern="^(0[1-9]|1[0-2])/(0[1-9]|[1-2][0-9]|3[0-1])/(19|20)\d{2}$"
Expand All @@ -329,14 +334,15 @@ function NationalExamSection() {
Certificate Number<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
name="certificate-number"
type="text"
placeholder="Enter Certificate Number"
required
/>
</label>
</div>
</div>
<button className={styles.upload}>
<button type="button" className={styles.upload}>
Upload Proof of National Exam
<img src={upload} className={styles.uploadButton} alt="buttonpng" />
</button>
Expand Down Expand Up @@ -378,6 +384,7 @@ function ICCCourses() {
<h3 className={styles.subTitle}>{"Course " + course.id}</h3>
{course.id > 1 && (
<button
type="button"
className={styles.deleteButton}
onClick={() => {
deleteCourse(course.id);
Expand All @@ -400,7 +407,7 @@ function ICCCourses() {
<select
className={styles.inputText}
defaultValue={"default"}
id="courseDrop"
id={`courseDrop${course.id}`}
required
>
<option value="default" className={styles.optionDefault} disabled>
Expand All @@ -420,30 +427,19 @@ function ICCCourses() {
</div>
<div className={styles.inputBox}>
<label className={styles.inputTitle}>
Professional Association Membership<span className={styles.boldRed}>*</span>
Date of Completion<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
type="text"
name={`email_${index}`}
placeholder="Enter your Membership"
required
/>
</label>
</div>
<div className={styles.inputBox}>
<label className={styles.inputTitle}>
Certificate Number<span className={styles.boldRed}>*</span>
<input
className={styles.inputText}
type="text"
name={`certNun${index}`}
placeholder="Enter Certificate Number"
name={`complete_${index}`}
placeholder="mm/dd/yyyy"
pattern="^(0[1-9]|1[0-2])/(0[1-9]|[1-2][0-9]|3[0-1])/(19|20)\d{2}$"
required
/>
</label>
</div>
</div>
<button className={styles.upload}>
<button type="button" className={styles.upload}>
Upload Proof of Course Completion
<img src={upload} className={styles.uploadButton} alt="buttonpng" />
</button>
Expand All @@ -467,28 +463,25 @@ export function Step2({ pathNumber, onSubmit }: Step2Props) {
onSubmit();
};

if (pathNumber === 1 || pathNumber === 2) {
content = <ProfessionalAssociationSection></ProfessionalAssociationSection>;
} else if (pathNumber === 3) {
if (pathNumber === 3) {
content = (
<>
<NationalExamSection></NationalExamSection>
<ProfessionalAssociationSection></ProfessionalAssociationSection>
<NationalExamSection />
</>
);
} else if (pathNumber === 4) {
content = (
<>
<NationalExamSection></NationalExamSection>
<ICCCourses></ICCCourses>
<ProfessionalAssociationSection></ProfessionalAssociationSection>
<NationalExamSection />
<ICCCourses />
</>
);
}
return (
<form id="step2-form" className={styles.formContainer} onSubmit={handleSubmit}>
<SchoolSection pathNumber={pathNumber}></SchoolSection>
<SchoolSection pathNumber={pathNumber} />
{content}
<ProfessionalAssociationSection />
</form>
);
}
4 changes: 2 additions & 2 deletions frontend/src/components/Steps.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
color: #6c6c6c;
}

::placeholder {
color: var(--color-accent);
input::placeholder {
color: var(--color-accent) !important;
opacity: 1; /* Firefox */
}

Expand Down

0 comments on commit be13fef

Please sign in to comment.