fix bugs and deploy

This commit is contained in:
Firesieht 2022-08-28 11:05:58 +03:00
parent 9b907cbb0d
commit 301ca255d0
6 changed files with 32 additions and 21 deletions

View File

@ -25,26 +25,23 @@ const Home: NextPage = () => {
let i = 1;
let cards = new Array<JSX.Element>()
let correctClasses = 0
let select = new Array<SelectItemIE>()
const getData = () =>{
let localFiles = JSON.parse(localStorage == undefined? "":localStorage.getItem("files") as string)
setFiles(localFiles)
setFile(localFiles[0])
if (data == ""){
axios.get(host+"/api/site/docx/" + (localFiles[0] as any).uuid).then(res => {
setData(res.data)
axios.get(host+"/api/site/state/" + (localFiles[0] as any).uuid).then(res => {
if (res.data.paragraphs_processed > 0){
setTimeout(getData, 1000);
}
else{
axios.get(host+"/api/site/docx/" + (localFiles[0] as any).uuid).then(res => {
setData(res.data)
})
}
})
}
files.forEach((value : any) => {
select.push(
{
name: value.file.slice(48, value.uuid.lenght),
value: value
} as SelectItemIE
)
});
}
const onFileChange = (newFile:any) =>{
setData("")
@ -53,8 +50,9 @@ const getData = () =>{
})
setFile(newFile)
}
setTimeout(getData, 2000);
if (data == ""){
setTimeout(getData, 2000);
}
if (data != ""){
for(var name in data as any) {
if ((data as any)[name].correct){correctClasses++}
@ -88,11 +86,17 @@ const getData = () =>{
<main className={styles.main}>
<Header></Header>
<div className={styles.selector}>
<ItemSelect
onChange={(val)=>onFileChange(val as any)}
items={select}
></ItemSelect>
<div className={styles.selector}>{
files.length == 0? "" : <ItemSelect
onChange={(val)=>onFileChange(val as any)}
items={files.map((value:any)=> ({
name: value.file.slice(60, value.uuid.lenght),
value: value
} as SelectItemIE)
)}
></ItemSelect>
}
</div>
<div className={styles.pagination}>
<div className={styles.tools}>

View File

@ -29,7 +29,7 @@ const History: NextPage = () => {
localStorage.setItem(value.uuid, value.file)
files.push(
<div className={styles.fileCard} onClick={()=>router.push("/view/" + value.uuid)}>
{value.file.slice(48, value.file.lenght)}
{value.file.slice(60, 88)}
</div>
)
});

View File

@ -17,7 +17,13 @@ const Upload: NextPage = () => {
const onNext = () =>{
localStorage.setItem("files", JSON.stringify(files))
router.push("/files")
if (files.length > 0){
router.push("/files")
}
else{
alert("Загрузите файлы, потом все заработает")
}
}
return (

View File

@ -24,6 +24,7 @@ const View: NextPage = () => {
const [text, setText] = useState("")
const getData = () =>{
if (data == ""){
axios.get(host+"/api/site/docx/" + uuid).then(res => {
setData(res.data)
})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB