Files
no-copy-frontend/src/app/ui/inputs/phone-input.tsx
T

31 lines
762 B
TypeScript
Raw Normal View History

'use client'
2025-12-29 18:47:50 +07:00
import { useState, ChangeEvent } from 'react';
import { InputMask } from '@react-input/mask';
2025-12-27 12:10:13 +07:00
import styles from '@/app/styles/module/login.module.scss';
interface PhoneInputProps {
phoneState: string | undefined;
2025-12-22 13:02:39 +07:00
validateHandler: (e: ChangeEvent<HTMLInputElement>) => void;
}
2025-12-22 13:02:39 +07:00
export default function PhoneInput({ phoneState, validateHandler }: PhoneInputProps) {
const [phone, setPhone] = useState(phoneState ? phoneState : '');
2025-12-22 17:19:59 +07:00
return (
2025-12-29 18:47:50 +07:00
<InputMask
type="phone"
id="phone"
name="phone"
className={`${styles['form-input']}`}
2025-12-29 18:47:50 +07:00
mask="+7 (___) ___-__-__"
replacement={{ _: /\d/ }}
value={phone}
2025-12-22 13:02:39 +07:00
onChange={(e) => {
2025-12-29 18:47:50 +07:00
setPhone(e.target.value);
2025-12-22 13:02:39 +07:00
validateHandler(e);
}}
2025-12-29 18:47:50 +07:00
placeholder="+7 (999) 123-45-67"
/>
)
}