From 56bd9abda20bdc5ba15d6af31cc8621b19ac22a8 Mon Sep 17 00:00:00 2001 From: UO283216 <98907723+UO283216@users.noreply.github.com> Date: Tue, 14 Mar 2023 00:27:51 +0100 Subject: [PATCH 1/2] Bug fixes and code cleanup (TODO fix click locat.) --- webapp/src/App.tsx | 17 +++-------------- webapp/src/components/login/Login.tsx | 14 +++++--------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/webapp/src/App.tsx b/webapp/src/App.tsx index 1ecf82f..0f8e147 100644 --- a/webapp/src/App.tsx +++ b/webapp/src/App.tsx @@ -23,20 +23,13 @@ function App(): JSX.Element { const [isLoading, setIsLoading] = useState(true) const [locations, setLocations] = useState>([]); const [selectedView, setselectedView] = useState("none") - const [userChoice, setuserChoice] = useState('https://inrupt.net/') - const [customSelected, setcustomSelected] = useState(false) - const providerOptions = [ //last one must be the custom one, they are auto generated - { value: 'https://inrupt.net/', label: 'Inrupt.net' }, - { value: 'https://solidcommunity.net/', label: 'Solid Community' }, - { value: String({userChoice}), label : 'Custom provider'} - ] const getNewLocation = (location:Location) => { - console.log("coming from AddLocation", location) + // console.log("coming from AddLocation", location) locations.push(location); createLocation(session.session.info.webId as string, location); - console.log(locations); + // console.log(locations); } const session = useSession(); @@ -57,7 +50,7 @@ function App(): JSX.Element { // setIsLoading(true) // setLocations([]); // }); - console.log(session) + // console.log(session) if(session.session.info.webId){ getLocations(session.session.info.webId).then((result)=>{setLocations(result); setIsLoading(false); console.log(result)}); } @@ -88,9 +81,6 @@ function App(): JSX.Element { //previous way of deleting // //TODO delet this one implemented the correct deletion - - - return ( <> @@ -111,7 +101,6 @@ function App(): JSX.Element { <> } {setselectedView(newView)}}/> - {/* {handleLogin()} */} { !session.session.info.isLoggedIn ? ( diff --git a/webapp/src/components/login/Login.tsx b/webapp/src/components/login/Login.tsx index ad52852..7e4fda8 100644 --- a/webapp/src/components/login/Login.tsx +++ b/webapp/src/components/login/Login.tsx @@ -9,25 +9,21 @@ import { useState } from "react"; function Login(props : any) : JSX.Element { - const [podProvider, setProvider] = React.useState('https://inrupt.net/'); const [userChoice, setuserChoice] = useState('https://inrupt.net/%27'); const [customSelected, setcustomSelected] = useState(false) const providerOptions = [ { value: 'https://solidcommunity.net/', label: 'Solid Community' }, - { value: 'https://inrupt.net/', label: 'Inrupt' } + { value: 'https://inrupt.net/', label: 'Inrupt' }, + { value: String({userChoice}), label : 'Custom provider'} ] - - const handleChange = (event) => { - setProvider(event.target.value as string); - }; const handleSubmit = async (e) => { //TODO refactor this once the restapi implementation is working e.preventDefault(); //if not used, the page will reload and data will be lost login({ redirectUrl: window.location.href, // after redirect, come to the actual page - oidcIssuer: podProvider, // redirect to the url + oidcIssuer: userChoice, // redirect to the url clientName: "Lo Map", }); }; @@ -63,14 +59,14 @@ function Login(props : any) : JSX.Element { Select your Solid pod provider: - + { providerOptions.map((element,i) => { if(i < providerOptions.length - 1) return ({setcustomSelected(false)}}>{element.label}) else //Last one is the custom one and should trigger the textBox - return ({setcustomSelected(true)}} > From 3ced142ff818bc7d7730e5be47b8d7310809d380 Mon Sep 17 00:00:00 2001 From: Patri Date: Tue, 14 Mar 2023 00:38:27 +0100 Subject: [PATCH 2/2] bug fixed --- webapp/src/components/Map.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/webapp/src/components/Map.tsx b/webapp/src/components/Map.tsx index feb7462..468cc5e 100644 --- a/webapp/src/components/Map.tsx +++ b/webapp/src/components/Map.tsx @@ -32,8 +32,8 @@ const Map = ( props : MapProps) => { const onUnmount = React.useCallback(function callback() {setMap(null)}, []) const handleMapClick = (location) => { - !firstMark ? setYes(true) : // - setMarkedLocation(location); + !firstMark ? setYes(true) : setYes(false) + setMarkedLocation(location); const newCenter = { lat: location.coordinates.lat, lng: location.coordinates.lng @@ -64,7 +64,7 @@ const Map = ( props : MapProps) => { onClick={() => handleMapClick(place)} > ))} - + );