From 3644b82e29052bfbcb2814880b96faa872f3c130 Mon Sep 17 00:00:00 2001 From: wrzesinski-hubert Date: Thu, 20 Aug 2020 18:14:28 +0200 Subject: [PATCH] X button --- src/components/App.tsx | 2 +- src/components/Dropdown.tsx | 14 +++++++++++++- src/components/SchedulerEvents.tsx | 4 +--- src/components/Topbar.tsx | 16 ++++++++++------ src/contexts/CoursesProvider.tsx | 14 ++++---------- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/components/App.tsx b/src/components/App.tsx index dbc7646..14810b2 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,5 +1,5 @@ import React, { useState, useContext } from 'react'; -import { Topbar } from './Topbar'; +import Topbar from './Topbar'; import { Transfer } from './Transfer'; import { Scheduler } from './Scheduler'; import { Rightbar } from './Rightbar'; diff --git a/src/components/Dropdown.tsx b/src/components/Dropdown.tsx index d266b2a..6b76565 100644 --- a/src/components/Dropdown.tsx +++ b/src/components/Dropdown.tsx @@ -36,7 +36,12 @@ const useStyles = makeStyles({ }, }); -export const Dropdown = () => { +interface DropdownProps { + clearInput: boolean; + handleClearInput: ()=>void; +} + +export const Dropdown = ({clearInput,handleClearInput}:DropdownProps) => { const classes = useStyles(); const [open, setOpen] = React.useState(false); @@ -58,6 +63,13 @@ export const Dropdown = () => { filterCourses(input); }, [input, open, choosenCourses]); + useEffect(()=>{ + if(clearInput){ + setInput('') + handleClearInput() + } + },[clearInput]) + const handleChange = (event: React.ChangeEvent) => setInput(event.target.value); const handleClick = () => setOpen(true); diff --git a/src/components/SchedulerEvents.tsx b/src/components/SchedulerEvents.tsx index e9f3daf..38e25f7 100644 --- a/src/components/SchedulerEvents.tsx +++ b/src/components/SchedulerEvents.tsx @@ -18,14 +18,12 @@ export const SchedulerEvents = ({ cellTop, cellWidth }: SchedulerEventsProps) => } //delete later additional mappings const groupTimeToEventRowMapping: GroupTimeToEventRowMapping = { - '08.15': 0, + '8.15': 0, '10.00': 1, '11.45': 2, '13.45': 3, '15.30': 4, '17.15': 5, - '10.17': 0, - '13.55': 1, }; useEffect(() => { diff --git a/src/components/Topbar.tsx b/src/components/Topbar.tsx index 62a14de..c7cfcb7 100644 --- a/src/components/Topbar.tsx +++ b/src/components/Topbar.tsx @@ -15,7 +15,7 @@ const TopbarTextStyled = styled.div` } `; -const TopbarStyled = styled.div` +const Topbar = styled.div` background-color: #ffdc61; height: 80px; padding: 5px; @@ -58,6 +58,7 @@ const TopbarInputIconStyled = styled.img` @media only screen and (max-width: 670px) { width: 25px; } + cursor: pointer; `; const TopbarIcon = styled.img` @@ -79,7 +80,8 @@ interface TopbarProps { handleTransfer: (e: MouseEvent) => void; } -export const Topbar = ({ handleTransfer }: TopbarProps) => { +export default function ({ handleTransfer }: TopbarProps) { + const [clearInput, setClearInput] = useState(false); const [isPolish, setIsPolish] = useState(false); const [anchorEl, setAnchorEl] = useState(null); @@ -89,8 +91,10 @@ export const Topbar = ({ handleTransfer }: TopbarProps) => { const handleClose = () => setAnchorEl(null); + const handleClearInput = () => setClearInput(!clearInput); + return ( - + plan na plan @@ -98,9 +102,9 @@ export const Topbar = ({ handleTransfer }: TopbarProps) => { - + - + @@ -108,6 +112,6 @@ export const Topbar = ({ handleTransfer }: TopbarProps) => { - + ); }; diff --git a/src/contexts/CoursesProvider.tsx b/src/contexts/CoursesProvider.tsx index 27772ec..a60f27a 100644 --- a/src/contexts/CoursesProvider.tsx +++ b/src/contexts/CoursesProvider.tsx @@ -20,22 +20,16 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => { const [choosenGroups, setChoosenGroups] = useState>([]); const addChoosenCourse = (choosenCourse: Course) => { - console.log('adding course'); setChoosenCourses([...choosenCourses, choosenCourse]); }; const addChoosenGroup = (choosenGroup: Group) => { + //const choosenCourse = courses.filter(course=>(course.groups.map(group=>group.id).includes(choosenGroup.id))) + console.log("id" + choosenGroup.id ) + console.log("mapowanie: " + courses.filter(course=>(course.groups.map(group=>group.id)))); + //console.log("wybrane kursy: " + choosenCourse); setChoosenGroups([...choosenGroups, choosenGroup]); }; - useEffect(() => { - console.log('All courses'); - console.log(courses); - }, [courses]); - useEffect(() => { - console.log('Choosen courses'); - console.log(choosenCourses); - }, [choosenCourses]); - useEffect(() => { const fetchData = async () => { const { data } = await axios.get(`${process.env.REACT_APP_API_URL}/getCourses`);