2025-12-08 13:57:26 +07:00
|
|
|
'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';
|
2025-12-08 13:57:26 +07:00
|
|
|
|
|
|
|
|
interface PhoneInputProps {
|
|
|
|
|
phoneState: string | undefined;
|
2025-12-22 13:02:39 +07:00
|
|
|
validateHandler: (e: ChangeEvent<HTMLInputElement>) => void;
|
2025-12-08 13:57:26 +07:00
|
|
|
}
|
|
|
|
|
|
2025-12-22 13:02:39 +07:00
|
|
|
export default function PhoneInput({ phoneState, validateHandler }: PhoneInputProps) {
|
2025-12-08 13:57:26 +07:00
|
|
|
const [phone, setPhone] = useState(phoneState ? phoneState : '');
|
2025-12-22 17:19:59 +07:00
|
|
|
|
2025-12-08 13:57:26 +07:00
|
|
|
return (
|
2025-12-29 18:47:50 +07:00
|
|
|
<InputMask
|
2025-12-08 13:57:26 +07:00
|
|
|
type="phone"
|
|
|
|
|
id="phone"
|
|
|
|
|
name="phone"
|
|
|
|
|
className={`${styles['form-input']}`}
|
2025-12-29 18:47:50 +07:00
|
|
|
mask="+7 (___) ___-__-__"
|
|
|
|
|
replacement={{ _: /\d/ }}
|
2025-12-08 13:57:26 +07:00
|
|
|
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"
|
2025-12-08 13:57:26 +07:00
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|