|
@@ -5,22 +5,63 @@ import React, {useEffect, useState} from "react";
|
|
|
import {SPRING_SERVER} from "../config";
|
|
import {SPRING_SERVER} from "../config";
|
|
|
import {Button} from "primereact/button";
|
|
import {Button} from "primereact/button";
|
|
|
import PathComponent from "../components/PathComponent";
|
|
import PathComponent from "../components/PathComponent";
|
|
|
|
|
+import {ScrollPanel} from "primereact/scrollpanel";
|
|
|
|
|
+import {Divider} from "primereact/divider";
|
|
|
|
|
+import {Accordion, AccordionTab} from "primereact/accordion";
|
|
|
|
|
+import ParcelsListComponent from "../components/ParcelsListComponent";
|
|
|
|
|
+import NewParcelComponent from "../components/NewParcelComponent";
|
|
|
|
|
+import MarkersComponent from "../components/MarkersComponent";
|
|
|
|
|
+import {Navigate, useNavigate} from "react-router-dom";
|
|
|
|
|
|
|
|
export default function () {
|
|
export default function () {
|
|
|
|
|
+ const navigate = useNavigate();
|
|
|
|
|
|
|
|
const [positions, setPositions] = useState([[51.746732, 19.450587], [51.744347, 19.451015]]);
|
|
const [positions, setPositions] = useState([[51.746732, 19.450587], [51.744347, 19.451015]]);
|
|
|
|
|
+ /*
|
|
|
|
|
+ const [authenticated, setAuthenticated] = useState(false)
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ if (!localStorage.getItem("access_token") || !localStorage.getItem("expires_at"))
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ localStorage.removeItem("access_token")
|
|
|
|
|
+ localStorage.removeItem("expires_at")
|
|
|
|
|
+ return <Navigate to="/" replace/>
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if (parseInt(localStorage.getItem("expires_at")) < Date.now()){
|
|
|
|
|
+ localStorage.removeItem("access_token")
|
|
|
|
|
+ localStorage.removeItem("expires_at")
|
|
|
|
|
+
|
|
|
|
|
+ return <Navigate to="/" replace/>
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /* useEffect(() => {
|
|
|
|
|
+ if (localStorage.getItem("access_token") && localStorage.getItem("expires_at") &&
|
|
|
|
|
+ localStorage.getItem("expires_at") < Date.now()) {
|
|
|
|
|
+ setAuthenticated(true)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ setAuthenticated(false)
|
|
|
|
|
+ }
|
|
|
|
|
+ })*/
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
|
+
|
|
|
const params = new URLSearchParams({
|
|
const params = new URLSearchParams({
|
|
|
- lon1: 19.45056,
|
|
|
|
|
- lat1: 51.74673,
|
|
|
|
|
|
|
+ lon1: 19.3037,
|
|
|
|
|
+ lat1: 51.8194,
|
|
|
lon2: 19.46211,
|
|
lon2: 19.46211,
|
|
|
lat2: 51.74275
|
|
lat2: 51.74275
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const url = SPRING_SERVER + '/route/nodes?' + params;
|
|
const url = SPRING_SERVER + '/route/nodes?' + params;
|
|
|
|
|
|
|
|
- fetch(url)
|
|
|
|
|
|
|
+ fetch(url, {
|
|
|
|
|
+ headers: {
|
|
|
|
|
+ "Authorization": "Bearer " + localStorage.getItem("access_token"),
|
|
|
|
|
+ // 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
.then(response => response.json())
|
|
.then(response => response.json())
|
|
|
.then(data => {
|
|
.then(data => {
|
|
|
setPositions(data)
|
|
setPositions(data)
|
|
@@ -29,21 +70,31 @@ export default function () {
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
const onButtonClick = () => {
|
|
const onButtonClick = () => {
|
|
|
- console.log(positions)
|
|
|
|
|
|
|
+ localStorage.removeItem("access_token")
|
|
|
|
|
+ return navigate("/")
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /*if (authenticated === true)*/
|
|
|
return (
|
|
return (
|
|
|
< >
|
|
< >
|
|
|
- <div className="flex flex-row h-screen">
|
|
|
|
|
- <div className="w-5 bg-orange-500 flex flex-column">
|
|
|
|
|
|
|
+ <div className="flex flex-row h-screen text-900 ">
|
|
|
|
|
+ <div className="w-5 bg-orange-500 flex flex-column align-items-center">
|
|
|
|
|
|
|
|
- <div className="flex flex-row align-self-center mt-3">
|
|
|
|
|
- <Avatar className="align-self-center" icon="pi pi-user" size="xlarge" shape="circle"
|
|
|
|
|
|
|
+ <div className="flex flex-row align-self-center mt-3 surface-200 w-11 border-round p-2 shadow-5">
|
|
|
|
|
+ <Avatar className="align-self-center text-700" icon="pi pi-user" size="xlarge" shape="circle"
|
|
|
style={{fontSize: '2.5rem'}}/>
|
|
style={{fontSize: '2.5rem'}}/>
|
|
|
- <div className="font-medium text-500 pl-2 align-self-center">USERNAME</div>
|
|
|
|
|
- <Button onClick={onButtonClick}></Button>
|
|
|
|
|
-
|
|
|
|
|
|
|
+ <div className="font-bold text-2xl pl-3 align-self-center">John Doe</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+
|
|
|
|
|
+ <Button className="col-11 mt-2" onClick={onButtonClick}><i className="pi pi-sign-out"
|
|
|
|
|
+ style={{fontSize: '1rem'}}></i></Button>
|
|
|
|
|
+ <ParcelsListComponent parcels={[
|
|
|
|
|
+ {'id': 1, 'name': 'package2241', 'address': 'New York 232-421'},
|
|
|
|
|
+ {'id': 2, 'name': 'package12437', 'address': 'New York 232-421'},
|
|
|
|
|
+ {'id': 2, 'name': 'package12437', 'address': 'New York 232-421'},
|
|
|
|
|
+ {'id': 2, 'name': 'package12437', 'address': 'New York 232-421'}]}></ParcelsListComponent>
|
|
|
|
|
+ <NewParcelComponent></NewParcelComponent>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="w-full bg-orange-500">
|
|
<div className="w-full bg-orange-500">
|
|
|
|
|
|
|
@@ -54,6 +105,7 @@ export default function () {
|
|
|
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
|
/>
|
|
/>
|
|
|
<PathComponent positions={positions}></PathComponent>
|
|
<PathComponent positions={positions}></PathComponent>
|
|
|
|
|
+ <MarkersComponent positions={positions}></MarkersComponent>
|
|
|
</MapContainer>
|
|
</MapContainer>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|