Skip to content

Commit

Permalink
fix: use the correct error keys for State and Zip (#4175)
Browse files Browse the repository at this point in the history
* fix: use the correct error keys for State and Zip

* fix: error keys in additional addresses
  • Loading branch information
jaredcwhite authored Jul 10, 2024
1 parent f27824b commit 4a58642
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
22 changes: 11 additions & 11 deletions sites/public/src/pages/applications/contact/address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ const ApplicationAddress = () => {
name="applicant.applicantAddress.state"
label={t("application.contact.state")}
validation={{ required: true, maxLength: 64 }}
error={errors.applicant?.address?.state}
error={errors.applicant?.applicantAddress?.state}
errorMessage={
errors.applicant?.applicantAddress?.state?.type === "maxLength"
? t("errors.maxLength")
Expand All @@ -368,7 +368,7 @@ const ApplicationAddress = () => {
? t("errors.maxLength")
: t("errors.zipCodeError")
}
error={errors.applicant?.address?.zipCode}
error={errors.applicant?.applicantAddress?.zipCode}
register={register}
dataTestId={"app-primary-address-zip"}
/>
Expand Down Expand Up @@ -404,9 +404,9 @@ const ApplicationAddress = () => {
defaultValue={application.applicationsMailingAddress.street}
label={t("application.contact.streetAddress")}
validation={{ required: true, maxLength: 64 }}
error={errors.mailingAddress?.street}
error={errors.applicationsMailingAddress?.street}
errorMessage={
errors.mailingAddress?.street?.type === "maxLength"
errors.applicationsMailingAddress?.street?.type === "maxLength"
? t("errors.maxLength")
: t("errors.streetError")
}
Expand All @@ -422,7 +422,7 @@ const ApplicationAddress = () => {
register={register}
dataTestId={"app-primary-mailing-address-street2"}
validation={{ maxLength: 64 }}
error={errors.mailingAddress?.street2}
error={errors.applicationsMailingAddress?.street2}
errorMessage={t("errors.maxLength")}
/>

Expand All @@ -433,9 +433,9 @@ const ApplicationAddress = () => {
label={t("application.contact.city")}
defaultValue={application.applicationsMailingAddress.city}
validation={{ required: true, maxLength: 64 }}
error={errors.mailingAddress?.city}
error={errors.applicationsMailingAddress?.city}
errorMessage={
errors.mailingAddress?.city?.type === "maxLength"
errors.applicationsMailingAddress?.city?.type === "maxLength"
? t("errors.maxLength")
: t("errors.cityError")
}
Expand All @@ -450,11 +450,11 @@ const ApplicationAddress = () => {
defaultValue={application.applicationsMailingAddress.state}
validation={{ required: true, maxLength: 64 }}
errorMessage={
errors.mailingAddress?.state?.type === "maxLength"
errors.applicationsMailingAddress?.state?.type === "maxLength"
? t("errors.maxLength")
: t("errors.stateError")
}
error={errors.mailingAddress?.state}
error={errors.applicationsMailingAddress?.state}
register={register}
controlClassName="control"
options={stateKeys}
Expand All @@ -469,9 +469,9 @@ const ApplicationAddress = () => {
label={t("application.contact.zip")}
defaultValue={application.applicationsMailingAddress.zipCode}
validation={{ required: true, maxLength: 64 }}
error={errors.mailingAddress?.zipCode}
error={errors.applicationsMailingAddress?.zipCode}
errorMessage={
errors.mailingAddress?.zipCode?.type === "maxLength"
errors.applicationsMailingAddress?.zipCode?.type === "maxLength"
? t("errors.maxLength")
: t("errors.zipCodeError")
}
Expand Down
36 changes: 18 additions & 18 deletions sites/public/src/pages/applications/household/member.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,11 @@ const ApplicationMember = () => {
defaultValue={member.householdMemberAddress.street}
validation={{ required: true, maxLength: 64 }}
errorMessage={
errors.address?.street?.type === "maxLength"
errors.householdMemberAddress?.street?.type === "maxLength"
? t("errors.maxLength")
: t("errors.streetError")
}
error={errors.address?.street}
error={errors.householdMemberAddress?.street}
register={register}
dataTestId={"app-household-member-address-street"}
label={t("application.contact.streetAddress")}
Expand All @@ -305,7 +305,7 @@ const ApplicationMember = () => {
name="householdMemberAddress.street2"
label={t("application.contact.apt")}
defaultValue={member.householdMemberAddress.street2}
error={errors.address?.street2}
error={errors.householdMemberAddress?.street2}
validation={{ maxLength: 64 }}
errorMessage={t("errors.maxLength")}
register={register}
Expand All @@ -320,11 +320,11 @@ const ApplicationMember = () => {
defaultValue={member.householdMemberAddress.city}
validation={{ required: true, maxLength: 64 }}
errorMessage={
errors.address?.city?.type === "maxLength"
errors.householdMemberAddress?.city?.type === "maxLength"
? t("errors.maxLength")
: t("errors.cityError")
}
error={errors.address?.city}
error={errors.householdMemberAddress?.city}
register={register}
dataTestId={"app-household-member-address-city"}
/>
Expand All @@ -335,9 +335,9 @@ const ApplicationMember = () => {
label={t("application.contact.state")}
defaultValue={member.householdMemberAddress.state}
validation={{ required: true, maxLength: 64 }}
error={errors.address?.state}
error={errors.householdMemberAddress?.state}
errorMessage={
errors.address?.state?.type === "maxLength"
errors.householdMemberAddress?.state?.type === "maxLength"
? t("errors.maxLength")
: t("errors.stateError")
}
Expand All @@ -355,9 +355,9 @@ const ApplicationMember = () => {
label={t("application.contact.zip")}
defaultValue={member.householdMemberAddress.zipCode}
validation={{ required: true, maxLength: 64 }}
error={errors.address?.zipCode}
error={errors.householdMemberAddress?.zipCode}
errorMessage={
errors.address?.zipCode?.type === "maxLength"
errors.address?.householdMemberAddress?.type === "maxLength"
? t("errors.maxLength")
: t("errors.zipCodeError")
}
Expand Down Expand Up @@ -400,9 +400,9 @@ const ApplicationMember = () => {
label={t("application.contact.streetAddress")}
defaultValue={member.householdMemberWorkAddress.street}
validation={{ required: true, maxLength: 64 }}
error={errors.workAddress?.street}
error={errors.householdMemberWorkAddress?.street}
errorMessage={
errors.workAddress?.street?.type === "maxLength"
errors.householdMemberWorkAddress?.street?.type === "maxLength"
? t("errors.maxLength")
: t("errors.streetError")
}
Expand All @@ -415,7 +415,7 @@ const ApplicationMember = () => {
name="householdMemberWorkAddress.street2"
label={t("application.contact.apt")}
defaultValue={member.householdMemberWorkAddress.street2}
error={errors.workAddress?.street2}
error={errors.householdMemberWorkAddress?.street2}
errorMessage={t("errors.maxLength")}
validation={{ maxLength: 64 }}
register={register}
Expand All @@ -429,9 +429,9 @@ const ApplicationMember = () => {
label={t("application.contact.city")}
defaultValue={member.householdMemberWorkAddress.city}
validation={{ required: true, maxLength: 64 }}
error={errors.workAddress?.city}
error={errors.householdMemberWorkAddress?.city}
errorMessage={
errors.workAddress?.city?.type === "maxLength"
errors.householdMemberWorkAddress?.city?.type === "maxLength"
? t("errors.maxLength")
: t("errors.cityError")
}
Expand All @@ -445,9 +445,9 @@ const ApplicationMember = () => {
label={t("application.contact.state")}
defaultValue={member.householdMemberWorkAddress.state}
validation={{ required: true, maxLength: 64 }}
error={errors.workAddress?.state}
error={errors.householdMemberWorkAddress?.state}
errorMessage={
errors.workAddress?.state?.type === "maxLength"
errors.householdMemberWorkAddress?.state?.type === "maxLength"
? t("errors.maxLength")
: t("errors.stateError")
}
Expand All @@ -465,9 +465,9 @@ const ApplicationMember = () => {
label={t("application.contact.zip")}
defaultValue={member.householdMemberWorkAddress.zipCode}
validation={{ required: true, maxLength: 64 }}
error={errors.workAddress?.zipCode}
error={errors.householdMemberWorkAddress?.zipCode}
errorMessage={
errors.workAddress?.zipCode?.type === "maxLength"
errors.householdMemberWorkAddress?.zipCode?.type === "maxLength"
? t("errors.maxLength")
: t("errors.zipCodeError")
}
Expand Down

0 comments on commit 4a58642

Please sign in to comment.