Skip to content

Commit

Permalink
styling menubar,settings,login,register
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinBo44 committed Aug 18, 2023
1 parent 7c7a14e commit dcd152e
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 190 deletions.
6 changes: 3 additions & 3 deletions frontend/src/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

import DayView from "./DayView.tsx";
import {useEffect, useState} from "react";
import axios from "axios";
import MenuBar from "./Menubar/MenuBar.tsx";
import Settings from "./Settings.tsx";

export default function HomePage(){

Expand All @@ -11,17 +11,17 @@ export default function HomePage(){
useEffect(() => {
axios({
// url: "http://api.weatherapi.com/v1/forecast.json?key=6cc628764c7547e298d143025230108&q="+ort+"&days=3&aqi=yes&alerts=no",
url: "https://api.weatherapi.com/v1/forecast.json?key=6cc628764c7547e298d143025230108&q=Lemgo&days=3&aqi=yes&alerts=no",
url: "https://api.weatherapi.com/v1/forecast.json?key=6cc628764c7547e298d143025230108&q=Berlin&days=3&aqi=yes&alerts=no",
method: "get"
}).then(function (response) {
setWeather(response.data);
});
}, []);


return (
<>
<MenuBar/>
<Settings/>
<DayView weather={weather}/>
</>
)
Expand Down
76 changes: 53 additions & 23 deletions frontend/src/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,73 @@
import {ChangeEvent, FormEvent, useState} from "react";
import {useState} from "react";
import axios from "axios";
import {Link, useNavigate} from "react-router-dom";
import {Button, Grid, TextField, Typography} from "@mui/material";

type Props = {
setUser: (user:string) => void
setUser: (user: string) => void
}

export default function LoginPage(loginPageProps:Props){
export default function LoginPage(loginPageProps: Props) {

const [username, setUsername] = useState("");
const [password, setPassword] = useState("");

const nav = useNavigate()

function onChangeHandlerUsername(event:ChangeEvent<HTMLInputElement>){
setUsername(event.target.value)
}

function onChnageHandlerPassword(event:ChangeEvent<HTMLInputElement>){
setPassword(event.target.value)
}

function login(event:FormEvent<HTMLFormElement>){
event.preventDefault();
function login() {
axios.post("/api/user/login", undefined, {auth: {username, password}})
.then((response) => loginPageProps.setUser(response.data))
.then(() => nav("/home"))
.catch((error) => console.log(error));
}

return(
<div>
<h1>LOGIN</h1>
<form onSubmit={login}>
<input type={"text"} id={"username"} placeholder={"enter your username"} required={true} onChange={onChangeHandlerUsername}/>
<input type={"password"} id={"password"} placeholder={"*****************"} required={true} onChange={onChnageHandlerPassword}/>
<button >Login</button>
</form>
<button><Link to={"/register"}>New here?</Link></button>
</div>
return (
<>
<Grid container={true}
direction={"column"}
alignItems={"center"}
p={"2%"}
>
<Grid container={true}
maxWidth={'350px'}
direction={'column'}
alignItems={'center'}
>
<Typography variant={"h2"}>
LOGIN
</Typography>
<br/>
<TextField id="username"
label={"Username"}
variant="outlined"
fullWidth={true}
onChange={e => setUsername(e.target.value)}
/>
<br/>
<TextField id="password"
type={'password'}
label={"Passwort"}
variant="outlined"
fullWidth={true}
onChange={e => setPassword(e.target.value)}
/>
<br/>
</Grid>
<Grid container={true}
justifyContent={"space-between"}
width={'350px'}
>
<Button onClick={() => {login()}}
variant={'outlined'}>
Einloggen
</Button>
<Button component={Link}
to={'/register'}
variant={'outlined'}>
Registrieren ?
</Button>
</Grid>
</Grid>
</>
);
}
20 changes: 7 additions & 13 deletions frontend/src/Menubar/AddActivity.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import axios from "axios";
import 'reactjs-popup/dist/index.css';
import {useState} from "react";
import {Button, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions,
FormGroup, FormControlLabel, FormLabel, Checkbox, TextField, Box} from '@mui/material';
import {
Button, Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions,
FormGroup, FormControlLabel, FormLabel, Checkbox, TextField
} from '@mui/material';

export default function AddActivity() {

Expand Down Expand Up @@ -75,17 +77,9 @@ export default function AddActivity() {
})
}

const styles = {
container: {
display: "flex",
backgroundColor: "#3866B2FF",
justifyContent: "space-evenly",
alignItems: "center",
}
};

return <Box style={styles.container}>
return <>
<Button size={"small"}
color={"info"}
variant={'contained'}
onClick={() => setOpenDialog(true)}
>Aktivität hinzufügen</Button>
Expand Down Expand Up @@ -151,5 +145,5 @@ export default function AddActivity() {
</Button>
</DialogActions>
</Dialog>
</Box>
</>
}
21 changes: 13 additions & 8 deletions frontend/src/Menubar/LogoutButton.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import {useNavigate} from "react-router-dom";
import {FormEvent} from "react";
import axios from "axios";
import {Button} from "@mui/material";


export default function LogoutButton() {
const nav = useNavigate();
function logout(event:FormEvent<HTMLFormElement>){
event.preventDefault()

function logout() {
axios.post("/api/user/logout")
.then((response) => console.log(response.data))
.then(()=>nav("/"))
.then(() => nav("/"))
.catch((error) => console.log(error))
}

return(
<form onSubmit={logout}>
<button>logout</button>
</form>
return (
<>
<Button
size={"medium"}
variant={'contained'}
color={"error"}
onClick={() => logout()}
>logout</Button>
</>
);
}
30 changes: 15 additions & 15 deletions frontend/src/Menubar/MenuBar.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import WeatherApi from "./WeatherAPI.tsx";
import AddActivity from "./AddActivity.tsx";
import {Box} from '@mui/material';
import {Grid, Typography} from '@mui/material';
import LogoutButton from "./LogoutButton.tsx";

const styles = {
menubar: {
display: "flex"
}
};

export default function MenuBar() {
return <Box>
<Box style={styles.menubar}>
<WeatherApi/>
<AddActivity/>
<LogoutButton/>
</Box>
</Box>
return <Grid container
direction="row"
justifyContent="space-around"
alignItems="center"
gap={2}
bgcolor={"#3866B2FF"}>
<Typography
variant={"h4"}
color={"white"}
fontFamily={"Copperplate, Papyrus, fantasy"}>To Be Able
</Typography>
<WeatherApi/>
<LogoutButton/>
</Grid>
}
29 changes: 8 additions & 21 deletions frontend/src/Menubar/WeatherAPI.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import {useEffect, useState} from 'react'
import axios from 'axios'
import LocationCityIcon from '@mui/icons-material/LocationCity';
Expand All @@ -8,7 +7,6 @@ import LocalFloristIcon from '@mui/icons-material/LocalFlorist';
import WbSunnyIcon from '@mui/icons-material/WbSunny';
import {Grid, Box, Typography} from "@mui/material";


type Weather = {
"location": {
"name": string,
Expand Down Expand Up @@ -3001,23 +2999,16 @@ type Weather = {
}
]
}
} //Weather Type End
}

const styles = {
gridContainer: {
backgroundColor: "#3866B2FF",
justifyContent: "space-evenly",
alignItems: "center",
},
gridItem: {
backgroundColor: "white",
padding: 5,
margin: 10,
borderRadius: 10,
align: "center",
},
boxItem: {
display: "flex"
display:'flex'
}
};

Expand All @@ -3027,24 +3018,20 @@ export default function WeatherApi() {

useEffect(() => {
axios({
url: "https://api.weatherapi.com/v1/forecast.json?key=6cc628764c7547e298d143025230108&q=Nordpol&days=3&aqi=yes&alerts=yes",
url: "https://api.weatherapi.com/v1/forecast.json?key=6cc628764c7547e298d143025230108&q=Berlin&days=3&aqi=yes&alerts=yes",
method: "get"
}).then(function (response) {
setWeather(response.data);
});
}, []);

return weather === undefined ? <p>Loading...</p> : (

<Box>
<Grid container style={styles.gridContainer}>
<Grid item>
<Box>
<Typography sx={{color:"white", fontFamily:"Verdana", }} paddingLeft={'5px'} paddingRight={'5px'}>
To Be Able
</Typography>
</Box>
</Grid>
<Grid container
direction="row"
justifyContent="center"
alignItems="center"
gap={2}>
<Grid item>
<Box style={styles.boxItem}>
<img src={weather.current.condition.icon} alt={"WeatherIcon"}/>
Expand Down
Loading

0 comments on commit dcd152e

Please sign in to comment.