Merge branch 'dev' into delete-modal
This commit is contained in:
commit
c161559e14
104
src/App.tsx
104
src/App.tsx
@ -5,7 +5,7 @@ import "dayjs/locale/ru";
|
||||
import SigninDialog from "./pages/auth/Signin";
|
||||
import SignupDialog from "./pages/auth/Signup";
|
||||
import { ViewPage } from "./pages/ViewPublicationPage";
|
||||
import { BrowserRouter, Route, Routes, useLocation, useNavigate, Navigate } from "react-router-dom";
|
||||
import { Route, Routes, useLocation, useNavigate, Navigate } from "react-router-dom";
|
||||
import "./index.css";
|
||||
import ContactFormPage from "./pages/ContactFormPage/ContactFormPage";
|
||||
import InstallQuiz from "./pages/InstallQuiz/InstallQuiz";
|
||||
@ -21,61 +21,65 @@ import { clearUserData, setUser, useUserStore } from "@root/user";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import PrivateRoute from "@ui_kit/PrivateRoute";
|
||||
|
||||
import { Restore } from "./pages/startPage/Restore";
|
||||
|
||||
dayjs.locale("ru");
|
||||
|
||||
const routeslink = [
|
||||
{ path: "/list", page: <MyQuizzesFull />, header: false, sidebar: false },
|
||||
{ path: "/questions/:quizId", page: <QuestionsPage />, header: true, sidebar: true, },
|
||||
{ path: "/contacts", page: <ContactFormPage />, header: true, sidebar: true },
|
||||
{ path: "/result", page: <Result />, header: true, sidebar: true },
|
||||
{ path: "/settings", page: <ResultSettings />, header: true, sidebar: true },
|
||||
{ path: "/install", page: <InstallQuiz />, header: true, sidebar: true },
|
||||
{ path: "/list", page: <MyQuizzesFull />, header: false, sidebar: false },
|
||||
{ path: "/questions/:quizId", page: <QuestionsPage />, header: true, sidebar: true },
|
||||
{ path: "/contacts", page: <ContactFormPage />, header: true, sidebar: true },
|
||||
{ path: "/result", page: <Result />, header: true, sidebar: true },
|
||||
{ path: "/settings", page: <ResultSettings />, header: true, sidebar: true },
|
||||
{ path: "/install", page: <InstallQuiz />, header: true, sidebar: true },
|
||||
] as const;
|
||||
|
||||
export default function App() {
|
||||
const userId = useUserStore((state) => state.userId);
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
const userId = useUserStore((state) => state.userId);
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useUserFetcher({
|
||||
url: `https://hub.pena.digital/user/${userId}`,
|
||||
userId,
|
||||
onNewUser: setUser,
|
||||
onError: (error) => {
|
||||
const errorMessage = getMessageFromFetchError(error);
|
||||
if (errorMessage) {
|
||||
enqueueSnackbar(errorMessage);
|
||||
clearUserData();
|
||||
clearAuthToken();
|
||||
}
|
||||
},
|
||||
});
|
||||
if (location.state?.redirectTo)
|
||||
return <Navigate to={location.state.redirectTo} replace state={{ backgroundLocation: location }} />;
|
||||
useUserFetcher({
|
||||
url: `https://hub.pena.digital/user/${userId}`,
|
||||
userId,
|
||||
onNewUser: setUser,
|
||||
onError: (error) => {
|
||||
const errorMessage = getMessageFromFetchError(error);
|
||||
if (errorMessage) {
|
||||
enqueueSnackbar(errorMessage);
|
||||
clearUserData();
|
||||
clearAuthToken();
|
||||
}
|
||||
},
|
||||
});
|
||||
if (location.state?.redirectTo)
|
||||
return <Navigate to={location.state.redirectTo} replace state={{ backgroundLocation: location }} />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContactFormModal />
|
||||
{location.state?.backgroundLocation && (
|
||||
<Routes>
|
||||
<Route path="/signin" element={<SigninDialog />} />
|
||||
<Route path="/signup" element={<SignupDialog />} />
|
||||
</Routes>
|
||||
)}
|
||||
<Routes location={location.state?.backgroundLocation || location}>
|
||||
<Route path="/" element={<Landing />} />
|
||||
<Route path="/signin" element={<Navigate to="/" replace state={{ redirectTo: "/signin" }} />} />
|
||||
<Route path="/signup" element={<Navigate to="/" replace state={{ redirectTo: "/signup" }} />} />
|
||||
<Route element={<PrivateRoute />}>
|
||||
{routeslink.map((e, i) => (
|
||||
<Route key={i} path={e.path} element={<Main page={e.page} header={e.header} sidebar={e.sidebar} />} />
|
||||
))}
|
||||
<Route path="edit" element={<EditPage />} />
|
||||
<Route path="crop" element={<ImageCrop />} />
|
||||
<Route path="/view" element={<ViewPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<ContactFormModal />
|
||||
{location.state?.backgroundLocation && (
|
||||
<Routes>
|
||||
<Route path="/signin" element={<SigninDialog />} />
|
||||
<Route path="/signup" element={<SignupDialog />} />
|
||||
<Route path="/restore" element={<Restore />} />
|
||||
</Routes>
|
||||
)}
|
||||
<Routes location={location.state?.backgroundLocation || location}>
|
||||
<Route path="/" element={<Landing />} />
|
||||
<Route path="/signin" element={<Navigate to="/" replace state={{ redirectTo: "/signin" }} />} />
|
||||
<Route path="/signup" element={<Navigate to="/" replace state={{ redirectTo: "/signup" }} />} />
|
||||
<Route path="/restore" element={<Navigate to="/" replace state={{ redirectTo: "/restore" }} />} />
|
||||
<Route element={<PrivateRoute />}>
|
||||
{routeslink.map((e, i) => (
|
||||
<Route key={i} path={e.path} element={<Main page={e.page} header={e.header} sidebar={e.sidebar} />} />
|
||||
))}
|
||||
|
||||
<Route path="edit" element={<EditPage />} />
|
||||
<Route path="crop" element={<ImageCrop />} />
|
||||
<Route path="/view" element={<ViewPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ const buttons = [
|
||||
},
|
||||
{
|
||||
name: "Email",
|
||||
desc: "mail@xample.ru",
|
||||
desc: "mail@example.ru",
|
||||
key: "email"
|
||||
},
|
||||
{
|
||||
@ -297,7 +297,7 @@ const ButtonsCard = ({ drawerNewFieldHC }: any) => {
|
||||
Добавить поле +
|
||||
</Button>
|
||||
}
|
||||
<Link
|
||||
{/* <Link
|
||||
component="button"
|
||||
// onClick={() => drawerMessengerHC(true)}
|
||||
sx={{
|
||||
@ -309,7 +309,7 @@ const ButtonsCard = ({ drawerNewFieldHC }: any) => {
|
||||
}}
|
||||
>
|
||||
Добавить мессенджеры
|
||||
</Link>
|
||||
</Link> */}
|
||||
|
||||
<PseudoButton />
|
||||
</Box>
|
||||
@ -355,7 +355,7 @@ const EmptyCard = ({ drawerNewFieldHC }: { drawerNewFieldHC: (a: string) => void
|
||||
|
||||
</Popover>
|
||||
</Box>
|
||||
<Link
|
||||
{/* <Link
|
||||
sx={{
|
||||
mt: "20px",
|
||||
fontSize: "16px",
|
||||
@ -365,7 +365,7 @@ const EmptyCard = ({ drawerNewFieldHC }: { drawerNewFieldHC: (a: string) => void
|
||||
}}
|
||||
>
|
||||
Добавить мессенджеры
|
||||
</Link>
|
||||
</Link> */}
|
||||
<PseudoButton />
|
||||
</Box>
|
||||
)
|
||||
|
@ -51,7 +51,6 @@ type Popper = {
|
||||
type NodeSingularWithPopper = NodeSingular & {
|
||||
popper: (config: PopperConfig) => Popper;
|
||||
};
|
||||
let counter = 0;
|
||||
|
||||
const stylesheet: Stylesheet[] = [
|
||||
{
|
||||
@ -161,7 +160,6 @@ function CsComponent({
|
||||
}, [modalQuestionTargetContentId])
|
||||
|
||||
const addNode = ({ parentNodeContentId, targetNodeContentId }: { parentNodeContentId: string, targetNodeContentId?: string }) => {
|
||||
console.log('AN', counter++, parentNodeContentId,targetNodeContentId)
|
||||
|
||||
//запрещаем работу родителя-ребенка если это один и тот же вопрос
|
||||
if (parentNodeContentId === targetNodeContentId) return
|
||||
@ -171,7 +169,6 @@ console.log('AN', counter++, parentNodeContentId,targetNodeContentId)
|
||||
const parentNodeChildren = cy?.$('edge[source = "' + parentNodeContentId + '"]')?.length
|
||||
//если есть инфо о выбранном вопросе из модалки - берём родителя из инфо модалки. Иначе из значения дропа
|
||||
const targetQuestion = { ...getQuestionByContentId(targetNodeContentId || dragQuestionContentId) } as AnyTypedQuizQuestion
|
||||
console.log('AN1', targetQuestion, parentNodeContentId,parentNodeChildren)
|
||||
if (Object.keys(targetQuestion).length !== 0 && parentNodeContentId && parentNodeChildren !== undefined) {
|
||||
clearDataAfterAddNode({ parentNodeContentId, targetQuestion, parentNodeChildren })
|
||||
cy?.data('changed', true)
|
||||
@ -199,13 +196,13 @@ console.log('AN1', targetQuestion, parentNodeContentId,parentNodeChildren)
|
||||
|
||||
const clearDataAfterAddNode = ({ parentNodeContentId, targetQuestion, parentNodeChildren }: { parentNodeContentId: string, targetQuestion: AnyTypedQuizQuestion, parentNodeChildren: number }) => {
|
||||
|
||||
console.log('AN2', parentNodeContentId,parentNodeChildren,targetQuestion)
|
||||
const parentQuestion = { ...getQuestionByContentId(parentNodeContentId) } as AnyTypedQuizQuestion
|
||||
|
||||
|
||||
//смотрим не добавлен ли родителю result. Если да - убираем его. Веточкам result не нужен
|
||||
trashQuestions.forEach((targetQuestion) => {
|
||||
if (targetQuestion.type === "result" && targetQuestion.content.rule.parentId === parentQuestion.content.id) {
|
||||
console.log('deleteQ', targetQuestion.id)
|
||||
deleteQuestion(targetQuestion.id);
|
||||
}
|
||||
})
|
||||
|
@ -5,80 +5,77 @@ import { Draggable } from "react-beautiful-dnd";
|
||||
import { AnyTypedQuizQuestion, UntypedQuizQuestion } from "../../../../model/questionTypes/shared";
|
||||
import QuestionsPageCard from "./QuestionPageCard";
|
||||
|
||||
|
||||
type FormDraggableListItemProps = {
|
||||
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
||||
questionIndex: number;
|
||||
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
||||
questionIndex: number;
|
||||
};
|
||||
|
||||
export default memo(
|
||||
({ question, questionIndex }: FormDraggableListItemProps) => {
|
||||
const theme = useTheme();
|
||||
export default memo(({ question, questionIndex }: FormDraggableListItemProps) => {
|
||||
const theme = useTheme();
|
||||
|
||||
return (
|
||||
<Draggable draggableId={String(questionIndex)} index={questionIndex}>
|
||||
{(provided) => (
|
||||
<ListItem
|
||||
ref={provided.innerRef}
|
||||
{...(questionIndex !== 0 ? provided.draggableProps : {})}
|
||||
sx={{ userSelect: "none", padding: 0 }}
|
||||
>
|
||||
{question.deleted ? (
|
||||
<Box
|
||||
{...provided.dragHandleProps}
|
||||
sx={{
|
||||
width: "100%",
|
||||
maxWidth: "800px",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
marginTop: "30px",
|
||||
gap: "5px",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "16px",
|
||||
color: theme.palette.grey2.main,
|
||||
}}
|
||||
>
|
||||
Вопрос удалён.
|
||||
</Typography>
|
||||
<Typography
|
||||
onClick={() => {
|
||||
updateQuestion(question.id, question => {
|
||||
question.deleted = false;
|
||||
});
|
||||
}}
|
||||
sx={{
|
||||
cursor: "pointer",
|
||||
fontSize: "16px",
|
||||
textDecoration: "underline",
|
||||
color: theme.palette.brightPurple.main,
|
||||
textDecorationColor: theme.palette.brightPurple.main,
|
||||
}}
|
||||
>
|
||||
Восстановить?
|
||||
</Typography>
|
||||
</Box>
|
||||
) : (
|
||||
<Box
|
||||
sx={{
|
||||
width: "100%",
|
||||
position: "relative",
|
||||
borderBottom: "1px solid rgba(0, 0, 0, 0.23)",
|
||||
}}
|
||||
>
|
||||
<QuestionsPageCard
|
||||
key={questionIndex}
|
||||
question={question}
|
||||
questionIndex={questionIndex}
|
||||
draggableProps={provided.dragHandleProps}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</ListItem>
|
||||
)}
|
||||
</Draggable>
|
||||
);
|
||||
}
|
||||
);
|
||||
return (
|
||||
<Draggable draggableId={String(questionIndex)} index={questionIndex}>
|
||||
{(provided) => (
|
||||
<ListItem
|
||||
ref={provided.innerRef}
|
||||
{...(questionIndex !== 0 ? provided.draggableProps : {})}
|
||||
sx={{ userSelect: "none", padding: 0 }}
|
||||
>
|
||||
{question.deleted ? (
|
||||
<Box
|
||||
{...provided.dragHandleProps}
|
||||
sx={{
|
||||
width: "100%",
|
||||
maxWidth: "800px",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
marginTop: "30px",
|
||||
gap: "5px",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
sx={{
|
||||
fontSize: "16px",
|
||||
color: theme.palette.grey2.main,
|
||||
}}
|
||||
>
|
||||
Вопрос удалён.
|
||||
</Typography>
|
||||
<Typography
|
||||
onClick={() => {
|
||||
updateQuestion(question.id, (question) => {
|
||||
question.deleted = false;
|
||||
});
|
||||
}}
|
||||
sx={{
|
||||
cursor: "pointer",
|
||||
fontSize: "16px",
|
||||
textDecoration: "underline",
|
||||
color: theme.palette.brightPurple.main,
|
||||
textDecorationColor: theme.palette.brightPurple.main,
|
||||
}}
|
||||
>
|
||||
Восстановить?
|
||||
</Typography>
|
||||
</Box>
|
||||
) : (
|
||||
<Box
|
||||
sx={{
|
||||
width: "100%",
|
||||
position: "relative",
|
||||
borderBottom: "1px solid rgba(0, 0, 0, 0.23)",
|
||||
}}
|
||||
>
|
||||
<QuestionsPageCard
|
||||
key={questionIndex}
|
||||
question={question}
|
||||
questionIndex={questionIndex}
|
||||
draggableProps={provided.dragHandleProps}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
</ListItem>
|
||||
)}
|
||||
</Draggable>
|
||||
);
|
||||
});
|
||||
|
@ -11,8 +11,8 @@ import OptionsPict from "@icons/questionsPage/options_pict";
|
||||
import Page from "@icons/questionsPage/page";
|
||||
import RatingIcon from "@icons/questionsPage/rating";
|
||||
import Slider from "@icons/questionsPage/slider";
|
||||
import { Box, InputAdornment, Paper } from "@mui/material";
|
||||
import { updateQuestion, updateUntypedQuestion } from "@root/questions/actions";
|
||||
import { Box, FormControlLabel, IconButton, InputAdornment, Paper, useMediaQuery, useTheme } from "@mui/material";
|
||||
import { toggleExpandQuestion, updateQuestion, updateUntypedQuestion } from "@root/questions/actions";
|
||||
import CustomTextField from "@ui_kit/CustomTextField";
|
||||
import { useRef, useState } from "react";
|
||||
import type { DraggableProvidedDragHandleProps } from "react-beautiful-dnd";
|
||||
@ -22,142 +22,206 @@ import SwitchQuestionsPage from "../../SwitchQuestionsPage";
|
||||
import { ChooseAnswerModal } from "./ChooseAnswerModal";
|
||||
import FormTypeQuestions from "../FormTypeQuestions";
|
||||
import { QuestionType } from "@model/question/question";
|
||||
|
||||
import { CrossedEyeIcon } from "@icons/CrossedEyeIcon";
|
||||
import { ArrowDownIcon } from "@icons/questionsPage/ArrowDownIcon";
|
||||
import { CopyIcon } from "@icons/questionsPage/CopyIcon";
|
||||
import { DeleteIcon } from "@icons/questionsPage/deleteIcon";
|
||||
import { HideIcon } from "@icons/questionsPage/hideIcon";
|
||||
import ExpandLessIcon from "@mui/icons-material/ExpandLess";
|
||||
import { NoLuggageOutlined, SignalCellularNullOutlined } from "@mui/icons-material";
|
||||
|
||||
interface Props {
|
||||
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
||||
questionIndex: number;
|
||||
draggableProps: DraggableProvidedDragHandleProps | null | undefined;
|
||||
question: AnyTypedQuizQuestion | UntypedQuizQuestion;
|
||||
questionIndex: number;
|
||||
draggableProps: DraggableProvidedDragHandleProps | null | undefined;
|
||||
}
|
||||
|
||||
export default function QuestionsPageCard({
|
||||
question,
|
||||
questionIndex,
|
||||
draggableProps,
|
||||
}: Props) {
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const anchorRef = useRef(null);
|
||||
export default function QuestionsPageCard({ question, questionIndex, draggableProps }: Props) {
|
||||
const [open, setOpen] = useState<boolean>(false);
|
||||
const anchorRef = useRef(null);
|
||||
const theme = useTheme();
|
||||
const isTablet = useMediaQuery(theme.breakpoints.down(1000));
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
||||
|
||||
const setTitle = useDebouncedCallback((title) => {
|
||||
const updateQuestionFn = question.type === null ? updateUntypedQuestion : updateQuestion;
|
||||
const setTitle = useDebouncedCallback((title) => {
|
||||
const updateQuestionFn = question.type === null ? updateUntypedQuestion : updateQuestion;
|
||||
|
||||
updateQuestionFn(question.id, question => {
|
||||
question.title = title;
|
||||
});
|
||||
}, 200);
|
||||
updateQuestionFn(question.id, (question) => {
|
||||
question.title = title;
|
||||
});
|
||||
}, 200);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Paper
|
||||
sx={{
|
||||
overflow: "hidden",
|
||||
maxWidth: "796px",
|
||||
width: "100%",
|
||||
backgroundColor: "white",
|
||||
border: "none",
|
||||
boxShadow: "none",
|
||||
paddingBottom: "20px",
|
||||
borderRadius: "0",
|
||||
borderTopLeftRadius: "12px",
|
||||
borderTopRightRadius: "12px",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
padding: 0,
|
||||
}}
|
||||
>
|
||||
<CustomTextField
|
||||
placeholder={`Заголовок ${questionIndex + 1} вопроса`}
|
||||
text={question.title}
|
||||
onChange={({ target }) => setTitle(target.value)}
|
||||
sx={{ margin: "20px", width: "auto" }}
|
||||
InputProps={{
|
||||
startAdornment: (
|
||||
<Box>
|
||||
<InputAdornment
|
||||
ref={anchorRef}
|
||||
position="start"
|
||||
sx={{ cursor: "pointer" }}
|
||||
onClick={() => setOpen((isOpened) => !isOpened)}
|
||||
>
|
||||
{IconAndrom(question.type)}
|
||||
</InputAdornment>
|
||||
<ChooseAnswerModal
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
anchorRef={anchorRef}
|
||||
question={question}
|
||||
questionType={question.type}
|
||||
/>
|
||||
</Box>
|
||||
),
|
||||
endAdornment: (
|
||||
<Box {...draggableProps}>
|
||||
{questionIndex !== 0 && (
|
||||
<InputAdornment position="start">
|
||||
<PointsIcon
|
||||
style={{ color: "#9A9AAF", fontSize: "30px" }}
|
||||
/>
|
||||
</InputAdornment>
|
||||
)}
|
||||
</Box>
|
||||
),
|
||||
}}
|
||||
return (
|
||||
<>
|
||||
<Paper
|
||||
sx={{
|
||||
overflow: "hidden",
|
||||
maxWidth: "796px",
|
||||
width: "100%",
|
||||
backgroundColor: "white",
|
||||
border: "none",
|
||||
boxShadow: "none",
|
||||
paddingBottom: "20px",
|
||||
borderRadius: "0",
|
||||
borderTopLeftRadius: "12px",
|
||||
borderTopRightRadius: "12px",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
p: 0,
|
||||
flexDirection: "column",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
margin: "20px",
|
||||
gap: "18px",
|
||||
flexDirection: isMobile ? "column-reverse" : null,
|
||||
}}
|
||||
>
|
||||
<CustomTextField
|
||||
placeholder={`Заголовок ${questionIndex + 1} вопроса`}
|
||||
text={question.title}
|
||||
onChange={({ target }) => setTitle(target.value)}
|
||||
sx={{ width: "100%" }}
|
||||
InputProps={{
|
||||
startAdornment: (
|
||||
<Box>
|
||||
<InputAdornment
|
||||
ref={anchorRef}
|
||||
position="start"
|
||||
sx={{ cursor: "pointer" }}
|
||||
onClick={() => setOpen((isOpened) => !isOpened)}
|
||||
>
|
||||
{IconAndrom(question.type)}
|
||||
</InputAdornment>
|
||||
<ChooseAnswerModal
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
anchorRef={anchorRef}
|
||||
question={question}
|
||||
questionType={question.type}
|
||||
/>
|
||||
{question.type === null ? (
|
||||
<FormTypeQuestions question={question} />
|
||||
) : (
|
||||
<SwitchQuestionsPage question={question} />
|
||||
)}
|
||||
</Box>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
width: isMobile ? "100%" : "auto",
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
flexDirection: isMobile ? "row-reverse" : null,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "4px",
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
sx={{ padding: "0", margin: "5px" }}
|
||||
disableRipple
|
||||
data-cy="expand-question"
|
||||
onClick={() => toggleExpandQuestion(question.id)}
|
||||
>
|
||||
{question.expanded ? (
|
||||
<ArrowDownIcon
|
||||
style={{
|
||||
width: "18px",
|
||||
color: "#4D4D4D",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<ExpandLessIcon
|
||||
sx={{
|
||||
boxSizing: "border-box",
|
||||
fill: theme.palette.brightPurple.main,
|
||||
background: "#FFF",
|
||||
borderRadius: "6px",
|
||||
height: "30px",
|
||||
width: "30px",
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</IconButton>
|
||||
|
||||
<Box
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
height: "30px",
|
||||
width: "30px",
|
||||
marginLeft: "3px",
|
||||
borderRadius: "50%",
|
||||
fontSize: "16px",
|
||||
color: question.expanded ? theme.palette.brightPurple.main : "#FFF",
|
||||
background: question.expanded ? "#EEE4FC" : theme.palette.brightPurple.main,
|
||||
}}
|
||||
>
|
||||
{questionIndex + 1}
|
||||
</Box>
|
||||
</Paper>
|
||||
</>
|
||||
);
|
||||
</Box>
|
||||
|
||||
<IconButton
|
||||
disableRipple
|
||||
sx={{
|
||||
padding: isMobile ? "0" : "0 5px",
|
||||
right: isMobile ? "0" : null,
|
||||
bottom: isMobile ? "0" : null,
|
||||
}}
|
||||
{...draggableProps}
|
||||
>
|
||||
<PointsIcon style={{ color: "#4D4D4D", fontSize: "30px" }} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{question.type === null ? (
|
||||
<FormTypeQuestions question={question} />
|
||||
) : (
|
||||
<SwitchQuestionsPage question={question} />
|
||||
)}
|
||||
</Box>
|
||||
</Paper>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const IconAndrom = (questionType: QuestionType | null) => {
|
||||
switch (questionType) {
|
||||
case "variant":
|
||||
return <Answer color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "images":
|
||||
return (
|
||||
<OptionsPict color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />
|
||||
);
|
||||
case "varimg":
|
||||
return (
|
||||
<OptionsAndPict
|
||||
color="#9A9AAF"
|
||||
sx={{ height: "22px", width: "20px" }}
|
||||
/>
|
||||
);
|
||||
case "emoji":
|
||||
return <Emoji color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "text":
|
||||
return <Input color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "select":
|
||||
return (
|
||||
<DropDown color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />
|
||||
);
|
||||
case "date":
|
||||
return <Date color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "number":
|
||||
return <Slider color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "file":
|
||||
return (
|
||||
<Download color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />
|
||||
);
|
||||
case "page":
|
||||
return <Page color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "rating":
|
||||
return (
|
||||
<RatingIcon color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />
|
||||
);
|
||||
default:
|
||||
return (
|
||||
<AnswerGroup color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />
|
||||
);
|
||||
}
|
||||
switch (questionType) {
|
||||
case "variant":
|
||||
return <Answer color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "images":
|
||||
return <OptionsPict color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "varimg":
|
||||
return <OptionsAndPict color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "emoji":
|
||||
return <Emoji color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "text":
|
||||
return <Input color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "select":
|
||||
return <DropDown color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "date":
|
||||
return <Date color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "number":
|
||||
return <Slider color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "file":
|
||||
return <Download color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "page":
|
||||
return <Page color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
case "rating":
|
||||
return <RatingIcon color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
default:
|
||||
return <AnswerGroup color="#9A9AAF" sx={{ height: "22px", width: "20px" }} />;
|
||||
}
|
||||
};
|
||||
|
@ -5,31 +5,25 @@ import { DragDropContext, Droppable } from "react-beautiful-dnd";
|
||||
import FormDraggableListItem from "./FormDraggableListItem";
|
||||
import { useQuestions } from "@root/questions/hooks";
|
||||
|
||||
|
||||
export const FormDraggableList = () => {
|
||||
const { questions } = useQuestions();
|
||||
|
||||
const { questions } = useQuestions()
|
||||
|
||||
const onDragEnd = ({ destination, source }: DropResult) => {
|
||||
if (destination) reorderQuestions(source.index, destination.index);
|
||||
};
|
||||
const onDragEnd = ({ destination, source }: DropResult) => {
|
||||
if (destination) reorderQuestions(source.index, destination.index);
|
||||
};
|
||||
|
||||
return (
|
||||
<DragDropContext onDragEnd={onDragEnd}>
|
||||
<Droppable droppableId="droppable-list">
|
||||
{(provided) => (
|
||||
<Box ref={provided.innerRef} {...provided.droppableProps}>
|
||||
{questions?.map((question, index) => (
|
||||
<FormDraggableListItem
|
||||
key={question.id}
|
||||
question={question}
|
||||
questionIndex={index}
|
||||
/>
|
||||
))}
|
||||
{provided.placeholder}
|
||||
</Box>
|
||||
)}
|
||||
</Droppable>
|
||||
</DragDropContext>
|
||||
);
|
||||
return (
|
||||
<DragDropContext onDragEnd={onDragEnd}>
|
||||
<Droppable droppableId="droppable-list">
|
||||
{(provided) => (
|
||||
<Box ref={provided.innerRef} {...provided.droppableProps}>
|
||||
{questions?.map((question, index) => (
|
||||
<FormDraggableListItem key={question.id} question={question} questionIndex={index} />
|
||||
))}
|
||||
{provided.placeholder}
|
||||
</Box>
|
||||
)}
|
||||
</Droppable>
|
||||
</DragDropContext>
|
||||
);
|
||||
};
|
||||
|
@ -8,106 +8,103 @@ import { FormDraggableList } from "./FormDraggableList";
|
||||
import { collapseAllQuestions, createUntypedQuestion } from "@root/questions/actions";
|
||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
|
||||
|
||||
export default function FormQuestionsPage() {
|
||||
const theme = useTheme();
|
||||
const quiz = useCurrentQuiz();
|
||||
const theme = useTheme();
|
||||
const quiz = useCurrentQuiz();
|
||||
|
||||
if (!quiz) return null;
|
||||
if (!quiz) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
sx={{
|
||||
maxWidth: "796px",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
margin: "60px 0 40px 0",
|
||||
}}
|
||||
>
|
||||
<Typography variant={"h5"}>Заголовок анкеты</Typography>
|
||||
<Button
|
||||
sx={{
|
||||
fontSize: "16px",
|
||||
lineHeight: "19px",
|
||||
padding: 0,
|
||||
textDecoration: "underline",
|
||||
color: theme.palette.brightPurple.main,
|
||||
textDecorationColor: theme.palette.brightPurple.main,
|
||||
}}
|
||||
onClick={collapseAllQuestions}
|
||||
>
|
||||
Свернуть всё
|
||||
</Button>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
maxWidth: "796px",
|
||||
boxShadow: "0px 10px 30px #e7e7e7",
|
||||
borderRadius: "12px",
|
||||
marginBottom: "30px",
|
||||
borderTop: "1px solid transparent",
|
||||
borderBottom: "1px solid transparent",
|
||||
background: "#FFFFFF",
|
||||
}}
|
||||
>
|
||||
<FormDraggableList />
|
||||
<Box
|
||||
sx={{
|
||||
cursor: "pointer",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "15px",
|
||||
padding: "4px",
|
||||
margin: "15px",
|
||||
border: "1px solid transparent",
|
||||
borderRadius: "8px",
|
||||
"&:hover": {
|
||||
border: "1px solid #9A9AAF",
|
||||
},
|
||||
}}
|
||||
onClick={() => {
|
||||
createUntypedQuestion(quiz.backendId);
|
||||
}}
|
||||
data-cy="create-question"
|
||||
>
|
||||
<AddAnswer color="#EEE4FC" />
|
||||
<Typography sx={{ color: "#9A9AAF" }}>
|
||||
Добавить еще один вопрос
|
||||
</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "flex-end",
|
||||
gap: "8px",
|
||||
maxWidth: "796px",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="outlined"
|
||||
sx={{ padding: "10px 20px", borderRadius: "8px", height: "44px" }}
|
||||
onClick={decrementCurrentStep}
|
||||
>
|
||||
<ArrowLeft />
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{
|
||||
height: "44px",
|
||||
padding: "10px 20px",
|
||||
borderRadius: "8px",
|
||||
background: theme.palette.brightPurple.main,
|
||||
fontSize: "18px",
|
||||
}}
|
||||
onClick={incrementCurrentStep}
|
||||
>
|
||||
Следующий шаг
|
||||
</Button>
|
||||
</Box>
|
||||
{createPortal(<QuizPreview />, document.body)}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
sx={{
|
||||
maxWidth: "796px",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
margin: "60px 0 40px 0",
|
||||
}}
|
||||
>
|
||||
<Typography variant={"h5"}>Заголовок анкеты</Typography>
|
||||
<Button
|
||||
sx={{
|
||||
fontSize: "16px",
|
||||
lineHeight: "19px",
|
||||
padding: 0,
|
||||
textDecoration: "underline",
|
||||
color: theme.palette.brightPurple.main,
|
||||
textDecorationColor: theme.palette.brightPurple.main,
|
||||
}}
|
||||
onClick={collapseAllQuestions}
|
||||
>
|
||||
Свернуть всё
|
||||
</Button>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
maxWidth: "796px",
|
||||
boxShadow: "0px 10px 30px #e7e7e7",
|
||||
borderRadius: "12px",
|
||||
marginBottom: "30px",
|
||||
borderTop: "1px solid transparent",
|
||||
borderBottom: "1px solid transparent",
|
||||
background: "#FFFFFF",
|
||||
}}
|
||||
>
|
||||
<FormDraggableList />
|
||||
<Box
|
||||
sx={{
|
||||
cursor: "pointer",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "15px",
|
||||
padding: "4px",
|
||||
margin: "15px",
|
||||
border: "1px solid transparent",
|
||||
borderRadius: "8px",
|
||||
"&:hover": {
|
||||
border: "1px solid #9A9AAF",
|
||||
},
|
||||
}}
|
||||
onClick={() => {
|
||||
createUntypedQuestion(quiz.backendId);
|
||||
}}
|
||||
data-cy="create-question"
|
||||
>
|
||||
<AddAnswer color="#EEE4FC" />
|
||||
<Typography sx={{ color: "#9A9AAF" }}>Добавить еще один вопрос</Typography>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "flex-end",
|
||||
gap: "8px",
|
||||
maxWidth: "796px",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="outlined"
|
||||
sx={{ padding: "10px 20px", borderRadius: "8px", height: "44px" }}
|
||||
onClick={decrementCurrentStep}
|
||||
>
|
||||
<ArrowLeft />
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{
|
||||
height: "44px",
|
||||
padding: "10px 20px",
|
||||
borderRadius: "8px",
|
||||
background: theme.palette.brightPurple.main,
|
||||
fontSize: "18px",
|
||||
}}
|
||||
onClick={incrementCurrentStep}
|
||||
>
|
||||
Следующий шаг
|
||||
</Button>
|
||||
</Box>
|
||||
{createPortal(<QuizPreview />, document.body)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -12,80 +12,75 @@ import Slider from "../../../assets/icons/questionsPage/slider";
|
||||
|
||||
import { QuestionType } from "@model/question/question";
|
||||
import { createTypedQuestion } from "@root/questions/actions";
|
||||
import type {
|
||||
UntypedQuizQuestion
|
||||
} from "../../../model/questionTypes/shared";
|
||||
|
||||
import type { UntypedQuizQuestion } from "../../../model/questionTypes/shared";
|
||||
|
||||
type ButtonTypeQuestion = {
|
||||
icon: JSX.Element;
|
||||
title: string;
|
||||
value: QuestionType;
|
||||
icon: JSX.Element;
|
||||
title: string;
|
||||
value: QuestionType;
|
||||
};
|
||||
|
||||
const BUTTON_TYPE_SHORT_QUESTIONS: ButtonTypeQuestion[] = [
|
||||
{
|
||||
icon: <Answer color="#9A9AAF" />,
|
||||
title: "Варианты ответов",
|
||||
value: "variant",
|
||||
},
|
||||
{
|
||||
icon: <Input color="#9A9AAF" />,
|
||||
title: "Своё поле для ввода",
|
||||
value: "text",
|
||||
},
|
||||
{
|
||||
icon: <DropDown color="#9A9AAF" />,
|
||||
title: "Выпадающий список",
|
||||
value: "select",
|
||||
},
|
||||
{
|
||||
icon: <Date color="#9A9AAF" />,
|
||||
title: "Дата",
|
||||
value: "date",
|
||||
},
|
||||
{
|
||||
icon: <Slider color="#9A9AAF" />,
|
||||
title: "Ползунок",
|
||||
value: "number",
|
||||
},
|
||||
{
|
||||
icon: <Download color="#9A9AAF" />,
|
||||
title: "Загрузка файла",
|
||||
value: "file",
|
||||
},
|
||||
{
|
||||
icon: <Answer color="#9A9AAF" />,
|
||||
title: "Варианты ответов",
|
||||
value: "variant",
|
||||
},
|
||||
{
|
||||
icon: <Input color="#9A9AAF" />,
|
||||
title: "Своё поле для ввода",
|
||||
value: "text",
|
||||
},
|
||||
{
|
||||
icon: <DropDown color="#9A9AAF" />,
|
||||
title: "Выпадающий список",
|
||||
value: "select",
|
||||
},
|
||||
{
|
||||
icon: <Date color="#9A9AAF" />,
|
||||
title: "Дата",
|
||||
value: "date",
|
||||
},
|
||||
{
|
||||
icon: <Slider color="#9A9AAF" />,
|
||||
title: "Ползунок",
|
||||
value: "number",
|
||||
},
|
||||
{
|
||||
icon: <Download color="#9A9AAF" />,
|
||||
title: "Загрузка файла",
|
||||
value: "file",
|
||||
},
|
||||
];
|
||||
|
||||
interface Props {
|
||||
question: UntypedQuizQuestion;
|
||||
question: UntypedQuizQuestion;
|
||||
}
|
||||
|
||||
export default function FormTypeQuestions({ question }: Props) {
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
gap: "20px",
|
||||
margin: "20px",
|
||||
}}
|
||||
>
|
||||
{(("page" in question) && question.page === 0
|
||||
? BUTTON_TYPE_QUESTIONS
|
||||
: BUTTON_TYPE_SHORT_QUESTIONS
|
||||
).map(({ icon, title, value: questionType }) => (
|
||||
<QuestionsMiniButton
|
||||
key={title}
|
||||
onClick={() => {
|
||||
createTypedQuestion(question.id, questionType);
|
||||
}}
|
||||
icon={icon}
|
||||
text={title}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
return (
|
||||
<Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
gap: "20px",
|
||||
margin: "20px",
|
||||
}}
|
||||
>
|
||||
{("page" in question && question.page === 0 ? BUTTON_TYPE_QUESTIONS : BUTTON_TYPE_SHORT_QUESTIONS).map(
|
||||
({ icon, title, value: questionType }) => (
|
||||
<QuestionsMiniButton
|
||||
key={title}
|
||||
onClick={() => {
|
||||
createTypedQuestion(question.id, questionType);
|
||||
}}
|
||||
icon={icon}
|
||||
text={title}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
@ -1,12 +1,5 @@
|
||||
import { useState, useEffect, useLayoutEffect, useRef } from "react"
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
IconButton,
|
||||
Typography,
|
||||
useMediaQuery,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import { useState, useEffect, useLayoutEffect, useRef } from "react";
|
||||
import { Box, Button, IconButton, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||||
import { collapseAllQuestions, createUntypedQuestion } from "@root/questions/actions";
|
||||
import { decrementCurrentStep, incrementCurrentStep } from "@root/quizes/actions";
|
||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
@ -14,105 +7,102 @@ import QuizPreview from "@ui_kit/QuizPreview/QuizPreview";
|
||||
import { createPortal } from "react-dom";
|
||||
import AddPlus from "../../assets/icons/questionsPage/addPlus";
|
||||
import ArrowLeft from "../../assets/icons/questionsPage/arrowLeft";
|
||||
import BranchingQuestions from "./BranchingModal/BranchingQuestionsModal"
|
||||
import BranchingQuestions from "./BranchingModal/BranchingQuestionsModal";
|
||||
import { QuestionSwitchWindowTool } from "./QuestionSwitchWindowTool";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
import { updateOpenBranchingPanel, updateEditSomeQuestion } from "@root/uiTools/actions";
|
||||
import { useUiTools } from "@root/uiTools/store";
|
||||
|
||||
export default function QuestionsPage() {
|
||||
const theme = useTheme();
|
||||
const { openedModalSettingsId, openBranchingPanel } = useUiTools();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
||||
const quiz = useCurrentQuiz();
|
||||
useLayoutEffect(() => {
|
||||
updateOpenBranchingPanel(false)
|
||||
updateEditSomeQuestion()
|
||||
},[])
|
||||
const theme = useTheme();
|
||||
const { openedModalSettingsId, openBranchingPanel } = useUiTools();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down(660));
|
||||
const quiz = useCurrentQuiz();
|
||||
useLayoutEffect(() => {
|
||||
updateOpenBranchingPanel(false);
|
||||
updateEditSomeQuestion();
|
||||
}, []);
|
||||
|
||||
const ref = useRef()
|
||||
if (!quiz) return null;
|
||||
const ref = useRef();
|
||||
if (!quiz) return null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
ref={ref}
|
||||
id="QuestionsPage"
|
||||
sx={{
|
||||
maxWidth: "796px",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
margin: "60px 0 40px 0",
|
||||
}}
|
||||
>
|
||||
<Typography variant={"h5"}>{quiz.name ? quiz.name : "Заголовок квиза"}</Typography>
|
||||
<Button
|
||||
sx={{
|
||||
display: openBranchingPanel ? "none" : "flex",
|
||||
fontSize: "16px",
|
||||
lineHeight: "19px",
|
||||
padding: 0,
|
||||
textDecoration: "underline",
|
||||
color: theme.palette.brightPurple.main,
|
||||
textDecorationColor: theme.palette.brightPurple.main,
|
||||
}}
|
||||
onClick={collapseAllQuestions}
|
||||
>
|
||||
Свернуть всё
|
||||
</Button>
|
||||
</Box>
|
||||
<QuestionSwitchWindowTool />
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
maxWidth: "796px",
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
createUntypedQuestion(quiz.backendId);
|
||||
}}
|
||||
sx={{
|
||||
position: "fixed",
|
||||
left: isMobile ? "20px" : "250px",
|
||||
bottom: isMobile ? "140px" : "20px",
|
||||
}}
|
||||
data-cy="create-question"
|
||||
>
|
||||
<AddPlus />
|
||||
</IconButton>
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box
|
||||
ref={ref}
|
||||
id="QuestionsPage"
|
||||
sx={{
|
||||
maxWidth: "796px",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
margin: "60px 0 40px 0",
|
||||
}}
|
||||
>
|
||||
<Typography variant={"h5"}>{
|
||||
quiz.name ? quiz.name : "Заголовок квиза" }</Typography>
|
||||
<Button
|
||||
sx={{
|
||||
display: openBranchingPanel ? "none" : "flex",
|
||||
fontSize: "16px",
|
||||
lineHeight: "19px",
|
||||
padding: 0,
|
||||
textDecoration: "underline",
|
||||
color: theme.palette.brightPurple.main,
|
||||
textDecorationColor: theme.palette.brightPurple.main,
|
||||
}}
|
||||
onClick={collapseAllQuestions}
|
||||
>
|
||||
Свернуть всё
|
||||
</Button>
|
||||
</Box>
|
||||
<QuestionSwitchWindowTool/>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
justifyContent: "space-between",
|
||||
maxWidth: "796px",
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
createUntypedQuestion(quiz.backendId);
|
||||
}}
|
||||
sx={{
|
||||
position: "fixed",
|
||||
left: isMobile ? "20px" : "250px",
|
||||
bottom: isMobile ? "140px" : "20px",
|
||||
}}
|
||||
data-cy="create-question"
|
||||
>
|
||||
<AddPlus />
|
||||
</IconButton>
|
||||
|
||||
|
||||
<Box sx={{ display: "flex", gap: "8px", marginLeft: "auto" }}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
sx={{ padding: "10px 20px", borderRadius: "8px", height: "44px" }}
|
||||
data-cy="back-button"
|
||||
onClick={decrementCurrentStep}
|
||||
>
|
||||
<ArrowLeft />
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{
|
||||
height: "44px",
|
||||
padding: "10px 20px",
|
||||
borderRadius: "8px",
|
||||
background: theme.palette.brightPurple.main,
|
||||
fontSize: "18px",
|
||||
}}
|
||||
onClick={incrementCurrentStep}
|
||||
>
|
||||
Следующий шаг
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
{createPortal(<QuizPreview />, document.body)}
|
||||
{openedModalSettingsId !== null && <BranchingQuestions/>}
|
||||
</>
|
||||
);
|
||||
<Box sx={{ display: "flex", gap: "8px", marginLeft: "auto" }}>
|
||||
<Button
|
||||
variant="outlined"
|
||||
sx={{ padding: "10px 20px", borderRadius: "8px", height: "44px" }}
|
||||
data-cy="back-button"
|
||||
onClick={decrementCurrentStep}
|
||||
>
|
||||
<ArrowLeft />
|
||||
</Button>
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{
|
||||
height: "44px",
|
||||
padding: "10px 20px",
|
||||
borderRadius: "8px",
|
||||
background: theme.palette.brightPurple.main,
|
||||
fontSize: "18px",
|
||||
}}
|
||||
onClick={incrementCurrentStep}
|
||||
>
|
||||
Следующий шаг
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
{createPortal(<QuizPreview />, document.body)}
|
||||
{openedModalSettingsId !== null && <BranchingQuestions />}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -12,48 +12,46 @@ import UploadFile from "./UploadFile/UploadFile";
|
||||
import AnswerOptions from "./answerOptions/AnswerOptions";
|
||||
import { notReachable } from "../../utils/notReachable";
|
||||
|
||||
|
||||
interface Props {
|
||||
question: AnyTypedQuizQuestion;
|
||||
question: AnyTypedQuizQuestion;
|
||||
}
|
||||
|
||||
export default function SwitchQuestionsPage({ question }: Props) {
|
||||
switch (question.type) {
|
||||
case "variant":
|
||||
return <AnswerOptions question={question} />;
|
||||
|
||||
switch (question.type) {
|
||||
case "variant":
|
||||
return <AnswerOptions question={question} />;
|
||||
case "images":
|
||||
return <OptionsPicture question={question} />;
|
||||
|
||||
case "images":
|
||||
return <OptionsPicture question={question} />;
|
||||
case "varimg":
|
||||
return <OptionsAndPicture question={question} />;
|
||||
|
||||
case "varimg":
|
||||
return <OptionsAndPicture question={question} />;
|
||||
case "emoji":
|
||||
return <Emoji question={question} />;
|
||||
|
||||
case "emoji":
|
||||
return <Emoji question={question} />;
|
||||
case "text":
|
||||
return <OwnTextField question={question} />;
|
||||
|
||||
case "text":
|
||||
return <OwnTextField question={question} />;
|
||||
case "select":
|
||||
return <DropDown question={question} />;
|
||||
|
||||
case "select":
|
||||
return <DropDown question={question} />;
|
||||
case "date":
|
||||
return <DataOptions question={question} />;
|
||||
|
||||
case "date":
|
||||
return <DataOptions question={question} />;
|
||||
case "number":
|
||||
return <SliderOptions question={question} />;
|
||||
|
||||
case "number":
|
||||
return <SliderOptions question={question} />;
|
||||
case "file":
|
||||
return <UploadFile question={question} />;
|
||||
|
||||
case "file":
|
||||
return <UploadFile question={question} />;
|
||||
case "page":
|
||||
return <PageOptions question={question} />;
|
||||
|
||||
case "page":
|
||||
return <PageOptions question={question} />;
|
||||
case "rating":
|
||||
return <RatingOptions question={question} />;
|
||||
|
||||
case "rating":
|
||||
return <RatingOptions question={question} />;
|
||||
|
||||
default:
|
||||
notReachable(question)
|
||||
}
|
||||
default:
|
||||
notReachable(question);
|
||||
}
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ export const ResultCard = ({ resultContract, resultData }: Props) => {
|
||||
placeholder="URL видео"
|
||||
text={resultData.content.video ?? ""}
|
||||
onChange={e => updateQuestion(resultData.id, q => {
|
||||
resultData.content.video = e.target.value;
|
||||
q.content.video = e.target.value;
|
||||
})}
|
||||
/>
|
||||
</Box>
|
||||
|
@ -1,33 +1,152 @@
|
||||
import { Box, Typography, Button } from "@mui/material";
|
||||
import { Box, Typography, Button, Paper, TextField, Link, FormControl } from "@mui/material";
|
||||
import NameIcon from "@icons/ContactFormIcon/NameIcon";
|
||||
import EmailIcon from "@icons/ContactFormIcon/EmailIcon";
|
||||
import PhoneIcon from "@icons/ContactFormIcon/PhoneIcon";
|
||||
import TextIcon from "@icons/ContactFormIcon/TextIcon";
|
||||
import AddressIcon from "@icons/ContactFormIcon/AddressIcon";
|
||||
|
||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
||||
import { useState } from "react";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
|
||||
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
||||
|
||||
type ContactFormProps = {
|
||||
currentQuestion: AnyTypedQuizQuestion;
|
||||
showResultForm: boolean;
|
||||
setShowContactForm: (show: boolean) => void;
|
||||
setShowResultForm: (show: boolean) => void;
|
||||
};
|
||||
|
||||
const icons = [
|
||||
{ type: "name", icon: NameIcon, defaultText: "Введите имя", defaultTitle: "имя" },
|
||||
{ type: "email", icon: EmailIcon, defaultText: "Введите Email", defaultTitle: "Email" },
|
||||
{ type: "phone", icon: PhoneIcon, defaultText: "Введите номер телефона", defaultTitle: "номер телефона" },
|
||||
{ type: "text", icon: TextIcon, defaultText: "Введите фамилию", defaultTitle: "фамилию" },
|
||||
{ type: "address", icon: AddressIcon, defaultText: "Введите адрес", defaultTitle: "адрес" },
|
||||
]
|
||||
|
||||
export const ContactForm = ({
|
||||
currentQuestion,
|
||||
showResultForm,
|
||||
setShowContactForm,
|
||||
setShowResultForm,
|
||||
}: ContactFormProps) => {
|
||||
const quiz = useCurrentQuiz();
|
||||
const { questions } = useQuestionsStore();
|
||||
|
||||
const [ready, setReady] = useState(false)
|
||||
const followNextForm = () => {
|
||||
setShowContactForm(false);
|
||||
setShowResultForm(true);
|
||||
};
|
||||
|
||||
const resultQuestion = questions.find(
|
||||
(question) =>
|
||||
question.type === "result" &&
|
||||
question.content.rule.parentId === currentQuestion.content.id
|
||||
);
|
||||
return (
|
||||
<Box>
|
||||
<Typography>Форма контактов</Typography>
|
||||
{!showResultForm && quiz?.config.resultInfo.when === "after" && (
|
||||
<Button variant="contained" onClick={followNextForm}>
|
||||
Показать результат
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
height: "100vh"
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
sx={{
|
||||
width: "800px"
|
||||
}}
|
||||
>
|
||||
|
||||
<Box>
|
||||
<Typography
|
||||
sx={{
|
||||
textAlign: "center",
|
||||
m: "20px 0",
|
||||
fontSize: "28px"
|
||||
}}
|
||||
>
|
||||
Заполните форму, чтобы получить результаты теста
|
||||
</Typography>
|
||||
</Box>
|
||||
|
||||
|
||||
<Paper
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
flexDirection: "column",
|
||||
p: "30px"
|
||||
}}>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
my: "20px"
|
||||
}}
|
||||
>
|
||||
{
|
||||
icons.map((data) => {
|
||||
const FC = quiz?.config.formContact[data.type]
|
||||
return FC.used ? <CustomInput title={FC.innerText || data.defaultText} desc={FC.text || data.defaultTitle} Icon={data.icon} />
|
||||
:
|
||||
<></>
|
||||
})
|
||||
}
|
||||
|
||||
</Box>
|
||||
|
||||
{
|
||||
// resultQuestion &&
|
||||
// quiz?.config.resultInfo.when === "after" &&
|
||||
(
|
||||
<Button
|
||||
disabled={!ready}
|
||||
variant="contained" onClick={followNextForm}>
|
||||
Получить результаты
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
mt: "20px",
|
||||
width: "450px",
|
||||
}}
|
||||
>
|
||||
<CustomCheckbox label="" handleChange={({ target }) => { setReady(target.checked) }} checked={ready} />
|
||||
<Typography>
|
||||
С
|
||||
<Link> Положением об обработке персональных данных </Link>
|
||||
и
|
||||
<Link> Политикой конфиденциальности </Link>
|
||||
ознакомлен
|
||||
</Typography>
|
||||
|
||||
</Box>
|
||||
</Paper>
|
||||
</Box >
|
||||
</Box >
|
||||
);
|
||||
};
|
||||
|
||||
const CustomInput = ({ title, desc, Icon }: any) => {
|
||||
return <Box m="15px 0">
|
||||
<Typography mb="7px">{title}</Typography>
|
||||
<TextField
|
||||
sx={{
|
||||
width: "350px",
|
||||
}}
|
||||
placeholder={desc}
|
||||
InputProps={{
|
||||
startAdornment: <Icon color="gray" />,
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ type FooterProps = {
|
||||
question: AnyTypedQuizQuestion;
|
||||
setShowContactForm: (show: boolean) => void;
|
||||
setShowResultForm: (show: boolean) => void;
|
||||
setResultQuestion: (id: string) => void;
|
||||
};
|
||||
|
||||
export const Footer = ({
|
||||
@ -25,7 +24,6 @@ export const Footer = ({
|
||||
question,
|
||||
setShowContactForm,
|
||||
setShowResultForm,
|
||||
setResultQuestion,
|
||||
}: FooterProps) => {
|
||||
const [disablePreviousButton, setDisablePreviousButton] =
|
||||
useState<boolean>(false);
|
||||
@ -103,16 +101,10 @@ export const Footer = ({
|
||||
type === "result" && content.rule.parentId === question.content.id
|
||||
);
|
||||
|
||||
if (resultQuestion) {
|
||||
setResultQuestion(resultQuestion.id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (quiz?.config.resultInfo.when === "after") {
|
||||
setShowContactForm(true);
|
||||
} else {
|
||||
if (quiz?.config.resultInfo.when !== "after" && resultQuestion) {
|
||||
setShowResultForm(true);
|
||||
} else {
|
||||
setShowContactForm(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -47,7 +47,6 @@ export const Question = ({ questions }: QuestionProps) => {
|
||||
useState<AnyTypedQuizQuestion>();
|
||||
const [showContactForm, setShowContactForm] = useState<boolean>(false);
|
||||
const [showResultForm, setShowResultForm] = useState<boolean>(false);
|
||||
const [resultQuestion, setResultQuestion] = useState<string>("");
|
||||
|
||||
useEffect(() => {
|
||||
const nextQuestion = getQuestionByContentId(quiz?.config.haveRoot || "");
|
||||
@ -77,19 +76,12 @@ export const Question = ({ questions }: QuestionProps) => {
|
||||
margin: "0 auto",
|
||||
}}
|
||||
>
|
||||
{!showContactForm && !showResultForm && !resultQuestion && (
|
||||
{!showContactForm && !showResultForm && (
|
||||
<QuestionComponent currentQuestion={currentQuestion} />
|
||||
)}
|
||||
{resultQuestion && (
|
||||
<ResultQuestion
|
||||
resultQuestion={resultQuestion}
|
||||
setResultQuestion={setResultQuestion}
|
||||
setShowContactForm={setShowContactForm}
|
||||
setShowResultForm={setShowResultForm}
|
||||
/>
|
||||
)}
|
||||
{showContactForm && (
|
||||
<ContactForm
|
||||
currentQuestion={currentQuestion}
|
||||
showResultForm={showResultForm}
|
||||
setShowContactForm={setShowContactForm}
|
||||
setShowResultForm={setShowResultForm}
|
||||
@ -97,19 +89,19 @@ export const Question = ({ questions }: QuestionProps) => {
|
||||
)}
|
||||
{showResultForm && (
|
||||
<ResultForm
|
||||
currentQuestion={currentQuestion}
|
||||
showContactForm={showContactForm}
|
||||
setShowContactForm={setShowContactForm}
|
||||
setShowResultForm={setShowResultForm}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
{!showContactForm && !showResultForm && !resultQuestion && (
|
||||
{!showContactForm && !showResultForm && (
|
||||
<Footer
|
||||
question={currentQuestion}
|
||||
setCurrentQuestion={setCurrentQuestion}
|
||||
setShowContactForm={setShowContactForm}
|
||||
setShowResultForm={setShowResultForm}
|
||||
setResultQuestion={setResultQuestion}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
|
@ -1,19 +1,33 @@
|
||||
import { Box, Typography, Button } from "@mui/material";
|
||||
import { getQuestionByContentId } from "@root/questions/actions";
|
||||
|
||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
|
||||
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
||||
import YoutubeEmbedIframe from "../../ui_kit/StartPagePreview/YoutubeEmbedIframe.tsx"
|
||||
|
||||
type ResultFormProps = {
|
||||
currentQuestion: AnyTypedQuizQuestion;
|
||||
showContactForm: boolean;
|
||||
setShowContactForm: (show: boolean) => void;
|
||||
setShowResultForm: (show: boolean) => void;
|
||||
};
|
||||
|
||||
export const ResultForm = ({
|
||||
currentQuestion,
|
||||
showContactForm,
|
||||
setShowContactForm,
|
||||
setShowResultForm,
|
||||
|
||||
}: ResultFormProps) => {
|
||||
const quiz = useCurrentQuiz();
|
||||
const { questions } = useQuestionsStore();
|
||||
const resultQuestion = questions.find(
|
||||
(question) =>
|
||||
question.type === "result" &&
|
||||
question.content.rule.parentId === currentQuestion.content.id
|
||||
);
|
||||
|
||||
const followNextForm = () => {
|
||||
setShowResultForm(false);
|
||||
@ -21,8 +35,90 @@ export const ResultForm = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Typography>Форма результатов</Typography>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "space-between",
|
||||
height: "100vh",
|
||||
width: "100vw",
|
||||
pt: "28px"
|
||||
}}
|
||||
>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "start",
|
||||
width: "490px",
|
||||
}}
|
||||
>
|
||||
{
|
||||
!resultQuestion?.content.useImage &&
|
||||
resultQuestion.content.video &&
|
||||
<YoutubeEmbedIframe
|
||||
videoUrl={resultQuestion.content.video}
|
||||
containerSX={{
|
||||
width: "490px",
|
||||
height: "280px"
|
||||
}}
|
||||
/>
|
||||
}
|
||||
{
|
||||
resultQuestion?.content.useImage &&
|
||||
resultQuestion.content.back &&
|
||||
<Box
|
||||
component='img'
|
||||
src={resultQuestion.content.back}
|
||||
sx={{
|
||||
width: "490px",
|
||||
height: "280px"
|
||||
}}
|
||||
>
|
||||
</Box>
|
||||
}
|
||||
|
||||
{resultQuestion.description !== "" && resultQuestion.description !== " " && <Typography
|
||||
sx={{
|
||||
fontSize: "23px",
|
||||
fontWeight: 700,
|
||||
m: "20px 0"
|
||||
}}
|
||||
>{resultQuestion.description}</Typography>}
|
||||
|
||||
<Typography
|
||||
sx={{
|
||||
m: "20px 0"
|
||||
}}
|
||||
>{resultQuestion.title || "Форма результатов"}
|
||||
</Typography>
|
||||
|
||||
</Box>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
height: "100px",
|
||||
boxShadow: "0 0 15px 0 rgba(0,0,0,.08)",
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
sx={{
|
||||
p:"10px 20px",
|
||||
width: "210px",
|
||||
height: "50px"
|
||||
}}
|
||||
>
|
||||
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
||||
</Button>
|
||||
</Box>
|
||||
|
||||
{!showContactForm && quiz?.config.resultInfo.when !== "after" && (
|
||||
<Button variant="contained" onClick={followNextForm}>
|
||||
Показать форму контактов
|
||||
|
@ -1,43 +0,0 @@
|
||||
import { Box, Typography, Button } from "@mui/material";
|
||||
|
||||
import { useCurrentQuiz } from "@root/quizes/hooks";
|
||||
import { useQuestionsStore } from "@root/questions/store";
|
||||
|
||||
type ResultQuestionProps = {
|
||||
resultQuestion: string;
|
||||
setResultQuestion: (id: string) => void;
|
||||
setShowContactForm: (show: boolean) => void;
|
||||
setShowResultForm: (show: boolean) => void;
|
||||
};
|
||||
|
||||
export const ResultQuestion = ({
|
||||
resultQuestion,
|
||||
setResultQuestion,
|
||||
setShowContactForm,
|
||||
setShowResultForm,
|
||||
}: ResultQuestionProps) => {
|
||||
const quiz = useCurrentQuiz();
|
||||
const { questions } = useQuestionsStore();
|
||||
|
||||
const followNextForm = () => {
|
||||
setResultQuestion("");
|
||||
|
||||
if (quiz?.config.resultInfo.when === "after") {
|
||||
setShowContactForm(true);
|
||||
} else {
|
||||
setShowResultForm(true);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Typography>Вопрос результат</Typography>
|
||||
<Typography>
|
||||
{JSON.stringify(questions.find(({ id }) => id === resultQuestion))}
|
||||
</Typography>
|
||||
<Button variant="contained" onClick={followNextForm}>
|
||||
Далее
|
||||
</Button>
|
||||
</Box>
|
||||
);
|
||||
};
|
@ -1,18 +1,9 @@
|
||||
import { login } from "@api/auth";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
IconButton,
|
||||
Link,
|
||||
Typography,
|
||||
useMediaQuery,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import { Box, Button, Dialog, IconButton, Link, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||||
import { setUserId, useUserStore } from "@root/user";
|
||||
import InputTextfield from "@ui_kit/InputTextfield";
|
||||
import PenaLogo2 from "@ui_kit/PenaLogo2";
|
||||
import Logotip from "../../pages/Landing/images/icons/QuizLogo";
|
||||
import PasswordInput from "@ui_kit/passwordInput";
|
||||
import { useFormik } from "formik";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
@ -31,9 +22,7 @@ const initialValues: Values = {
|
||||
};
|
||||
|
||||
const validationSchema = object({
|
||||
email: string()
|
||||
.required("Поле обязательно")
|
||||
.email("Введите корректный email"),
|
||||
email: string().required("Поле обязательно").email("Введите корректный email"),
|
||||
password: string().required("Поле обязательно").min(8, "Минимум 8 символов"),
|
||||
});
|
||||
|
||||
@ -49,10 +38,7 @@ export default function SigninDialog() {
|
||||
initialValues,
|
||||
validationSchema,
|
||||
onSubmit: async (values, formikHelpers) => {
|
||||
const [loginResponse, loginError] = await login(
|
||||
values.email.trim(),
|
||||
values.password.trim()
|
||||
);
|
||||
const [loginResponse, loginError] = await login(values.email.trim(), values.password.trim());
|
||||
|
||||
formikHelpers.setSubmitting(false);
|
||||
|
||||
@ -111,8 +97,7 @@ export default function SigninDialog() {
|
||||
gap: "15px",
|
||||
borderRadius: "12px",
|
||||
boxShadow: "0px 15px 80px rgb(210 208 225 / 70%)",
|
||||
"& .MuiFormHelperText-root.Mui-error, & .MuiFormHelperText-root.Mui-error.MuiFormHelperText-filled":
|
||||
{
|
||||
"& .MuiFormHelperText-root.Mui-error, & .MuiFormHelperText-root.Mui-error.MuiFormHelperText-filled": {
|
||||
position: "absolute",
|
||||
top: "46px",
|
||||
margin: "0",
|
||||
@ -130,7 +115,7 @@ export default function SigninDialog() {
|
||||
<CloseIcon sx={{ transform: "scale(1.5)" }} />
|
||||
</IconButton>
|
||||
<Box>
|
||||
<PenaLogo2 width={upMd ? 233 : 196} color="black" />
|
||||
<Logotip width={upMd ? 233 : 196} />
|
||||
</Box>
|
||||
<Typography
|
||||
sx={{
|
||||
@ -212,16 +197,8 @@ export default function SigninDialog() {
|
||||
mt: "auto",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
sx={{ color: "#7E2AEA", textAlign: "center" }}
|
||||
>
|
||||
Вы еще не присоединились?
|
||||
</Typography>
|
||||
<Link
|
||||
component={RouterLink}
|
||||
to="/signup"
|
||||
sx={{ color: "#7E2AEA" }}
|
||||
>
|
||||
<Typography sx={{ color: "#7E2AEA", textAlign: "center" }}>Вы еще не присоединились?</Typography>
|
||||
<Link component={RouterLink} to="/signup" sx={{ color: "#7E2AEA" }}>
|
||||
Регистрация
|
||||
</Link>
|
||||
</Box>
|
||||
|
@ -1,23 +1,14 @@
|
||||
import { register } from "@api/auth";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
IconButton,
|
||||
Link,
|
||||
Typography,
|
||||
useMediaQuery,
|
||||
useTheme,
|
||||
} from "@mui/material";
|
||||
import { Box, Button, Dialog, IconButton, Link, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||||
import { setUserId, useUserStore } from "@root/user";
|
||||
import InputTextfield from "@ui_kit/InputTextfield";
|
||||
import PenaLogo2 from "@ui_kit/PenaLogo2";
|
||||
import Logotip from "../../pages/Landing/images/icons/QuizLogo";
|
||||
import PasswordInput from "@ui_kit/passwordInput";
|
||||
import { useFormik } from "formik";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { useEffect, useState } from "react";
|
||||
import {Link as RouterLink, useLocation, useNavigate} from "react-router-dom";
|
||||
import { Link as RouterLink, useLocation, useNavigate } from "react-router-dom";
|
||||
import { object, ref, string } from "yup";
|
||||
|
||||
interface Values {
|
||||
@ -33,9 +24,7 @@ const initialValues: Values = {
|
||||
};
|
||||
|
||||
const validationSchema = object({
|
||||
email: string()
|
||||
.required("Поле обязательно")
|
||||
.email("Введите корректный email"),
|
||||
email: string().required("Поле обязательно").email("Введите корректный email"),
|
||||
password: string()
|
||||
.min(8, "Минимум 8 символов")
|
||||
.matches(/^[.,:;-_+\d\w]+$/, "Некорректные символы")
|
||||
@ -50,18 +39,14 @@ export default function SignupDialog() {
|
||||
const user = useUserStore((state) => state.user);
|
||||
const theme = useTheme();
|
||||
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
||||
const location = useLocation()
|
||||
const location = useLocation();
|
||||
|
||||
const navigate = useNavigate();
|
||||
const formik = useFormik<Values>({
|
||||
initialValues,
|
||||
validationSchema,
|
||||
onSubmit: async (values, formikHelpers) => {
|
||||
const [registerResponse, registerError] = await register(
|
||||
values.email.trim(),
|
||||
values.password.trim(),
|
||||
"+7"
|
||||
);
|
||||
const [registerResponse, registerError] = await register(values.email.trim(), values.password.trim(), "+7");
|
||||
|
||||
formikHelpers.setSubmitting(false);
|
||||
|
||||
@ -120,12 +105,11 @@ export default function SignupDialog() {
|
||||
gap: "15px",
|
||||
borderRadius: "12px",
|
||||
boxShadow: "0px 15px 80px rgb(210 208 225 / 70%)",
|
||||
"& .MuiFormHelperText-root.Mui-error, & .MuiFormHelperText-root.Mui-error.MuiFormHelperText-filled":
|
||||
{
|
||||
position: "absolute",
|
||||
top: "46px",
|
||||
margin: "0",
|
||||
},
|
||||
"& .MuiFormHelperText-root.Mui-error, & .MuiFormHelperText-root.Mui-error.MuiFormHelperText-filled": {
|
||||
position: "absolute",
|
||||
top: "46px",
|
||||
margin: "0",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
@ -139,7 +123,7 @@ export default function SignupDialog() {
|
||||
<CloseIcon sx={{ transform: "scale(1.5)" }} />
|
||||
</IconButton>
|
||||
<Box sx={{ mt: upMd ? undefined : "62px" }}>
|
||||
<PenaLogo2 width={upMd ? 233 : 196} color="black" />
|
||||
<Logotip width={upMd ? 233 : 196} />
|
||||
</Box>
|
||||
<Typography
|
||||
sx={{
|
||||
@ -186,11 +170,8 @@ export default function SignupDialog() {
|
||||
value: formik.values.repeatPassword,
|
||||
placeholder: "Не менее 8 символов",
|
||||
onBlur: formik.handleBlur,
|
||||
error:
|
||||
formik.touched.repeatPassword &&
|
||||
Boolean(formik.errors.repeatPassword),
|
||||
helperText:
|
||||
formik.touched.repeatPassword && formik.errors.repeatPassword,
|
||||
error: formik.touched.repeatPassword && Boolean(formik.errors.repeatPassword),
|
||||
helperText: formik.touched.repeatPassword && formik.errors.repeatPassword,
|
||||
autoComplete: "new-password",
|
||||
"data-cy": "repeat-password",
|
||||
}}
|
||||
|
189
src/pages/startPage/Restore.tsx
Normal file
189
src/pages/startPage/Restore.tsx
Normal file
@ -0,0 +1,189 @@
|
||||
import { FC, useState } from "react";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { Box, Button, Dialog, IconButton, Typography, useMediaQuery, useTheme } from "@mui/material";
|
||||
import InputTextfield from "@ui_kit/InputTextfield";
|
||||
import PasswordInput from "@ui_kit/passwordInput";
|
||||
import { useFormik } from "formik";
|
||||
import { object, ref, string } from "yup";
|
||||
import Logotip from "../Landing/images/icons/QuizLogo";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
interface Values {
|
||||
email: string;
|
||||
password: string;
|
||||
repeatPassword: string;
|
||||
}
|
||||
|
||||
const initialValues: Values = {
|
||||
email: "",
|
||||
password: "",
|
||||
repeatPassword: "",
|
||||
};
|
||||
|
||||
const validationSchema = object({
|
||||
email: string().required("Поле обязательно").email("Введите корректный email"),
|
||||
password: string()
|
||||
.min(8, "Минимум 8 символов")
|
||||
.matches(/^[.,:;-_+\d\w]+$/, "Некорректные символы")
|
||||
.required("Поле обязательно"),
|
||||
repeatPassword: string()
|
||||
.oneOf([ref("password"), undefined], "Пароли не совпадают")
|
||||
.required("Повторите пароль"),
|
||||
});
|
||||
|
||||
export const Restore: FC = () => {
|
||||
const [isDialogOpen, setIsDialogOpen] = useState<boolean>(true);
|
||||
const navigate = useNavigate();
|
||||
const theme = useTheme();
|
||||
const upMd = useMediaQuery(theme.breakpoints.up("md"));
|
||||
|
||||
const formik = useFormik<Values>({
|
||||
initialValues,
|
||||
validationSchema,
|
||||
onSubmit: (values) => {
|
||||
console.log(values);
|
||||
},
|
||||
});
|
||||
|
||||
function handleClose() {
|
||||
setIsDialogOpen(false);
|
||||
setTimeout(() => navigate("/"), theme.transitions.duration.leavingScreen);
|
||||
}
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Button sx={{ width: "200px", height: "200px", background: "red" }} onClick={() => setIsDialogOpen(true)}>
|
||||
open
|
||||
</Button>
|
||||
<Dialog
|
||||
open={isDialogOpen}
|
||||
onClose={handleClose}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
width: "600px",
|
||||
maxWidth: "600px",
|
||||
},
|
||||
}}
|
||||
slotProps={{
|
||||
backdrop: {
|
||||
style: {
|
||||
backgroundColor: "rgb(0 0 0 / 0.7)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
<Box
|
||||
component="form"
|
||||
onSubmit={formik.handleSubmit}
|
||||
noValidate
|
||||
sx={{
|
||||
position: "relative",
|
||||
backgroundColor: "white",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
flexDirection: "column",
|
||||
p: upMd ? "50px" : "18px",
|
||||
pb: upMd ? "40px" : "30px",
|
||||
gap: "15px",
|
||||
borderRadius: "12px",
|
||||
boxShadow: "0px 15px 80px rgb(210 208 225 / 70%)",
|
||||
"& .MuiFormHelperText-root.Mui-error, & .MuiFormHelperText-root.Mui-error.MuiFormHelperText-filled": {
|
||||
position: "absolute",
|
||||
top: "46px",
|
||||
margin: "0",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<IconButton
|
||||
onClick={handleClose}
|
||||
sx={{
|
||||
position: "absolute",
|
||||
right: "7px",
|
||||
top: "7px",
|
||||
}}
|
||||
>
|
||||
<CloseIcon sx={{ transform: "scale(1.5)" }} />
|
||||
</IconButton>
|
||||
<Box sx={{ mt: upMd ? undefined : "62px" }}>
|
||||
<Logotip width={upMd ? 233 : 196} />
|
||||
</Box>
|
||||
<Typography
|
||||
sx={{
|
||||
color: "#4D4D4D",
|
||||
mt: "5px",
|
||||
mb: upMd ? "30px" : "33px",
|
||||
}}
|
||||
>
|
||||
Восстановление пароля
|
||||
</Typography>
|
||||
<InputTextfield
|
||||
TextfieldProps={{
|
||||
value: formik.values.email,
|
||||
placeholder: "username",
|
||||
onBlur: formik.handleBlur,
|
||||
error: formik.touched.email && Boolean(formik.errors.email),
|
||||
helperText: formik.touched.email && formik.errors.email,
|
||||
"data-cy": "username",
|
||||
}}
|
||||
onChange={formik.handleChange}
|
||||
color="#F2F3F7"
|
||||
id="email"
|
||||
label="Email"
|
||||
gap={upMd ? "10px" : "10px"}
|
||||
/>
|
||||
<PasswordInput
|
||||
TextfieldProps={{
|
||||
value: formik.values.password,
|
||||
placeholder: "Не менее 8 символов",
|
||||
onBlur: formik.handleBlur,
|
||||
error: formik.touched.password && Boolean(formik.errors.password),
|
||||
helperText: formik.touched.password && formik.errors.password,
|
||||
autoComplete: "new-password",
|
||||
"data-cy": "password",
|
||||
}}
|
||||
onChange={formik.handleChange}
|
||||
color="#F2F3F7"
|
||||
id="password"
|
||||
label="Пароль"
|
||||
gap={upMd ? "10px" : "10px"}
|
||||
/>
|
||||
<PasswordInput
|
||||
TextfieldProps={{
|
||||
value: formik.values.repeatPassword,
|
||||
placeholder: "Не менее 8 символов",
|
||||
onBlur: formik.handleBlur,
|
||||
error: formik.touched.repeatPassword && Boolean(formik.errors.repeatPassword),
|
||||
helperText: formik.touched.repeatPassword && formik.errors.repeatPassword,
|
||||
autoComplete: "new-password",
|
||||
"data-cy": "repeat-password",
|
||||
}}
|
||||
onChange={formik.handleChange}
|
||||
color="#F2F3F7"
|
||||
id="repeatPassword"
|
||||
label="Повторить пароль"
|
||||
gap={upMd ? "10px" : "10px"}
|
||||
/>
|
||||
<Button
|
||||
variant="contained"
|
||||
fullWidth
|
||||
type="submit"
|
||||
disabled={formik.isSubmitting}
|
||||
sx={{
|
||||
py: "12px",
|
||||
"&:hover": {
|
||||
backgroundColor: "#581CA7",
|
||||
},
|
||||
"&:active": {
|
||||
color: "white",
|
||||
backgroundColor: "black",
|
||||
},
|
||||
}}
|
||||
data-cy="signup"
|
||||
>
|
||||
Восстановить
|
||||
</Button>
|
||||
</Box>
|
||||
</Dialog>
|
||||
</Box>
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user