Skip to content

Commit

Permalink
Merge pull request #26 from MarvinBo44/fix/more-fixes
Browse files Browse the repository at this point in the history
BIG END BANG BOOM, done
  • Loading branch information
StefanZuehlsdorf authored Aug 22, 2023
2 parents 4d1ede7 + 0551352 commit 79fbbbd
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 41 deletions.
27 changes: 16 additions & 11 deletions frontend/src/DayView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ type WeatherProps = {
dayActivities: Activity[];
}


type ActivityDataProps = {
dayActivity: Activity
}

export default function DayView(props: WeatherProps) {



function ActivityCard(props: ActivityDataProps) {
return (
<li className={"activityOutput"}>
Expand All @@ -42,26 +39,34 @@ export default function DayView(props: WeatherProps) {
const dayAfterTomorrowWeather = getForecastByDate(new Date(new Date().setDate(new Date().getDate() + 2)).toISOString().split('T')[0]);

function isWarm() {
if (props.weather.current.temp_c >= 25) {
return true;
if (props.weather != undefined) {
if (props.weather.current.temp_c >= 25) {
return true;
}
}
}

function isMiddle() {
if (props.weather.current.temp_c >= 10 && props.weather.current.temp_c <= 24){
return true;
if (props.weather != undefined) {
if (props.weather.current.temp_c >= 10 && props.weather.current.temp_c <= 24) {
return true;
}
}
}

function isCold() {
if (props.weather.current.temp_c < 10) {
return true;
if (props.weather != undefined) {
if (props.weather.current.temp_c < 10) {
return true;
}
}
}

function isRaining() {
if (props.weather.current.precip_mm > 0) {
return true;
if (props.weather != undefined) {
if (props.weather.current.precip_mm > 0) {
return true;
}
}
}

Expand Down
10 changes: 2 additions & 8 deletions frontend/src/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import DayView, {Activity} from "./DayView.tsx";
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 type Weather = {
"location": {
"name": string,
Expand Down Expand Up @@ -3008,7 +3007,7 @@ export type Activity = {
possibleWhenRaining: boolean,
possibleWithChildren: boolean,
insideActivity: boolean,
outsideActivity: boolean,
outsideActivity: boolean
}

export default function HomePage(){
Expand All @@ -3031,7 +3030,6 @@ export default function HomePage(){
}, []);



useEffect(() => {
axios({
// url: "http://api.weatherapi.com/v1/forecast.json?key=6cc628764c7547e298d143025230108&q="+ort+"&days=3&aqi=yes&alerts=no",
Expand All @@ -3042,15 +3040,11 @@ export default function HomePage(){
});
}, [city]);

console.log(city)
console.log("https://api.weatherapi.com/v1/forecast.json?key=dcf0dc2ec78e416e81375800232108&q="+city+"&days=3&aqi=yes&alerts=no")

return (
<>
{weather != undefined && <MenuBar weather={weather} city={city}/>}
<Settings setDayActivity={setDayActivity} setCity={setCity}/>
{weather != undefined && <DayView weather={weather} dayActivities={dayActivities}/>}
{/*<SearchCity setCity={setCity}></SearchCity>*/}
</>
)
}
9 changes: 5 additions & 4 deletions frontend/src/Menubar/AddActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import {
FormGroup, FormControlLabel, FormLabel, Checkbox, TextField
} from '@mui/material';
import {useNavigate} from "react-router-dom";
import {Activity} from "../HomePage.tsx";

type SetDayActivity = {
setDayActivity: (newActivities: Activity[]) => void,
}


export default function AddActivity(props) {
export default function AddActivity(props: SetDayActivity) {

const [possibleWhenWarm, setPossibleWhenWarm] = useState(false)
const [possibleWhenMiddle, setPossibleWhenMiddle] = useState(false)
Expand Down Expand Up @@ -85,8 +88,6 @@ export default function AddActivity(props) {
);
}



return <>
<Button size={"small"}
color={"info"}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/Menubar/MenuBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ type WeatherProps = {
city: string;
}


export default function MenuBar(props: WeatherProps) {
return props.weather === undefined ? <div>loading</div> :
<Grid container
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/Menubar/WeatherWidgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import WbSunnyIcon from '@mui/icons-material/WbSunny';
import {Grid, Box, Typography} from "@mui/material";
import {Weather} from "../HomePage.tsx";



type WeatherProps = {
weather: Weather | undefined;
city: string;
Expand All @@ -26,7 +24,6 @@ const styles = {

export default function WeatherWidgets(props:WeatherProps) {


return props.weather === undefined ? <p>Loading...</p> : (
<Box>
<Grid container
Expand Down
17 changes: 7 additions & 10 deletions frontend/src/SearchCity.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
// import {TextField} from "@mui/material";
import {Button, Grid, TextField} from "@mui/material";
import {ChangeEvent, useState} from "react";

type Props = {
setCity: (newCity: string) => void
};

// import {useState} from "react";
import {Box, Button, FormGroup, Grid, TextField} from "@mui/material";
import {useState} from "react";
export default function SearchCity(props: Props) {

export default function SearchCity(props) {

// Local state to hold the current value of the input
const [inputValue, setInputValue] = useState('');

// Handler function for the TextField's onChange event
const handleInputChange = (event) => {
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
setInputValue(event.target.value);
};

// Handler function for the button's onClick event
const handleClick = () => {
props.setCity(inputValue);
};
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import AddActivity from "./Menubar/AddActivity.tsx";
import {Box, Button, Grid, TextField} from "@mui/material";
import SearchCity from "./SearchCity.tsx";
import {useState} from "react";
import {ChangeEvent, useState} from "react";
import {Activity} from "./HomePage.tsx";

export default function Settings(props) {
type Props = {
setDayActivity: (newActivities: Activity[]) => void,
setCity: (newCity: string) => void
}

export default function Settings(props: Props) {

// Local state to hold the current value of the input
const [inputValue, setInputValue] = useState('');

// Handler function for the TextField's onChange event
const handleInputChange = (event) => {
const handleInputChange = (event: ChangeEvent<HTMLInputElement>) => {
setInputValue(event.target.value);
};

Expand Down

0 comments on commit 79fbbbd

Please sign in to comment.