2023-06-30 17:59:50 +00:00
|
|
|
import {Box, Checkbox, FormControlLabel, IconButton, Paper, useTheme} from "@mui/material";
|
2023-06-28 23:32:43 +00:00
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
|
|
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
2023-06-30 14:39:07 +00:00
|
|
|
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
2023-06-28 23:32:43 +00:00
|
|
|
import OneIcon from "@icons/questionsPage/OneIcon";
|
|
|
|
import PointsIcon from "@icons/questionsPage/PointsIcon";
|
|
|
|
import TypeQuestions from "./TypeQuestions";
|
|
|
|
import SwitchQuestionsPage from "./SwitchQuestionsPage";
|
2023-06-30 14:39:07 +00:00
|
|
|
import React, {useState} from "react";
|
|
|
|
import DeleteIcon from "@icons/questionsPage/deleteIcon";
|
|
|
|
import {useParams} from "react-router-dom";
|
|
|
|
import {questionStore} from "@root/questions";
|
2023-06-30 17:59:50 +00:00
|
|
|
import CopyIcon from "@icons/questionsPage/CopyIcon";
|
|
|
|
import CrossedEyeIcon from "@icons/CrossedEyeIcon";
|
|
|
|
import HideIcon from "@icons/questionsPage/hideIcon";
|
2023-06-28 23:32:43 +00:00
|
|
|
|
|
|
|
interface Props {
|
2023-06-30 14:39:07 +00:00
|
|
|
DeleteClick: () => void;
|
|
|
|
totalIndex: number
|
2023-06-28 23:32:43 +00:00
|
|
|
}
|
|
|
|
|
2023-06-30 17:59:50 +00:00
|
|
|
export default function QuestionsPageCard({totalIndex, DeleteClick}: Props) {
|
2023-06-30 19:10:47 +00:00
|
|
|
|
|
|
|
function onDragStart(event: any) {
|
|
|
|
event
|
|
|
|
.dataTransfer
|
|
|
|
.setData('text', event.target.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-06-30 17:59:50 +00:00
|
|
|
const theme = useTheme();
|
2023-06-30 14:39:07 +00:00
|
|
|
const params = Number(useParams().quizId);
|
|
|
|
const {listQuestions, updateQuestionsList, createQuestion, removeQuestion} = questionStore()
|
|
|
|
const [isExpanded, setIsExpanded] = useState<boolean>(false);
|
2023-06-30 17:59:50 +00:00
|
|
|
const switchState = listQuestions[params][totalIndex].type
|
2023-06-28 23:32:43 +00:00
|
|
|
return (
|
2023-06-30 19:10:47 +00:00
|
|
|
<Paper
|
|
|
|
draggable="true"
|
|
|
|
id={String(totalIndex)}
|
|
|
|
sx={{
|
|
|
|
maxWidth: "796px",
|
|
|
|
width: "100%",
|
|
|
|
borderRadius: "12px",
|
|
|
|
margin: "20px 0",
|
|
|
|
backgroundColor: isExpanded ? "white" : "#333647"
|
|
|
|
}}
|
|
|
|
onDragStart={onDragStart}
|
|
|
|
>
|
2023-06-28 23:32:43 +00:00
|
|
|
<Box
|
|
|
|
sx={{ width: "100%", maxWidth: "760px", display: "flex", alignItems: "center", gap: "10px", padding: "20px" }}
|
|
|
|
>
|
2023-06-30 14:39:07 +00:00
|
|
|
<CustomTextField placeholder="Заголовок вопроса" text={""}
|
|
|
|
onChange={e => {updateQuestionsList(params, totalIndex, {title: e.target.value})
|
|
|
|
console.log(listQuestions[params][totalIndex].title)
|
|
|
|
}
|
|
|
|
}/>
|
|
|
|
<IconButton onClick={() => setIsExpanded((prev) => !prev)}>
|
2023-06-28 23:32:43 +00:00
|
|
|
{" "}
|
2023-06-30 14:39:07 +00:00
|
|
|
{isExpanded ?
|
|
|
|
<ExpandMoreIcon />
|
|
|
|
:<ExpandLessIcon fill="#7E2AEA"/>
|
|
|
|
}
|
2023-06-28 23:32:43 +00:00
|
|
|
</IconButton>
|
2023-06-30 17:59:50 +00:00
|
|
|
<Box sx={{display: "flex"}}>
|
|
|
|
<FormControlLabel
|
|
|
|
control={
|
|
|
|
<Checkbox
|
|
|
|
icon={<HideIcon/>}
|
|
|
|
checkedIcon={<CrossedEyeIcon />}
|
|
|
|
/>}
|
|
|
|
label={""}
|
|
|
|
sx={{
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
ml: "-9px",
|
|
|
|
mr: 0,
|
|
|
|
userSelect: "none",
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
<IconButton><CopyIcon/></IconButton>
|
|
|
|
<IconButton sx={{ borderRadius: "6px", padding: "2px" }} onClick={DeleteClick}>
|
|
|
|
<DeleteIcon />
|
|
|
|
</IconButton>
|
|
|
|
</Box>
|
2023-06-28 23:32:43 +00:00
|
|
|
<OneIcon />
|
|
|
|
<PointsIcon />
|
2023-06-30 17:59:50 +00:00
|
|
|
|
2023-06-28 23:32:43 +00:00
|
|
|
</Box>
|
2023-06-30 14:39:07 +00:00
|
|
|
{isExpanded && (
|
|
|
|
<Box sx={{display: "flex", flexDirection: "column", padding: 0, borderRadius: "12px"}}>
|
|
|
|
{switchState.length === 0 ?
|
2023-06-30 17:59:50 +00:00
|
|
|
<TypeQuestions totalIndex={totalIndex}/>
|
2023-06-30 14:39:07 +00:00
|
|
|
:
|
2023-06-30 17:59:50 +00:00
|
|
|
<SwitchQuestionsPage totalIndex={totalIndex}/>}
|
2023-06-30 14:39:07 +00:00
|
|
|
</Box>)
|
|
|
|
}
|
2023-06-28 23:32:43 +00:00
|
|
|
</Paper>
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|