frontend/Components/ErrorViewer/index.tsx

62 lines
2.6 KiB
TypeScript
Raw Normal View History

2022-08-26 22:49:44 +03:00
import React, { useState } from "react";
import DocViewer, { DocViewerRenderers } from "react-doc-viewer";
import styles from "./error.module.css"
import 'antd/dist/antd.css';
interface ErrorViewerIE{
errText:string;
2022-08-27 12:17:39 +03:00
paragraph: [number, string][];
2022-08-26 22:49:44 +03:00
variants?: string[];
num: number;
2022-08-27 12:17:39 +03:00
correct:boolean;
2022-08-26 22:49:44 +03:00
}
export const ErrorViewer : React.FC<ErrorViewerIE> = (props) =>{
const [open, setOpen] = useState(false)
return(
2022-08-27 01:37:17 +03:00
<div className={styles.viewer}>
<div className={styles.card}>
<div className={styles.leftSide}>
<img src={props.correct? "/images/correct.svg":"/images/err.svg"}></img>
<div style={{color:"rgba(0, 0, 0, 0.45)"}}>{props.num}</div>
<div className={styles.Text}>
{props.errText}
</div>
2022-08-26 22:49:44 +03:00
</div>
2022-08-27 01:37:17 +03:00
<div className={styles.rightSide}>
<div className={styles.correct}>{props.correct? "Нет замечаний":"Есть замечания"}</div>
<div onClick={()=>setOpen(!open)} className={styles.arrow}>
<span style={{color:"#1890FF"}}>Посмотреть</span>
<img style={{transform: open? "rotate(180deg)":""}} src="/images/arrow.svg"></img>
</div>
</div>
</div>
{ open?
<div className={styles.fixes}>
<div className={styles.paragraphs}>
2022-08-26 22:49:44 +03:00
{
props.paragraph.map(
2022-08-27 01:37:17 +03:00
(value, index)=><div className={styles.paragraph}>
2022-08-27 17:41:59 +03:00
<div className={styles.num}><strong>{index+1}</strong> <div className={styles.circle} style={{opacity:"0.5",background: Number(value[1])<50? "#F5222D": Number(value[1]) < 70? "#E3F32A":"#52C41A", display:props.correct? "":"none"}}></div></div>
2022-08-27 12:17:39 +03:00
<div className={styles.paragraph}>{value[0]}</div>
<div style={{display: props.correct? "":"none"}}><strong>Score:{value[1]}</strong></div>
2022-08-27 01:37:17 +03:00
</div>
2022-08-26 22:49:44 +03:00
)
}
</div>
<div style={{display: props.variants==undefined? "none":""}}>
{
props.variants?.map(
(value)=><div className={styles.variant}>{value}</div>
)
}
</div>
</div>
2022-08-27 01:37:17 +03:00
:<div></div>
}
2022-08-26 22:49:44 +03:00
</div>
);
}