Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 66x 476x 476x 75x 476x | import React from "react";
import { useFormContext } from "react-hook-form";
import { HFGiveInput } from "@shared/HFInputs/HFGiveInput/HFGiveInput";
import { MAX_LENGTH_ZIP_CODE_DIGITS } from "@constants/constants";
import { normalizeZip } from "@utils/helpers";
type GiveZipCodeInputProps = {
id?: string;
name: string;
placeholder?: string;
label?: string;
letterSpacing?: string;
disabled?: boolean;
focusViewColor?: string;
helperText?: string;
isUSResident?: boolean;
};
const GiveZipCodeInput = ({
name,
placeholder,
label,
letterSpacing = "6px",
isUSResident = false,
...props
}: GiveZipCodeInputProps) => {
const { setValue, watch } = useFormContext();
React.useEffect(() => {
setValue(name, normalizeZip(watch(name), isUSResident));
}, [watch(name)]);
return (
<HFGiveInput
name={name}
label={label}
fullWidth
placeholder={placeholder}
{...props}
sx={{
letterSpacing,
"& .MuiFormHelperText-root": {
letterSpacing: "0px",
},
"& input::placeholder": {
letterSpacing: letterSpacing || "0px",
},
}}
inputProps={{
maxLength: MAX_LENGTH_ZIP_CODE_DIGITS[isUSResident ? "US" : "NON_US"],
}}
/>
);
};
export default GiveZipCodeInput;
|