feat: OptionsPicture upload pictures
This commit is contained in:
parent
a49b999a38
commit
13f0e7fb55
@ -1,36 +1,48 @@
|
|||||||
import { Box, Link, Typography, useTheme } from "@mui/material";
|
import { useState } from "react";
|
||||||
import React from "react";
|
import { Box, Link, Typography, Button, useTheme } from "@mui/material";
|
||||||
|
|
||||||
|
import ButtonsOptions from "../ButtonsOptions";
|
||||||
|
import { questionStore, updateQuestionsList } from "@root/questions";
|
||||||
|
|
||||||
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
|
import EnterIcon from "../../../assets/icons/questionsPage/enterIcon";
|
||||||
import AddImage from "../../../assets/icons/questionsPage/addImage";
|
import AddImage from "../../../assets/icons/questionsPage/addImage";
|
||||||
import ButtonsOptions from "../ButtonsOptions";
|
|
||||||
import SwitchAnswerOptionsPict from "./switchOptionsPict";
|
import SwitchAnswerOptionsPict from "./switchOptionsPict";
|
||||||
|
|
||||||
|
import type { ChangeEvent } from "react";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
totalIndex: number;
|
totalIndex: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function OptionsPicture({ totalIndex }: Props) {
|
export default function OptionsPicture({ totalIndex }: Props) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [switchState, setSwitchState] = React.useState("setting");
|
const [switchState, setSwitchState] = useState("setting");
|
||||||
// const [addInput, setAddInput] = React.useState([
|
const { listQuestions } = questionStore();
|
||||||
// 0: {name: "распутье", variants: ["дорога влево", "дорога вправо"]};
|
|
||||||
// ]);
|
|
||||||
const SSHC = (data: string) => {
|
const SSHC = (data: string) => {
|
||||||
setSwitchState(data);
|
setSwitchState(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
// const createCondition = (name) => {
|
const addImage = ({ target }: ChangeEvent<HTMLInputElement>) => {
|
||||||
// addInput([...state, {name: name}])
|
if (target.files?.length) {
|
||||||
// }
|
const clonContent = listQuestions[totalIndex].content;
|
||||||
//
|
|
||||||
// const deleteCondition = (index) => {
|
clonContent.images.push(URL.createObjectURL(target.files[0]));
|
||||||
//
|
|
||||||
// }
|
updateQuestionsList(totalIndex, { content: clonContent });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box sx={{ padding: "20px" }}>
|
<Box sx={{ padding: "20px" }}>
|
||||||
<Box
|
<Box
|
||||||
sx={{ display: "flex", alignItems: "center", paddingBottom: "25px" }}
|
sx={{ display: "flex", alignItems: "center", paddingBottom: "25px" }}
|
||||||
>
|
>
|
||||||
<AddImage />
|
<Button component="label" sx={{ padding: "0px" }}>
|
||||||
|
<AddImage />
|
||||||
|
<input type="file" hidden onChange={addImage} />
|
||||||
|
</Button>
|
||||||
<Typography
|
<Typography
|
||||||
sx={{
|
sx={{
|
||||||
padding: "0 0 0 20px",
|
padding: "0 0 0 20px",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user