Skip to content

Commit

Permalink
Merge pull request #66 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Protoype Release
  • Loading branch information
Pablo-ArgF authored Mar 13, 2023
2 parents 86720ab + 3ced142 commit 42174a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
17 changes: 3 additions & 14 deletions webapp/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@ function App(): JSX.Element {
const [isLoading, setIsLoading] = useState(true)
const [locations, setLocations] = useState<Array<Location>>([]);
const [selectedView, setselectedView] = useState<string>("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();
Expand All @@ -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)});
}
Expand Down Expand Up @@ -88,9 +81,6 @@ function App(): JSX.Element {
//previous way of deleting
//<button onClick={() => deleteLocation(session.session.info.webId as string, "https://patrigarcia.inrupt.net/profile/card#d8068302-9df2-4e42-a531-e3d39f685f93")}>DELETE</button>
//TODO delet this one implemented the correct deletion



return (
<>
<ChakraProvider>
Expand All @@ -111,7 +101,6 @@ function App(): JSX.Element {
<></>
}
<Menu changeViewTo= {(newView : string) => {setselectedView(newView)}}/>
{/* {handleLogin()} */}
{
!session.session.info.isLoggedIn ? (
<Login session={session.session}></Login>
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/components/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,7 +64,7 @@ const Map = ( props : MapProps) => {
onClick={() => handleMapClick(place)}
></Marker>
))}
<LocationView isOpen={isOpen} onClose={onClose} place={ !firstMark ? markedLocation : null}></LocationView>
<LocationView isOpen={isOpen} onClose={onClose} place={ firstMark ? markedLocation : ''}></LocationView>
</GoogleMap>
);

Expand Down
14 changes: 5 additions & 9 deletions webapp/src/components/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
};
Expand Down Expand Up @@ -63,14 +59,14 @@ function Login(props : any) : JSX.Element {
<Flex direction={'column'} bg={'white'} width={"40vw"} height={"40vh"} position={'relative'} zIndex={1} overflow='hidden' px={2} alignItems='center' borderRadius={'2vh'} padding='1vh' rowGap={'1vh'} justifyContent='space-evenly'>
<Image src={lomap_logo} width='20vw'></Image>
<Text fontSize={'2xl'}>Select your Solid pod provider:</Text>
<RadioGroup onChange={setuserChoice} value={userChoice}>
<RadioGroup onChange={setuserChoice} value={userChoice} >
<Stack direction='row'>
{
providerOptions.map((element,i) => {
if(i < providerOptions.length - 1)
return (<Radio value={element.value} onChange={(e)=>{setcustomSelected(false)}}>{element.label}</Radio>)
else //Last one is the custom one and should trigger the textBox
return (<Radio
return (<Radio
value={element.value}
onChange={(e)=>{setcustomSelected(true)}}
>
Expand Down

0 comments on commit 42174a0

Please sign in to comment.