номер телефона сбрасывается при смене маски
This commit is contained in:
parent
7312f0e941
commit
3bb940047c
@ -24,13 +24,13 @@ type InputProps = {
|
||||
const TextField = MuiTextField as unknown as FC<TextFieldProps>;
|
||||
let first = true;
|
||||
|
||||
function phoneChange(e: ChangeEvent<HTMLInputElement>, mask: string) {
|
||||
function phoneChange(newValue: string, mask: string) {
|
||||
const masked = IMask.createMask({
|
||||
mask: "+7 (000) 000-00-00",
|
||||
// ...and other options
|
||||
});
|
||||
masked.value = e.target.value;
|
||||
const a = IMask.pipe(e.target.value, {
|
||||
masked.value = newValue;
|
||||
const a = IMask.pipe(newValue, {
|
||||
mask,
|
||||
});
|
||||
return a || "";
|
||||
@ -68,7 +68,7 @@ export const CustomInput = ({
|
||||
// inputRef={isPhone ? ref : null}
|
||||
//@ts-ignore
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
isPhone ? onChangePhone?.(phoneChange(e, mask)) : onChange?.(e)
|
||||
isPhone ? onChangePhone?.(phoneChange(e.target.value, mask)) : onChange?.(e)
|
||||
}
|
||||
onBlur={onBlur}
|
||||
type={isPhone ? "tel" : type}
|
||||
@ -106,7 +106,16 @@ export const CustomInput = ({
|
||||
</InputAdornment>
|
||||
),
|
||||
endAdornment: (
|
||||
<InputAdornment position="end">{isPhone && <CountrySelector setMask={setMask} />}</InputAdornment>
|
||||
<InputAdornment position="end">
|
||||
{isPhone && (
|
||||
<CountrySelector
|
||||
setMask={(e) => {
|
||||
onChangePhone?.(phoneChange("", mask));
|
||||
setMask(e);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</InputAdornment>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
|
||||
@ -12,7 +12,7 @@ const isProduction = !(
|
||||
);
|
||||
|
||||
//туризм больше не в исключениях
|
||||
if (!isProduction) domain = "https://hbpn.link";
|
||||
if (!isProduction) domain = "https://s.hbpn.link";
|
||||
// domain = "https://hbpn.link";
|
||||
|
||||
export { domain, isProduction };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user