improve questions preview
This commit is contained in:
parent
d8fca6a339
commit
db8e8029d0
@ -9,36 +9,36 @@ interface Props {
|
|||||||
|
|
||||||
export default function File({ question }: Props) {
|
export default function File({ question }: Props) {
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [files, setFiles] = useState<File[] | null>(null);
|
const [file, setFile] = useState<File | null>(null);
|
||||||
|
|
||||||
function handleFileChange(event: ChangeEvent<HTMLInputElement>) {
|
function handleFileChange(event: ChangeEvent<HTMLInputElement>) {
|
||||||
if (!event.target.files) return setFiles(null);
|
if (!event.target.files?.[0]) return setFile(null);
|
||||||
setFiles(Array.from(event.target.files));
|
setFile(event.target.files[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
|
alignItems: "start",
|
||||||
gap: 1,
|
gap: 1,
|
||||||
}}>
|
}}>
|
||||||
<Typography variant="h6">{question.title}</Typography>
|
<Typography variant="h6">{question.title}</Typography>
|
||||||
<Box>
|
<Button
|
||||||
<Button
|
variant="contained"
|
||||||
variant="contained"
|
onClick={() => fileInputRef.current?.click()}
|
||||||
onClick={() => fileInputRef.current?.click()}
|
>
|
||||||
>
|
Загрузить файл
|
||||||
Загрузить файл
|
<input
|
||||||
<input
|
ref={fileInputRef}
|
||||||
ref={fileInputRef}
|
onChange={handleFileChange}
|
||||||
onChange={handleFileChange}
|
type="file"
|
||||||
type="file"
|
style={{
|
||||||
style={{
|
display: "none",
|
||||||
display: "none",
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
</Button>
|
||||||
</Button>
|
{file && <Typography>Выбран файл: {file.name}</Typography>}
|
||||||
</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -53,16 +53,20 @@ export default function Images({ question }: Props) {
|
|||||||
borderColor: selectedVariants.includes(index) ? theme.palette.brightPurple.main : "#E3E3E3",
|
borderColor: selectedVariants.includes(index) ? theme.palette.brightPurple.main : "#E3E3E3",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img
|
{variant.extendedText ?
|
||||||
src={variant.extendedText}
|
<img
|
||||||
alt="question variant"
|
src={variant.extendedText}
|
||||||
style={{
|
alt="question variant"
|
||||||
width: "100%",
|
style={{
|
||||||
display: "block",
|
width: "100%",
|
||||||
objectFit: "scale-down",
|
display: "block",
|
||||||
flexGrow: 1,
|
objectFit: "scale-down",
|
||||||
}}
|
flexGrow: 1,
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
:
|
||||||
|
<Typography p={2}>Картинка отсутствует</Typography>
|
||||||
|
}
|
||||||
<Divider sx={{ width: "100%" }} />
|
<Divider sx={{ width: "100%" }} />
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
@ -12,12 +12,23 @@ export default function Page({ question }: Props) {
|
|||||||
<Box sx={{
|
<Box sx={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
|
alignItems: "start",
|
||||||
gap: 1,
|
gap: 1,
|
||||||
}}>
|
}}>
|
||||||
<Typography variant="h6">{question.title}</Typography>
|
<Typography variant="h6">{question.title}</Typography>
|
||||||
<Box>
|
<Typography>{question.content.text}</Typography>
|
||||||
<Typography>{question.content.text}</Typography>
|
{question.content.picture &&
|
||||||
</Box>
|
<img
|
||||||
|
src={question.content.picture}
|
||||||
|
alt=""
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
display: "block",
|
||||||
|
objectFit: "scale-down",
|
||||||
|
flexGrow: 1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,6 @@ export default function Varimg({ question }: Props) {
|
|||||||
<Box sx={{
|
<Box sx={{
|
||||||
border: "1px solid #E3E3E3",
|
border: "1px solid #E3E3E3",
|
||||||
maxWidth: "400px",
|
maxWidth: "400px",
|
||||||
minWidth: "200px",
|
|
||||||
minHeight: "150px",
|
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
@ -64,7 +62,7 @@ export default function Varimg({ question }: Props) {
|
|||||||
}}>
|
}}>
|
||||||
{currentVariant?.extendedText ?
|
{currentVariant?.extendedText ?
|
||||||
<img
|
<img
|
||||||
src={currentVariant?.extendedText}
|
src={currentVariant.extendedText}
|
||||||
alt="question variant"
|
alt="question variant"
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
@ -74,7 +72,7 @@ export default function Varimg({ question }: Props) {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
:
|
:
|
||||||
<Typography>Выберите вариант</Typography>
|
<Typography p={2}>{selectedVariantIndex === -1 ? "Выберите вариант" : "Картинка отсутствует"}</Typography>
|
||||||
}
|
}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
Loading…
Reference in New Issue
Block a user