updated classes fetching endpoint

This commit is contained in:
maciekglowacki 2020-10-26 23:14:23 +01:00
parent 4c2820d3b8
commit 8ceef555d1
3 changed files with 9 additions and 18 deletions

View File

@ -66,7 +66,6 @@ export const Dropdown = ({ clearInput, handleClearInput }: DropdownProps) => {
//courses - choosenCourses
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
const { courses, basket, addToBasket } = useContext(coursesContext)!;
useEffect(() => {

View File

@ -1,4 +1,4 @@
import React, { MouseEvent, useEffect, useState } from 'react';
import React, { MouseEvent, useState } from 'react';
import { Group, GroupType } from '../types';
import styled from 'styled-components/macro';
import Popover from '@material-ui/core/Popover';
@ -35,7 +35,7 @@ const SchedulerEvent = styled.div<SchedulerEventProps>`
z-index: 2;
`;
interface ClassesProps{
interface ClassesProps {
cellWidth: number;
cellHeight: number;
groupType: GroupType;
@ -48,14 +48,14 @@ const Classes = styled.div<ClassesProps>`
z-index: 2;
border-radius: 10px;
font-size:0.90vw;
font-size: 0.9vw;
/* background-color: rgb(100, 181, 246); */
width: ${({ cellWidth }) => (cellWidth * 2.5) / 3}px;
height: ${({ cellHeight }) => (cellHeight * 2 * 3) / 4}px;
margin-right: 5px;
text-align: center;
background-color:${({groupType})=>groupType === "CLASS" ? "#FFDC61" : "#A68820"};
box-shadow: 9px 9px 8px -2px rgba(0,0,0,0.59);
background-color: ${({ groupType }) => (groupType === 'CLASS' ? '#FFDC61' : '#A68820')};
box-shadow: 9px 9px 8px -2px rgba(0, 0, 0, 0.59);
`;
interface SchedulerRowProps {
@ -98,7 +98,7 @@ export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight
{groups.map(
(group, index) =>
group.day === eventIndex && (
<>
<div key={index}>
<Classes
groupType={group.type}
cellWidth={cellWidth}
@ -141,7 +141,7 @@ export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight
<p>{groups[index].room}</p>
</Typography>
</Popover>
</>
</div>
),
)}
</SchedulerEvent>

View File

@ -75,18 +75,10 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
useEffect(() => {
const fetchData = async () => {
const { data } = await axios.get<Array<{ id: number; name: string; lectures: Array<Group>, classes:Array<Group> }>>(
const { data: courses } = await axios.get<Array<Course>>(
`${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`,
);
console.log(data);
const courses = data.map(({ id, name, lectures, classes }) => ({
id,
name,
lectures,
classes,
})) as Array<Course>;
courses.sort((a: Course, b: Course) => (a.name > b.name ? 1 : -1));
setCourses(courses);
};
fetchData();