Merge branch 'dev' into 'staging'

fix FC phone types

See merge request frontend/squzanswerer!164
This commit is contained in:
Nastya 2024-07-11 20:12:38 +00:00
commit e0c71f9069
2 changed files with 6 additions and 3 deletions

@ -12,9 +12,11 @@ type InputProps = {
desc: string; desc: string;
Icon: FC<{ color: string; backgroundColor: string }>; Icon: FC<{ color: string; backgroundColor: string }>;
onChange: TextFieldProps["onChange"]; onChange: TextFieldProps["onChange"];
onChangePhone?: (phone: string) => void;
id: string; id: string;
isPhone?: boolean; isPhone?: boolean;
type?: HTMLInputTypeAttribute; type?: HTMLInputTypeAttribute;
value?: string;
}; };
const TextField = MuiTextField as unknown as FC<TextFieldProps>; const TextField = MuiTextField as unknown as FC<TextFieldProps>;
@ -37,7 +39,7 @@ function phoneChange(e: ChangeEvent<HTMLInputElement>, mask: string) {
return a || ""; return a || "";
} }
export const CustomInput = ({ title, desc, Icon, onChange, isPhone, type, value }: InputProps) => { export const CustomInput = ({ title, desc, Icon, onChange, onChangePhone, isPhone, type, value }: InputProps) => {
const theme = useTheme(); const theme = useTheme();
const isMobile = useRootContainerSize() < 600; const isMobile = useRootContainerSize() < 600;
const { settings } = useQuizSettings(); const { settings } = useQuizSettings();
@ -58,7 +60,7 @@ export const CustomInput = ({ title, desc, Icon, onChange, isPhone, type, value
<TextField <TextField
// inputRef={isPhone ? ref : null} // inputRef={isPhone ? ref : null}
//@ts-ignore //@ts-ignore
onChange={isPhone ? (e: ChangeEvent<HTMLInputElement>) => onChange(phoneChange(e, mask)) : onChange} onChange={isPhone ? (e: ChangeEvent<HTMLInputElement>) => onChangePhone(phoneChange(e, mask)) : onChange(e)}
type={isPhone ? "tel" : type} type={isPhone ? "tel" : type}
value={value} value={value}
sx={{ sx={{

@ -62,7 +62,8 @@ export const Inputs = ({
); );
const Phone = ( const Phone = (
<CustomInput <CustomInput
onChange={(phone: string) => { onChange={({ target }) => setText(target.value)}
onChangePhone={(phone: string) => {
console.log("onChange of phone"); console.log("onChange of phone");
console.log(phone); console.log(phone);
setPhone(phone); setPhone(phone);