diff --git a/src/App.tsx b/src/App.tsx index 4c774233..a72b9c43 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,6 @@ import { BrowserRouter, Routes, Route } from "react-router-dom"; import HomePage from "./Pages/HomePage/HomePage"; +import JsonPage from "./Pages/JsonPage/Json" import NoPage from "./Pages/NoPage/NoPage"; import "./App.css"; import Header from "./Components/Header/Header"; @@ -11,6 +12,7 @@ function App() { } /> + }/> } /> diff --git a/src/Pages/HomePage/HomePage.css b/src/Pages/HomePage/HomePage.css index 298d54bc..3d24302c 100644 --- a/src/Pages/HomePage/HomePage.css +++ b/src/Pages/HomePage/HomePage.css @@ -1,7 +1,15 @@ .container{ display: grid; - grid-template: "x a b"; + grid-template-rows: auto; + grid-template-columns: auto; + grid-template-areas: ". a b"; gap:10px; justify-content: space-evenly; padding: 0% 3%; } + +.submit-btn{ + margin-top:50px; + position:relative; + width: 30%; +} \ No newline at end of file diff --git a/src/Pages/HomePage/HomePage.tsx b/src/Pages/HomePage/HomePage.tsx index ad335bdb..2b089458 100644 --- a/src/Pages/HomePage/HomePage.tsx +++ b/src/Pages/HomePage/HomePage.tsx @@ -2,6 +2,7 @@ import React, { useState, ChangeEvent } from "react"; import "./HomePage.css"; import DragDropFileInput from "../../Components/DragDropFileInput/DragDropFileInput"; import FileList from "../../Components/FileList/FileList"; +import { useNavigate } from "react-router-dom"; function HomePage() { const [files, setFiles] = useState([]); @@ -61,13 +62,18 @@ function HomePage() { } }; + const navigate = useNavigate(); + const Submit = ()=>{ + navigate('/Json',{state:{data:files}}) + } return (
- + {/**/}
+
); } diff --git a/src/Pages/JsonPage/Json.css b/src/Pages/JsonPage/Json.css new file mode 100644 index 00000000..97d4184b --- /dev/null +++ b/src/Pages/JsonPage/Json.css @@ -0,0 +1,24 @@ +.loader-container.active{ + display: block; + width: 100%; + height: 100vh; + position: fixed; + background: rgba(0, 0, 0, 0.834) + url("../../assets/6.svg") center + no-repeat; + z-index: 1; +} +.loader-container p{ + position: absolute; + top: 55%; + right:35%; + left:35%; +} + +.loader-container{ + display: none; +} + +pre{ + text-align: left; +} \ No newline at end of file diff --git a/src/Pages/JsonPage/Json.tsx b/src/Pages/JsonPage/Json.tsx new file mode 100644 index 00000000..863db864 --- /dev/null +++ b/src/Pages/JsonPage/Json.tsx @@ -0,0 +1,58 @@ +import { useEffect, useState } from "react"; +import { useLocation } from "react-router-dom"; +import "./Json.css" + + +function JsonPage(){ + const [loading, setLoading] = useState(true) + const [form, setForm]=useState({}) + const [fetchError, setError]=useState(null) + const location = useLocation(); + const file:File = location.state.data[0]; + + console.log(file) + + const api_url = "http://localhost:5000" + useEffect(()=>{ + const formData = new FormData() + formData.append("file",file) + fetch(api_url+"/upload",{ + method:'POST', + headers:{ + + }, + body:formData + }).then((res:Response)=>{ + fetch(api_url+"/analyze",{ + method:'GET', + headers:{ + + } + }).then((response:Response)=>{ + response.json().then((data)=>{ + console.log(data) + setForm(data) + setLoading(false) + }).catch(e=>{ + setLoading(false) + setError(e) + console.log(e) + }) + }) + }) + },[]) + return ( +
+
+
+

+ Votre fichier est en cours d'analyse + Your file is being analyzed +

+
+
{(fetchError ? 

{fetchError.message}

: JSON.stringify(form, null, 2))}
+
+ ); +} + +export default JsonPage \ No newline at end of file diff --git a/src/assets/6.svg b/src/assets/6.svg new file mode 100644 index 00000000..971841cb --- /dev/null +++ b/src/assets/6.svg @@ -0,0 +1 @@ + \ No newline at end of file