import { Form } from "antd"; import { TitleProps } from "antd/es/typography/Title"; import { FunctionComponent } from "react"; import { useTranslation } from "react-i18next"; import PhoneInput from "react-phone-input-2"; import { useAppSelector } from "redux/hooks"; import { ProBlack1 } from "ThemeConstants"; interface ProPhoneInput extends TitleProps { phone: string; setPhone: (phone: string) => void; propName?: string label?: string } const ProPhoneInput: FunctionComponent = ({ phone, setPhone, propName, label }) => { const { t } = useTranslation(); const { themeName } = useAppSelector((state) => state.theme); const { isRTL } = useAppSelector((state) => state.locale); return ( { if (!value || value.length <= 3) { return Promise.reject(new Error("")); } return Promise.resolve(); }, }, ]} normalize={(value) => { if (value && setPhone) { setPhone(value); } return value; }} > ); }; export const PhoneInputWrapper = ({ phone, themeName, isRTL, placeholder, value, onChange, propName, label }: { phone: string; themeName: string; isRTL: boolean; placeholder: string; value?: string; onChange?: (value: string) => void; propName?: string; label?: string; }) => { return (
{ onChange?.(value); }} buttonStyle={{ backgroundColor: "transparent", border: 0, borderLeft: "1px solid #363636", borderRadius: 0, position: "relative", ...(isRTL && { top: -25, right: 25, }), ...(!isRTL && { top: -25, }), }} autocompleteSearch inputProps={{ id: propName || "phone", // Required for accessibility & autofill name: propName || "phone", required: true, autoFocus: false, autoComplete: "tel", type: "tel", inputMode: "numeric", pattern: "[0-9]*", }} />
); }; export default ProPhoneInput;