Skip to content

Commit

Permalink
feat: use currency type for dollar amount inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Jun 28, 2024
1 parent 1de824b commit 68c56f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const FormHouseholdIncome = () => {
const formMethods = useFormContext()

// eslint-disable-next-line @typescript-eslint/unbound-method
const { errors, register, setValue, trigger, watch } = formMethods
const { errors, register, getValues, setValue, trigger, watch } = formMethods

const incomePeriodValue: string = watch("application.incomePeriod")

Expand Down Expand Up @@ -63,13 +63,14 @@ const FormHouseholdIncome = () => {
<Grid.Cell>
<Field
id="incomeYear"
type="text"
type="currency"
getValues={getValues}
setValue={setValue}
name="incomeYear"
label={t("application.details.annualIncome")}
placeholder={t("t.enterAmount")}
register={register}
disabled={incomePeriodValue !== IncomePeriodEnum.perYear}
validation={{ pattern: /^[0-9.]+$/ }}
error={fieldHasError(errors?.incomeYear)}
errorMessage={t("errors.numberError")}
/>
Expand All @@ -78,13 +79,14 @@ const FormHouseholdIncome = () => {
<Grid.Cell>
<Field
id="incomeMonth"
type="text"
type="currency"
getValues={getValues}
setValue={setValue}
name="incomeMonth"
label={t("application.details.monthlyIncome")}
placeholder={t("t.enterAmount")}
register={register}
disabled={incomePeriodValue !== IncomePeriodEnum.perMonth}
validation={{ pattern: /^[0-9.]+$/ }}
error={fieldHasError(errors?.incomeMonth)}
errorMessage={t("errors.numberError")}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const UnitForm = ({ onSubmit, onClose, defaultUnit, nextId, draft }: UnitFormPro
className={errors[fieldName] ? "error" : ""}
error={errors[fieldName]}
errorMessage={t("errors.requiredFieldError")}
validation={{ required: !!amiChartID, pattern: /^[0-9.]+$/ }}
validation={{ required: !!amiChartID }}
inputProps={{
onChange: () => {
clearErrors(fieldName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const AdditionalFees = (props: AdditionalFeesProps) => {
const formMethods = useFormContext()
const { profile } = useContext(AuthContext)
// eslint-disable-next-line @typescript-eslint/unbound-method
const { register, watch, errors, clearErrors } = formMethods
const { register, watch, errors, clearErrors, getValues, setValue } = formMethods

const jurisdiction = watch("jurisdiction.id")

Expand Down Expand Up @@ -47,6 +47,8 @@ const AdditionalFees = (props: AdditionalFeesProps) => {
id={"applicationFee"}
register={register}
type={"currency"}
getValues={getValues}
setValue={setValue}
prepend={"$"}
placeholder={"0.00"}
/>
Expand All @@ -58,6 +60,8 @@ const AdditionalFees = (props: AdditionalFeesProps) => {
id={"depositMin"}
register={register}
type={"currency"}
getValues={getValues}
setValue={setValue}
prepend={"$"}
placeholder={"0.00"}
error={fieldHasError(errors?.depositMin)}
Expand All @@ -74,6 +78,8 @@ const AdditionalFees = (props: AdditionalFeesProps) => {
id={"depositMax"}
register={register}
type={"currency"}
getValues={getValues}
setValue={setValue}
prepend={"$"}
placeholder={"0.00"}
error={fieldHasError(errors?.depositMax)}
Expand Down

0 comments on commit 68c56f0

Please sign in to comment.