настройки формы контактов без мессенджеров

This commit is contained in:
Nastya 2023-12-16 07:20:07 +03:00
parent f8c4d11728
commit 0341a73b3e
11 changed files with 481 additions and 170 deletions

@ -94,7 +94,10 @@ export type AnyTypedQuizQuestion =
| QuizQuestionFile | QuizQuestionFile
| QuizQuestionPage | QuizQuestionPage
| QuizQuestionRating | QuizQuestionRating
| QuizQuestionResult; | QuizQuestionResult
| QuizQuestionContact;
type FilterQuestionsWithVariants<T> = T extends { type FilterQuestionsWithVariants<T> = T extends {
content: { variants: QuestionVariant[]; }; content: { variants: QuestionVariant[]; };

@ -40,7 +40,7 @@ export interface QuizConfig {
theme: string, theme: string,
reply: string, reply: string,
replname: string, replname: string,
} }
startpage: { startpage: {
description: string; description: string;
button: string; button: string;
@ -58,6 +58,14 @@ export interface QuizConfig {
cycle: boolean; cycle: boolean;
}; };
}; };
formContact: {
name: FCField;
email: FCField;
phone: FCField;
text: FCField;
address: FCField;
button: string
};
info: { info: {
phonenumber: string; phonenumber: string;
clickable: boolean; clickable: boolean;
@ -68,6 +76,14 @@ export interface QuizConfig {
meta: string; meta: string;
} }
type FCField = {
text: string
innerText: string
key: string
required: boolean
used: boolean
}
export const defaultQuizConfig: QuizConfig = { export const defaultQuizConfig: QuizConfig = {
type: null, type: null,
noStartPage: false, noStartPage: false,
@ -81,7 +97,7 @@ export const defaultQuizConfig: QuizConfig = {
theme: "", theme: "",
reply: "", reply: "",
replname: "", replname: "",
}, },
startpage: { startpage: {
description: "", description: "",
button: "", button: "",
@ -106,5 +122,43 @@ export const defaultQuizConfig: QuizConfig = {
site: "", site: "",
law: "", law: "",
}, },
formContact: {
name: {
text: "",
innerText: "",
key: "",
required: false,
used: true
},
email: {
text: "",
innerText: "",
key: "",
required: false,
used: true
},
phone: {
text: "",
innerText: "",
key: "",
required: false,
used: true
},
text: {
text: "",
innerText: "",
key: "",
required: false,
used: false
},
address: {
text: "",
innerText: "",
key: "",
required: false,
used: false
},
button: ""
},
meta: "", meta: "",
}; };

@ -1,9 +1,10 @@
import ExpandMoreIcon from "@mui/icons-material/ExpandMore"; import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import { Box, Button, IconButton, Link, Paper, SxProps, TextField, Theme, Typography, useTheme } from "@mui/material"; import { Box, Button, IconButton, Link, Paper, SxProps, TextField, Theme, Typography, useTheme, Popover, useMediaQuery, Divider } from "@mui/material";
import { incrementCurrentStep } from "@root/quizes/actions"; import { incrementCurrentStep, updateQuiz } from "@root/quizes/actions";
import CustomTextField from "@ui_kit/CustomTextField"; import CustomTextField from "@ui_kit/CustomTextField";
import React from "react"; import React from "react";
import InfoIcon from "../../assets/icons/InfoIcon"; import Info from "../../assets/icons/Info";
import Trash from "@icons/trash";
import { OneIcon } from "../../assets/icons/questionsPage/OneIcon"; import { OneIcon } from "../../assets/icons/questionsPage/OneIcon";
import AddPlus from "../../assets/icons/questionsPage/addPlus"; import AddPlus from "../../assets/icons/questionsPage/addPlus";
import ArrowLeft from "../../assets/icons/questionsPage/arrowLeft"; import ArrowLeft from "../../assets/icons/questionsPage/arrowLeft";
@ -12,116 +13,105 @@ import DrawerNewField from "./DrawerParent";
import WindowMessengers from "./Massengers/WindowMessengers"; import WindowMessengers from "./Massengers/WindowMessengers";
import WindowNewField from "./NewField/WindowNewField"; import WindowNewField from "./NewField/WindowNewField";
import SwitchContactForm from "./switchContactForm"; import SwitchContactForm from "./switchContactForm";
import GearIcon from "@icons/GearIcon";
import { useQuestionsStore } from "@root/questions/store";
import { useCurrentQuiz } from "@root/quizes/hooks";
const buttons = [
{
name: "Имя",
desc: "Дмитрий",
key: "name"
},
{
name: "Email",
desc: "mail@xample.ru",
key: "email"
},
{
name: "Номер",
desc: "+7 900 000 00 00",
key: "phone"
},
{
name: "Фамилия",
desc: "Иванов",
key: "text"
},
{
name: "Адрес",
desc: "Москва, Лаврушинский пер., 10",
key: "address"
},
]
export default function ContactFormPage() { export default function ContactFormPage() {
const [drawerNewField, setDrawerNewField] = React.useState(false); const theme = useTheme();
const quiz = useCurrentQuiz()
const isTablet = useMediaQuery(theme.breakpoints.down(1000))
const [drawerNewField, setDrawerNewField] = React.useState("");
const [drawerMessenger, setDrawerMessenger] = React.useState(false); const [drawerMessenger, setDrawerMessenger] = React.useState(false);
const drawerNewFieldHC = (bool: boolean) => { const drawerNewFieldHC = (str: string) => {
setDrawerNewField(bool); setDrawerNewField(str);
}; };
const drawerMessengerHC = (bool: boolean) => { const drawerMessengerHC = (bool: boolean) => {
setDrawerMessenger(bool); setDrawerMessenger(bool);
}; };
const theme = useTheme();
return ( return (
<> <Box
<Box sx={{ display: "flex", alignItems: "center", gap: "10px" }}> sx={{
p: isTablet ? "0 0 150px 0" : "0"
}}
>
<Box sx={{
display: "flex",
alignItems: "center",
gap: "10px",
m: "67px 0 41px 0",
}}>
<Link <Link
sx={{ sx={{
fontSize: "16px", fontSize: "16px",
lineHeight: "19px", lineHeight: "19px",
color: theme.palette.brightPurple.main, color: theme.palette.brightPurple.main,
textDecorationColor: theme.palette.brightPurple.main, textDecorationColor: theme.palette.brightPurple.main,
}} }}
> >
Как собрать данные посетителя Как собрать данные посетителя
</Link>{" "} </Link>{" "}
<InfoIcon /> {/* <Popover>
<Info />
</Popover> */}
</Box> </Box>
<ContactFormParent>
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "end" }}>
<OneIcon />
<IconButton>
{" "}
<ExpandMoreIcon />{" "}
</IconButton>
</Box>
<Box sx={{ display: "flex", flexDirection: "column", gap: "20px", padding: "10px 20px" }}>
<Typography>Имя*</Typography>
<CustomTextField placeholder="Дмитрий" text={""} />
<Typography>E-mail*</Typography>
<CustomTextField placeholder="+7 900 000 00 00" text={""} />
<Typography>Телефон*</Typography>
<CustomTextField placeholder="+7 900 000 00 00" text={""} />
<Button
onClick={() => drawerNewFieldHC(true)}
variant="contained"
sx={{ maxWidth: "fit-content", padding: "10px 20px" }}
>
Добавить поле +
</Button>
<DrawerNewField isOpen={drawerNewField} openHC={drawerNewFieldHC}>
<WindowNewField />
</DrawerNewField>
<Link
component="button"
onClick={() => drawerMessengerHC(true)}
sx={{
fontSize: "16px",
lineHeight: "19px",
color: theme.palette.brightPurple.main,
textDecorationColor: theme.palette.brightPurple.main,
textAlign: "left",
}}
>
Добавить мессенджеры
</Link>
<DrawerNewField isOpen={drawerMessenger} openHC={drawerMessengerHC}>
<WindowMessengers />
</DrawerNewField>
<Button variant="contained" sx={{ padding: "10px 20px", maxWidth: "fit-content" }}>
Название кнопки
</Button>
</Box>
</ContactFormParent>
<ContactFormParent> {
<Box sx={{ display: "flex", alignItems: "center", justifyContent: "end" }}> !quiz?.config.formContact.name.used &&
<OneIcon /> !quiz?.config.formContact.email.used &&
<IconButton> !quiz?.config.formContact.phone.used &&
{" "} !quiz?.config.formContact.text.used &&
<ExpandMoreIcon />{" "} !quiz?.config.formContact.address.used ?
</IconButton> <ContactFormParent>
</Box> <EmptyCard drawerNewFieldHC={drawerNewFieldHC} />
<Button variant="contained" sx={{ maxWidth: "fit-content", padding: "10px 20px" }}> </ContactFormParent>
Добавить поле + :
</Button> <ContactFormParent>
<Box sx={{ display: "flex" }}> <ButtonsCard drawerNewFieldHC={drawerNewFieldHC} />
<Typography sx={{ color: theme.palette.orange.main }}>Будут показаны поля по умолчанию</Typography> </ContactFormParent>
<InfoIcon /> }
</Box>
<Link
sx={{
mt: "20px",
fontSize: "16px",
lineHeight: "19px",
color: theme.palette.brightPurple.main,
textDecorationColor: theme.palette.brightPurple.main,
}}
>
Добавить мессенджеры
</Link>
<Button variant="contained" sx={{ padding: "10px 20px", maxWidth: "fit-content" }}>
Название кнопки
</Button>
</ContactFormParent>
<Box sx={{ display: "flex", justifyContent: "space-between", maxWidth: "796px" }}> <Box sx={{ display: "flex", justifyContent: "space-between", maxWidth: "796px" }}>
<IconButton>
<AddPlus />
</IconButton>
<Box sx={{ display: "flex", gap: "8px" }}> <Box sx={{ display: "flex", gap: "8px" }}>
<Button variant="outlined"> <Button variant="outlined">
<ArrowLeft /> <ArrowLeft />
@ -131,7 +121,13 @@ export default function ContactFormPage() {
</Button> </Button>
</Box> </Box>
</Box> </Box>
</>
<DrawerNewField isOpenDrawer={drawerNewField} drawerNewFieldHC={drawerNewFieldHC}>
<WindowNewField type={drawerNewField} drawerNewFieldHC={drawerNewFieldHC} />
</DrawerNewField>
</Box>
); );
} }
@ -142,10 +138,7 @@ interface Props {
function ContactFormParent({ outerContainerSx: sx, children }: Props) { function ContactFormParent({ outerContainerSx: sx, children }: Props) {
const theme = useTheme(); const theme = useTheme();
const [switchState, setSwitchState] = React.useState("setting"); const isTablet = useMediaQuery(theme.breakpoints.down(1000))
const SSHC = (data: string) => {
setSwitchState(data);
};
return ( return (
<Paper <Paper
sx={{ sx={{
@ -154,16 +147,15 @@ function ContactFormParent({ outerContainerSx: sx, children }: Props) {
borderRadius: "12px", borderRadius: "12px",
margin: "20px 0", margin: "20px 0",
display: "flex", display: "flex",
flexDirection: "column",
}} }}
> >
<Box sx={{ width: "100%", display: "flex" }}> <Box sx={{ width: "100%", display: "flex", flexDirection: isTablet ? "column" : "row", }}>
<Box <Box
sx={{ sx={{
borderRight: `1px solid ${theme.palette.grey2.main}`, // borderRight: isTablet ? "none" : `1px solid ${theme.palette.grey2.main}`,
maxWidth: "386px", maxWidth: "386px",
width: "100%", width: "100%",
padding: "113px 20px 20px 20px", padding: "100px 20px 20px 20px",
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
gap: "20px", gap: "20px",
@ -186,14 +178,211 @@ function ContactFormParent({ outerContainerSx: sx, children }: Props) {
}} }}
/> />
</Box> </Box>
<Box sx={{ display: "flex", flexDirection: "column", padding: "20px", width: "100%", gap: "20px" }}> <Divider sx={{
{children} height: isTablet ? "1px" : "80%",
</Box> width: isTablet ? "80%" : "1px",
</Box> margin: "auto"
<Box> }}
<ButtonSettingForms switchState={switchState} SSHC={SSHC} /> orientation={isTablet ? "horisontal" : "vertical"}
<SwitchContactForm switchState={switchState} /> />
{children}
</Box> </Box>
</Paper> </Paper>
); );
} }
const SettingField = ({ name, placeholder, type, drawerNewFieldHC }: { name: string, placeholder: string, type: string; drawerNewFieldHC: any }) => {
const theme = useTheme();
const quiz = useCurrentQuiz()
return (
<>
<Typography>{quiz.config.formContact[type].text || name}</Typography>
<Box
sx={{ display: "flex", mb: "10px" }}
>
<Typography
sx={{
color: quiz.config.formContact[type].innerText ? "black" : "#9A9AAF",
fontSize: "20px",
backgroundColor: theme.palette.background.default,
height: "48px",
borderRadius: "10px",
border: "1px #9A9AAF solid",
lineHeight: "21px",
p: " 0 25px 0 14px ",
display: "flex",
alignItems: "center",
width: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
position: "relative"
}}
>
{quiz.config.formContact[type].innerText || placeholder}
<IconButton
onClick={() => drawerNewFieldHC(type)}
sx={{
position: "absolute",
right: "0"
}}>
<GearIcon height="20px" width="20px" color="#7e2aea" />
</IconButton>
</Typography>
<IconButton
onClick={() => updateQuiz(quiz?.id, (quiz) => {
quiz.config.formContact[type].used = false
})}
sx={{
width: "48px",
ml: "5px"
}}
>
<Trash />
</IconButton>
</Box>
</>
)
}
const ButtonsCard = ({ drawerNewFieldHC }: any) => {
const theme = useTheme();
const quiz = useCurrentQuiz()
return (
<Box sx={{ display: "flex", flexDirection: "column", padding: "20px", width: "100%", gap: "20px" }}>
{
buttons.map((contentData) => {
const content = quiz?.config.formContact[contentData.key]
return content.used ? <SettingField drawerNewFieldHC={drawerNewFieldHC} key={contentData.key} type={contentData.key} name={content.text || contentData.name} placeholder={content.innerText || contentData.desc} /> : <></>
})
}
{
(
quiz?.config.formContact.name.used &&
quiz?.config.formContact.email.used &&
quiz?.config.formContact.phone.used &&
quiz?.config.formContact.text.used &&
quiz?.config.formContact.address.used
) ?
<></>
:
<Button
onClick={() => drawerNewFieldHC("all")}
variant="contained"
sx={{ maxWidth: "fit-content", padding: "10px 20px" }}
>
Добавить поле +
</Button>
}
<Link
component="button"
// onClick={() => drawerMessengerHC(true)}
sx={{
fontSize: "16px",
lineHeight: "19px",
color: theme.palette.brightPurple.main,
textDecorationColor: theme.palette.brightPurple.main,
textAlign: "left",
}}
>
Добавить мессенджеры
</Link>
<PseudoButton />
</Box>
)
}
const EmptyCard = ({ drawerNewFieldHC }: { drawerNewFieldHC: (a: string) => void }) => {
const theme = useTheme();
const [FC, setFC] = React.useState(false)
const openFC = () => setFC(true)
const closeFC = () => setFC(false)
const popover = React.useRef(null);
return (
<Box sx={{ display: "flex", flexDirection: "column", padding: "100px 20px 20px 20px", width: "100%", gap: "20px", }}>
<Button
onClick={() => drawerNewFieldHC("all")}
variant="contained" sx={{ maxWidth: "fit-content", padding: "10px 20px" }}>
Добавить поле +
</Button>
<Box sx={{ display: "flex" }}>
<Typography sx={{ color: theme.palette.orange.main }}>Будут показаны поля по умолчанию</Typography>
<Box ref={popover}>
<Info sx={{ ml: "6px", p: "0" }} onClick={openFC} />
</Box>
<Popover
open={FC}
onClose={closeFC}
anchorEl={popover.current}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'center',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'center',
}}
disableRestoreFocus
>
<Typography sx={{ m: "20px", textAlign: "center" }}>
Если вам не нужно собирать контакты, <br></br> отключите форму контактов
</Typography>
</Popover>
</Box>
<Link
sx={{
mt: "20px",
fontSize: "16px",
lineHeight: "19px",
color: theme.palette.brightPurple.main,
textDecorationColor: theme.palette.brightPurple.main,
}}
>
Добавить мессенджеры
</Link>
<PseudoButton />
</Box>
)
}
const PseudoButton = () => {
const quiz = useCurrentQuiz()
return (
<TextField
onChange={({ target }) => {
updateQuiz(quiz.id, (quiz) => {
quiz.config.formContact.button = target.value
})
}}
value={quiz.config.formContact.button}
sx={{
heigth: "44px",
width: "190px",
"& .MuiInputBase-root": {
backgroundColor: "#7E2AEA",
borderRadius: "8px",
color: "white",
},
"& .MuiInputBase-input": {
padding: "10px 20px",
textAlign: "center"
},
"& .MuiInputBase-input::placeholder": {
color: "white",
opacity: "1"
}
}}
placeholder="Название кнопки"
>
{quiz?.config.formContact.button || "Название кнопки"}
</TextField>
)
}

@ -7,18 +7,18 @@ import {SxProps, Theme} from "@mui/material";
interface Props { interface Props {
outerContainerSx?: SxProps<Theme>; outerContainerSx?: SxProps<Theme>;
children?: React.ReactNode; children?: React.ReactNode;
isOpen: boolean; isOpenDrawer: string;
openHC: (arg0: boolean) => void drawerNewFieldHC: (str: string) => void
} }
export default function DrawerNewField({outerContainerSx: sx, children, isOpen, openHC }: Props) { export default function DrawerNewField({outerContainerSx: sx, children, isOpenDrawer: isOpen, drawerNewFieldHC }: Props) {
return ( return (
<> <>
<Drawer <Drawer
anchor='right' anchor='right'
open={isOpen} open={Boolean(isOpen)}
onClose={() => openHC(false)} onClose={() => drawerNewFieldHC("")}
> >
<Box <Box
sx={{ width: 450 }} sx={{ width: 450 }}

@ -6,14 +6,19 @@ import EmailIcon from "@icons/ContactFormIcon/EmailIcon";
import PhoneIcon from "@icons/ContactFormIcon/PhoneIcon"; import PhoneIcon from "@icons/ContactFormIcon/PhoneIcon";
import TextIcon from "@icons/ContactFormIcon/TextIcon"; import TextIcon from "@icons/ContactFormIcon/TextIcon";
import AddressIcon from "@icons/ContactFormIcon/AddressIcon"; import AddressIcon from "@icons/ContactFormIcon/AddressIcon";
import { useCurrentQuiz } from "@root/quizes/hooks";
interface Props { interface Props {
switchState: string switchState: string
SSHC: (data:string) => void SSHC: (data:string) => void
type: string
} }
export default function ButtonsNewField ({SSHC, switchState}:Props) { export default function ButtonsNewField ({SSHC, switchState, type}:Props) {
const theme = useTheme(); const theme = useTheme();
const quiz = useCurrentQuiz()
console.log(quiz)
console.log(type)
const buttonSetting: {icon: JSX.Element; title: string; value: string} [] =[ const buttonSetting: {icon: JSX.Element; title: string; value: string} [] =[
{icon: <NameIcon color={switchState === 'name' ? '#ffffff' : theme.palette.grey3.main}/>, title: 'Имя', value: 'name'}, {icon: <NameIcon color={switchState === 'name' ? '#ffffff' : theme.palette.grey3.main}/>, title: 'Имя', value: 'name'},
{icon: <EmailIcon color={switchState === 'email' ? '#ffffff' : theme.palette.grey3.main}/>, title: 'Email', value: 'email'}, {icon: <EmailIcon color={switchState === 'email' ? '#ffffff' : theme.palette.grey3.main}/>, title: 'Email', value: 'email'},
@ -31,16 +36,20 @@ export default function ButtonsNewField ({SSHC, switchState}:Props) {
}} }}
> >
{buttonSetting.map( (e,i) => ( {buttonSetting.map( (e,i) => (
type === e.value || type === "all" ?
<MiniButtonSetting <MiniButtonSetting
disabled = {quiz?.config.formContact[e.value]?.used}
key={i} key={i}
onClick={()=>{SSHC(e.value)}} onClick={()=>{SSHC(e.value)}}
sx={{backgroundColor: switchState === e.value ? theme.palette.brightPurple.main : 'transparent', sx={{backgroundColor: switchState === e.value ? theme.palette.brightPurple.main : 'transparent',
color: switchState === e.value ? '#ffffff' : theme.palette.grey3.main, color: switchState === e.value && type === "all" ? '#ffffff' : theme.palette.grey3.main,
}} }}
> >
{e.icon} {e.icon}
{e.title} {e.title}
</MiniButtonSetting> </MiniButtonSetting>
:
<></>
))} ))}
</Box> </Box>
) )

@ -1,9 +1,11 @@
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import {FormControl, SxProps, TextField, Theme, Typography} from "@mui/material"; import { FormControl, SxProps, TextField, Theme, Typography } from "@mui/material";
import CustomTextField from "@ui_kit/CustomTextField"; import CustomTextField from "@ui_kit/CustomTextField";
import CustomCheckbox from "@ui_kit/CustomCheckbox"; import CustomCheckbox from "@ui_kit/CustomCheckbox";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import * as React from "react"; import * as React from "react";
import { useCurrentQuiz } from "@root/quizes/hooks";
import { updateQuiz } from "@root/quizes/actions";
interface Props { interface Props {
outerContainerSx?: SxProps<Theme>; outerContainerSx?: SxProps<Theme>;
@ -11,51 +13,88 @@ interface Props {
defaultValue?: string; defaultValue?: string;
placeholderHelp: string; placeholderHelp: string;
placeholderField: string; placeholderField: string;
drawerNewFieldHC:(a:string)=>void
} }
export default function NewFieldParent ({defaultValue, placeholderHelp, placeholderField, outerContainerSx: sx, children}: Props) { export default function NewFieldParent({ drawerNewFieldHC, defaultValue, placeholderHelp, placeholderField, outerContainerSx: sx, children }: Props) {
return( const quiz = useCurrentQuiz()
<Box sx={{padding: '20px', display: 'flex', flexDirection: 'column', gap: '20px'}}> console.log({ defaultValue, placeholderHelp, placeholderField, outerContainerSx: sx, children })
<Box sx={{display: 'flex', flexDirection: 'column', gap: '15px'}}> return (
<Typography>Подсказка</Typography> <Box sx={{ padding: '20px', display: 'flex', flexDirection: 'column', gap: '20px' }}>
<CustomTextField placeholder={placeholderHelp} text={''}/> <Box sx={{ display: 'flex', flexDirection: 'column', gap: '15px' }}>
<Typography
>Подсказка</Typography>
<CustomTextField
onChange={({ target }) => {
updateQuiz(quiz.id, (quiz) => {
quiz.config.formContact[defaultValue].text = target.value
})
}}
value={quiz.config.formContact[defaultValue].text}
placeholder={placeholderHelp} text={''} />
</Box> </Box>
<Box sx={{display: 'flex', flexDirection: 'column', gap: '15px'}}> <Box sx={{ display: 'flex', flexDirection: 'column', gap: '15px' }}>
<Typography>Подсказка внутри поля</Typography> <Typography
<CustomTextField placeholder={placeholderField} text={''}/> >Подсказка внутри поля</Typography>
<CustomTextField
onChange={({ target }) => {
updateQuiz(quiz.id, (quiz) => {
quiz.config.formContact[defaultValue].innerText = target.value
})
}}
value={quiz.config.formContact[defaultValue].innerText}
placeholder={placeholderField} text={''} />
</Box> </Box>
<Box sx={{display: 'flex', flexDirection: 'column', gap: '15px'}}> <Box sx={{ display: 'flex', flexDirection: 'column', gap: '15px' }}>
<Typography>Ключ</Typography> <Typography>Ключ</Typography>
<FormControl <TextField
fullWidth value={quiz.config.formContact[defaultValue].key}
variant="standard" onChange={({ target }) => {
sx={{ p: 0, border: 0 }} updateQuiz(quiz.id, (quiz) => {
> quiz.config.formContact[defaultValue].key = target.value
<TextField })
disabled }}
id="outlined-disabled" placeholder="text"
value={defaultValue} sx={{
sx={{ "& .css-1d3z3hw-MuiOutlinedInput-notchedOutline": {
"& .css-1d3z3hw-MuiOutlinedInput-notchedOutline": { border: 'none'
border: 'none' },
}, "& .MuiInputBase-root": {
"& .MuiInputBase-root": { height: "48px",
height: "48px", borderRadius: "10px",
borderRadius: "10px", backgroundColor: '#EEE4FC',
backgroundColor: '#EEE4FC', },
}, }}
}}
/> />
</FormControl> <CustomCheckbox
<CustomCheckbox label={"Обязательно к заполнению"}/> checked={quiz.config.formContact[defaultValue].required}
handleChange={({ target }) => {
console.log("click")
updateQuiz(quiz.id, (quiz) => {
quiz.config.formContact[defaultValue].required = target.checked
})
}}
label={"Обязательно к заполнению"} />
</Box> </Box>
<Box> {/* <Box>
<Typography>Запрашивать на</Typography> <Typography>Запрашивать на</Typography>
<CustomCheckbox label={'Шаг 1'}/> <CustomCheckbox label={'Шаг 1'}/>
<CustomCheckbox label={'Шаг 2'}/> <CustomCheckbox label={'Шаг 2'}/>
</Box> </Box> */}
{children} {children}
<Button variant='contained' sx={{maxWidth: '125px'}}>Добавить</Button> <Button
onClick={() => {
updateQuiz(quiz.id, (quiz) => {
quiz.config.formContact[defaultValue].used = true
})
drawerNewFieldHC("")
}}
variant='contained' sx={{ maxWidth: '125px' }}>Добавить</Button>
</Box> </Box>
) )
} }

@ -8,10 +8,11 @@ import CustomizedSwitch from "@ui_kit/CustomSwitch";
interface Props { interface Props {
switchState: string, switchState: string,
drawerNewFieldHC:(a:string)=>void
} }
export default function SwitchNewField({switchState ='name'}: Props) { export default function SwitchNewField({switchState ='name', drawerNewFieldHC}: Props) {
const [SwitchMask, setSwitchMask] = React.useState(false); const [SwitchMask, setSwitchMask] = React.useState(false);
const SwitchMaskHC = (bool:boolean) => { const SwitchMaskHC = (bool:boolean) => {
setSwitchMask(bool) setSwitchMask(bool)
@ -19,16 +20,16 @@ export default function SwitchNewField({switchState ='name'}: Props) {
switch (switchState) { switch (switchState) {
case 'name': case 'name':
return (<NewFieldParent placeholderHelp={'Введите имя'} placeholderField={'Дмитрий'} defaultValue={'name'}/>); return (<NewFieldParent drawerNewFieldHC={drawerNewFieldHC} placeholderHelp={'Введите имя'} placeholderField={'Дмитрий'} defaultValue={'name'}/>);
break; break;
case 'email': case 'email':
return (<NewFieldParent placeholderHelp={'Введите Email'} placeholderField={'mail@example.ru'} defaultValue={'email'}/>); return (<NewFieldParent drawerNewFieldHC={drawerNewFieldHC} placeholderHelp={'Введите Email'} placeholderField={'mail@example.ru'} defaultValue={'email'}/>);
break; break;
case 'phone': case 'phone':
return ( return (
<NewFieldParent placeholderHelp={'Введите номер'} placeholderField={'+7 900 000 00 00'} defaultValue={'phone'}> <NewFieldParent drawerNewFieldHC={drawerNewFieldHC} placeholderHelp={'Введите номер'} placeholderField={'+7 900 000 00 00'} defaultValue={'phone'}>
<FormControlLabel {/* <FormControlLabel
value="start" value="start"
control={<CustomizedSwitch/>} control={<CustomizedSwitch/>}
label="Маска для телефона" label="Маска для телефона"
@ -41,7 +42,7 @@ export default function SwitchNewField({switchState ='name'}: Props) {
SwitchMaskHC(!SwitchMask) SwitchMaskHC(!SwitchMask)
}} }}
/> /> */}
{SwitchMask ? {SwitchMask ?
<SelectMask/> <SelectMask/>
@ -52,10 +53,10 @@ export default function SwitchNewField({switchState ='name'}: Props) {
); );
break; break;
case 'text': case 'text':
return (<NewFieldParent placeholderHelp={'Введите фамилию'} placeholderField={'Иванов'} defaultValue={'text'}/>); return (<NewFieldParent drawerNewFieldHC={drawerNewFieldHC} placeholderHelp={'Введите фамилию'} placeholderField={'Иванов'} defaultValue={'text'}/>);
break; break;
case 'address': case 'address':
return (<NewFieldParent placeholderHelp={'Введите адрес'} placeholderField={'Москва, Лаврушинский пер., 10'} defaultValue={'address'}/>); return (<NewFieldParent drawerNewFieldHC={drawerNewFieldHC} placeholderHelp={'Введите адрес'} placeholderField={'Москва, Лаврушинский пер., 10'} defaultValue={'address'}/>);
break; break;
default: default:
return (<></>) return (<></>)

@ -1,29 +1,44 @@
import * as React from 'react'; import * as React from 'react';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import {Typography, useTheme} from "@mui/material"; import { Typography, useTheme } from "@mui/material";
import CloseIcon from '@mui/icons-material/Close'; import CloseIcon from '@mui/icons-material/Close';
import ButtonsNewField from "./ButtonsNewField"; import ButtonsNewField from "./ButtonsNewField";
import SwitchNewField from "./SwitchNewField"; import SwitchNewField from "./SwitchNewField";
import { useCurrentQuiz } from '@root/quizes/hooks';
export default function WindowNewField() { export default function WindowNewField({ type, drawerNewFieldHC }: { type: string, drawerNewFieldHC: (a: string) => void }) {
const quiz = useCurrentQuiz()
const theme = useTheme(); const theme = useTheme();
const [switchState, setSwitchState] = React.useState('name'); const [switchState, setSwitchState] = React.useState("");
React.useEffect(() => {
for (let val in quiz?.config.formContact) {
console.log(quiz?.config.formContact)
console.log(quiz?.config.formContact[val])
console.log(quiz?.config.formContact[val].used)
if (!quiz?.config.formContact[val].used) {
setSwitchState(val)
return
}
}
}, [])
const SSHC = (data: string) => { const SSHC = (data: string) => {
setSwitchState(data) setSwitchState(data)
} }
console.log(switchState)
return( return (
<> <>
<Box sx={{padding: '10px 10px 10px 20px', display: 'flex', justifyContent: 'space-between', alignItems: 'center', background: theme.palette.background.default}}> <Box sx={{ padding: '10px 10px 10px 20px', display: 'flex', justifyContent: 'space-between', alignItems: 'center', background: theme.palette.background.default }}>
<Typography>Новое поле</Typography> <Typography>Новое поле</Typography>
<Button sx={{padding: 0}}><CloseIcon fontSize='large'/></Button> <Button onClick={() => drawerNewFieldHC("")} sx={{ padding: 0 }}><CloseIcon fontSize='large' /></Button>
</Box> </Box>
<Box><ButtonsNewField switchState={switchState} SSHC={SSHC}/></Box> <Box><ButtonsNewField type={type} switchState={switchState} SSHC={SSHC} /></Box>
<SwitchNewField switchState={switchState}/> <SwitchNewField switchState={switchState} drawerNewFieldHC={drawerNewFieldHC} />
</> </>
) )
} }

@ -29,10 +29,9 @@ import { useEffect, useState } from "react";
import { Link, useNavigate } from "react-router-dom"; import { Link, useNavigate } from "react-router-dom";
import useSWR from "swr"; import useSWR from "swr";
import { SidebarMobile } from "./Sidebar/SidebarMobile"; import { SidebarMobile } from "./Sidebar/SidebarMobile";
import { cleanQuestions } from "@root/questions/actions"; import { cleanQuestions, setQuestions } from "@root/questions/actions";
import { updateOpenBranchingPanel } from "@root/uiTools/actions"; import { updateOpenBranchingPanel } from "@root/uiTools/actions";
import { BranchingPanel } from "../Questions/BranchingPanel"; import { BranchingPanel } from "../Questions/BranchingPanel";
import { setQuestions } from "@root/questions/actions";
import { useQuestionsStore } from "@root/questions/store"; import { useQuestionsStore } from "@root/questions/store";
import { useQuizes } from "@root/quizes/hooks"; import { useQuizes } from "@root/quizes/hooks";
import { questionApi } from "@api/question"; import { questionApi } from "@api/question";
@ -52,6 +51,7 @@ export default function EditPage() {
const questions = await questionApi.getList({ quiz_id: editQuizId }) const questions = await questionApi.getList({ quiz_id: editQuizId })
setQuestions(questions) setQuestions(questions)
} }
getData() getData()
}, []) }, [])

@ -553,3 +553,4 @@ export const createBackResult = async (
enqueueSnackbar("Не удалось создать вопрос"); enqueueSnackbar("Не удалось создать вопрос");
} }
}); });

@ -32,7 +32,7 @@ export default function SwitchStepPages({
} }
case 1: return quizType === "form" ? <FormQuestionsPage /> : <QuestionsPage />; case 1: return quizType === "form" ? <FormQuestionsPage /> : <QuestionsPage />;
case 2: return <ResultPage />; case 2: return <ResultPage />;
case 3: return <QuestionsMap />; case 3: return <ContactFormPage />;
case 4: return <ContactFormPage />; case 4: return <ContactFormPage />;
case 5: return <InstallQuiz />; case 5: return <InstallQuiz />;
case 6: return <>Реклама</>; case 6: return <>Реклама</>;