2022-08-26 15:28:20 +03:00
|
|
|
|
import type { NextPage } from 'next'
|
|
|
|
|
import Head from 'next/head'
|
2022-08-26 22:49:44 +03:00
|
|
|
|
import { ErrorViewer } from '../Components/ErrorViewer'
|
2022-08-26 20:02:52 +03:00
|
|
|
|
import { FileUploader } from '../Components/FileUploader'
|
2022-08-26 22:49:44 +03:00
|
|
|
|
import { Header } from '../Components/header'
|
2022-08-26 15:28:20 +03:00
|
|
|
|
import styles from '../styles/Home.module.css'
|
2022-08-26 22:49:44 +03:00
|
|
|
|
import 'antd/dist/antd.css';
|
2022-08-27 01:37:17 +03:00
|
|
|
|
import { ItemSelect, SelectItemIE } from '../Components/ItemSelect'
|
|
|
|
|
import { useState } from 'react'
|
2022-08-27 03:48:28 +03:00
|
|
|
|
import { get } from './api/fetch'
|
|
|
|
|
import { host } from './api/consts'
|
|
|
|
|
import { PulseLoader } from 'react-spinners'
|
|
|
|
|
import axios from 'axios'
|
2022-08-27 01:37:17 +03:00
|
|
|
|
|
|
|
|
|
|
2022-08-26 15:28:20 +03:00
|
|
|
|
|
|
|
|
|
const Home: NextPage = () => {
|
2022-08-27 01:37:17 +03:00
|
|
|
|
|
2022-08-27 03:48:28 +03:00
|
|
|
|
let files = JSON.parse(localStorage.getItem("files") as string)
|
|
|
|
|
const [file, setFile] = useState(files[0].uuid)
|
|
|
|
|
const [data,setData] = useState("")
|
2022-08-27 01:37:17 +03:00
|
|
|
|
let i = 1;
|
|
|
|
|
let cards = new Array<JSX.Element>()
|
|
|
|
|
|
2022-08-27 03:48:28 +03:00
|
|
|
|
const getData = () =>{
|
|
|
|
|
if (data == ""){
|
|
|
|
|
axios.get(host+"/api/docx/" + file).then(res => {
|
|
|
|
|
setData(res.data)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const onFileChange = (newFile:any) =>{
|
|
|
|
|
setData("")
|
|
|
|
|
axios.get(host+"/api/docx/" + newFile).then(res => {
|
|
|
|
|
setData(res.data)
|
|
|
|
|
})
|
|
|
|
|
setFile(newFile)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTimeout(getData, 2000);
|
|
|
|
|
if (data != ""){
|
|
|
|
|
for(var name in data as any) {
|
|
|
|
|
cards.push(
|
2022-08-27 01:37:17 +03:00
|
|
|
|
<ErrorViewer
|
|
|
|
|
num={i}
|
|
|
|
|
paragraph={(data as any)[name][0]==undefined? ["Выявлено отсутсвие данного модуля"]:(data as any)[name]}
|
|
|
|
|
errText={name}
|
|
|
|
|
correct={(data as any)[name][0]==undefined? false:true}
|
|
|
|
|
></ErrorViewer>
|
2022-08-27 03:48:28 +03:00
|
|
|
|
)
|
|
|
|
|
i++
|
2022-08-27 01:37:17 +03:00
|
|
|
|
}
|
2022-08-27 03:48:28 +03:00
|
|
|
|
}
|
2022-08-27 01:37:17 +03:00
|
|
|
|
|
2022-08-27 03:48:28 +03:00
|
|
|
|
let select = new Array<SelectItemIE>()
|
|
|
|
|
files.forEach((value : any) => {
|
|
|
|
|
select.push(
|
|
|
|
|
{
|
|
|
|
|
name: value.file.slice(48, value.uuid.lenght),
|
|
|
|
|
value: value.uuid
|
|
|
|
|
} as SelectItemIE
|
|
|
|
|
)
|
|
|
|
|
});
|
2022-08-27 01:37:17 +03:00
|
|
|
|
|
2022-08-26 15:28:20 +03:00
|
|
|
|
return (
|
|
|
|
|
<div className={styles.container}>
|
|
|
|
|
<Head>
|
2022-08-27 01:37:17 +03:00
|
|
|
|
<title>Загрузите файл</title>
|
2022-08-26 15:28:20 +03:00
|
|
|
|
<meta name="description" content="Generated by create next app" />
|
|
|
|
|
<link rel="icon" href="/favicon.ico" />
|
|
|
|
|
</Head>
|
|
|
|
|
<main className={styles.main}>
|
2022-08-26 22:49:44 +03:00
|
|
|
|
<Header></Header>
|
|
|
|
|
|
2022-08-27 01:37:17 +03:00
|
|
|
|
<div className={styles.selector}>
|
|
|
|
|
<ItemSelect
|
2022-08-27 03:48:28 +03:00
|
|
|
|
onChange={(val)=>onFileChange(val as any)}
|
|
|
|
|
items={select}
|
2022-08-27 01:37:17 +03:00
|
|
|
|
></ItemSelect>
|
2022-08-26 22:49:44 +03:00
|
|
|
|
</div>
|
2022-08-27 01:37:17 +03:00
|
|
|
|
<div className={styles.pagination}>
|
2022-08-27 03:48:28 +03:00
|
|
|
|
{data == ""? <PulseLoader color={"#13377D"}></PulseLoader>:cards}
|
2022-08-26 22:49:44 +03:00
|
|
|
|
</div>
|
2022-08-26 15:28:20 +03:00
|
|
|
|
</main>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Home
|