-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add address verification for preferences step (#3715)
* feat: add collectAddress checkbox with subfields * test: update preference tests * fix: add minimum value validation for radius field * fix: make collect address not required * fix: expand collect address fields * fix: change fields order in PreferenceDrawer * feat: add address holder fields to application * fix: make added field optional * fix: display errors properly * feat: add address holder fields to application summary * feat: add address verification for preferences step * feat: adjust padding for application summary * fix: move address holder name and relationship fields to extraData * fix: remove redundant backend address holder fields * fix: use enum for address holder fields * fix: add alternate address form component * fix: remove redundant fields from new address form * fix: verify preferences address when collectAddress true * fix: block going back on address verification add string to translation * fix: use onClick to block address Verification back button
- Loading branch information
1 parent
a8b13b0
commit 0f9ead7
Showing
5 changed files
with
211 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
shared-helpers/src/views/address/FormAddressAlternate.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { UseFormMethods } from "react-hook-form" | ||
import { Field, resolveObject, Select, t } from "@bloom-housing/ui-components" | ||
import React from "react" | ||
|
||
type FormAddressProps = { | ||
subtitle?: string | ||
dataKey: string | ||
register: UseFormMethods["register"] | ||
errors?: UseFormMethods["errors"] | ||
required?: boolean | ||
stateKeys: string[] | ||
} | ||
|
||
export const FormAddressAlternate = ({ | ||
subtitle, | ||
dataKey, | ||
register, | ||
errors, | ||
required, | ||
stateKeys, | ||
}: FormAddressProps) => { | ||
return ( | ||
<> | ||
<legend className={`text__caps-spaced ${!subtitle ? "sr-only" : ""}`}> | ||
{!subtitle ? t("application.preferences.options.address") : subtitle} | ||
</legend> | ||
<Field | ||
id={`${dataKey}.street`} | ||
name={`${dataKey}.street`} | ||
label={t("application.contact.streetAddress")} | ||
placeholder={t("application.contact.streetAddress")} | ||
validation={{ required: true, maxLength: 64 }} | ||
errorMessage={ | ||
resolveObject(`${dataKey}.street`, errors)?.type === "maxLength" | ||
? t("errors.maxLength") | ||
: t("errors.streetError") | ||
} | ||
error={!!resolveObject(`${dataKey}.street`, errors)} | ||
register={register} | ||
/> | ||
|
||
<Field | ||
id={`${dataKey}.street2`} | ||
name={`${dataKey}.street2`} | ||
label={t("application.contact.apt")} | ||
placeholder={t("application.contact.apt")} | ||
register={register} | ||
error={!!resolveObject(`${dataKey}.street2`, errors)} | ||
validation={{ maxLength: 64 }} | ||
errorMessage={t("errors.maxLength")} | ||
/> | ||
|
||
<div className="flex"> | ||
<Field | ||
id={`${dataKey}.city`} | ||
name={`${dataKey}.city`} | ||
label={t("application.contact.cityName")} | ||
placeholder={t("application.contact.cityName")} | ||
register={register} | ||
validation={{ required, maxLength: 64 }} | ||
error={!!resolveObject(`${dataKey}.city`, errors)} | ||
errorMessage={ | ||
resolveObject(`${dataKey}.city`, errors)?.type === "maxLength" | ||
? t("errors.maxLength") | ||
: t("errors.cityError") | ||
} | ||
/> | ||
|
||
<Select | ||
id={`${dataKey}.state`} | ||
name={`${dataKey}.state`} | ||
label={t("application.contact.state")} | ||
validation={{ required: true }} | ||
error={!!resolveObject(`${dataKey}.state`, errors)} | ||
errorMessage={ | ||
resolveObject(`${dataKey}.state`, errors)?.type === "maxLength" | ||
? t("errors.maxLength") | ||
: t("errors.stateError") | ||
} | ||
register={register} | ||
controlClassName="control" | ||
options={stateKeys} | ||
keyPrefix="states" | ||
/> | ||
</div> | ||
<Field | ||
id={`${dataKey}.zipCode`} | ||
name={`${dataKey}.zipCode`} | ||
label={t("application.contact.zip")} | ||
placeholder={t("application.contact.zipCode")} | ||
register={register} | ||
validation={{ required, maxLength: 64 }} | ||
error={!!resolveObject(`${dataKey}.zipCode`, errors)} | ||
errorMessage={ | ||
resolveObject(`${dataKey}.zipCode`, errors)?.type === "maxLength" | ||
? t("errors.maxLength") | ||
: t("errors.zipCodeError") | ||
} | ||
/> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters