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

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