diff --git a/src/components/App.tsx b/src/components/App.tsx index d4f107a..8007e3f 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -35,23 +35,21 @@ export const App = () => { <> }> {userPrivilige !== 'ADMIN' && ( - <> - - - - {userPrivilige === 'STUDENT' && ( - <> - - - - )} - {userPrivilige === 'DEANERY' && } - - - )} - {userPrivilige === 'ADMIN' && ( - + <> + + + + {userPrivilige === 'STUDENT' && ( + <> + + + + )} + {userPrivilige === 'DEANERY' && } + + )} + {userPrivilige === 'ADMIN' && } ); diff --git a/src/components/CourseCard.tsx b/src/components/CourseCard.tsx index e1dc2b6..8404274 100644 --- a/src/components/CourseCard.tsx +++ b/src/components/CourseCard.tsx @@ -158,7 +158,7 @@ export const CourseCard = ({ course }: CourseCardProps) => { } = useContext(coursesContext)!; const [isSelected, setSelected] = useState(true); const groups = [...course.lectures!, ...course.classes!]; - const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.id), []); + const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []); const [previous, setPrevious] = useState(basketCourseGroups); const onGroupClick = (group: Group, courseId: number) => { diff --git a/src/components/Transfer.tsx b/src/components/Transfer.tsx index ac30265..7932431 100644 --- a/src/components/Transfer.tsx +++ b/src/components/Transfer.tsx @@ -9,10 +9,11 @@ import { Group } from '../types'; import { coursesContext } from '../contexts/CoursesProvider'; import { Dropdown } from './Dropdown'; import { DropdownModal } from './DropdownModal'; +import { dayMapping } from '../constants'; interface TransferProps { handleClose: (e: React.MouseEvent) => void; - isOpen: boolean; + isTransferOpen: boolean; } const useStyles = makeStyles({ @@ -107,10 +108,10 @@ const createExchange = async (groupsIds: Array) => { } }; -export const Transfer = ({ handleClose, isOpen }: TransferProps) => { - const { selectGroups } = useContext(coursesContext)!; +export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => { + const { basket } = useContext(coursesContext)!; const classes = useStyles(); - const groups = selectGroups(); + // const groups = selectGroups(); const [input, setInput] = useState(''); const [open, setOpen] = useState(false); @@ -133,29 +134,39 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => { const handleCloseDropdown = () => setOpen(false); useEffect(() => { const getExchanges = async () => { - const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`); - console.log('exchanges: ', data); - setExchanges(data); + try { + const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`); + console.log('exchanges: ', data); + setExchanges(data); + } catch (e) { + console.log(e); + } }; const getAssignmentsGroups = async () => { - const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`); - console.log('assignments: ', data); - setAssignmentsGroups(data); + try { + const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`); + console.log('assignments: ', data); + const classes = data.filter((el: any) => el.type === 'CLASS'); + setAssignmentsGroups(classes); + } catch (e) { + console.log(e); + } }; + console.log('open changed'); getExchanges(); getAssignmentsGroups(); - }, []); + }, [isTransferOpen]); return (
- + Oddam @@ -172,7 +183,7 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => { {assignmentsGroups.map((el) => { return ( - {el.name} + {`${el.name} (${dayMapping[el.day - 1]} ${el.time} ${el.endTime})`} ); })} @@ -183,12 +194,11 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => { PrzyjmÄ™ - {/* */} - + {/* { handleShowDropdown(); }} - /> + /> */} Array; selectBasketNames: () => Array; selectBasketCourses: () => Array; - selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined }; + selectBasketCourseGroups: (courseName: string) => { lecture: Group | undefined; classes: Group | undefined }; selectGroups: () => Array; getNewestStudentTimetable: (studentId: string) => void; getStudentTimetablesHistory: (studentId: string) => void; @@ -100,8 +100,8 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => { }, [] as Array); }; - const selectBasketCourseGroups = (courseId: number) => { - const course = basket.find(({ id }) => id === courseId); + const selectBasketCourseGroups = (courseName: string) => { + const course = basket.find(({ name }) => name === courseName); if (course !== undefined) { return { lecture: course.lecture, classes: course.classes }; } else {