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 | 13x 234x 234x 10x 10x 10x 234x 10x | import { GiveInput, InputProps } from "@shared/GiveInputs/GiveInput";
import { useFormContext } from "react-hook-form";
import { normalizeInput } from "@sections/PayBuilder/Checkout/helpers";
const ExpirationDateField = (props: InputProps) => {
const { setValue } = useFormContext();
const handleChange = (value: string) => {
const normalizedValue = normalizeInput(value);
if (normalizedValue && normalizedValue.length <= 7) {
setValue("payment.expirationDate", normalizedValue, {
shouldValidate: true,
});
} else EsetValue("payment.expirationDate", "");
};
return (
<GiveInput
{...props}
onChange={(event) => handleChange(event.target.value)}
InputProps={{
inputMode: "numeric",
}}
maxLength={7}
/>
);
};
export default ExpirationDateField;
|