updated classes fetching endpoint
This commit is contained in:
parent
4c2820d3b8
commit
8ceef555d1
@ -66,7 +66,6 @@ export const Dropdown = ({ clearInput, handleClearInput }: DropdownProps) => {
|
|||||||
//courses - choosenCourses
|
//courses - choosenCourses
|
||||||
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
|
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
|
||||||
|
|
||||||
|
|
||||||
const { courses, basket, addToBasket } = useContext(coursesContext)!;
|
const { courses, basket, addToBasket } = useContext(coursesContext)!;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { MouseEvent, useEffect, useState } from 'react';
|
import React, { MouseEvent, useState } from 'react';
|
||||||
import { Group, GroupType } from '../types';
|
import { Group, GroupType } from '../types';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import Popover from '@material-ui/core/Popover';
|
import Popover from '@material-ui/core/Popover';
|
||||||
@ -48,13 +48,13 @@ const Classes = styled.div<ClassesProps>`
|
|||||||
z-index: 2;
|
z-index: 2;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
|
||||||
font-size:0.90vw;
|
font-size: 0.9vw;
|
||||||
/* background-color: rgb(100, 181, 246); */
|
/* background-color: rgb(100, 181, 246); */
|
||||||
width: ${({ cellWidth }) => (cellWidth * 2.5) / 3}px;
|
width: ${({ cellWidth }) => (cellWidth * 2.5) / 3}px;
|
||||||
height: ${({ cellHeight }) => (cellHeight * 2 * 3) / 4}px;
|
height: ${({ cellHeight }) => (cellHeight * 2 * 3) / 4}px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color:${({groupType})=>groupType === "CLASS" ? "#FFDC61" : "#A68820"};
|
background-color: ${({ groupType }) => (groupType === 'CLASS' ? '#FFDC61' : '#A68820')};
|
||||||
box-shadow: 9px 9px 8px -2px rgba(0, 0, 0, 0.59);
|
box-shadow: 9px 9px 8px -2px rgba(0, 0, 0, 0.59);
|
||||||
`;
|
`;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight
|
|||||||
{groups.map(
|
{groups.map(
|
||||||
(group, index) =>
|
(group, index) =>
|
||||||
group.day === eventIndex && (
|
group.day === eventIndex && (
|
||||||
<>
|
<div key={index}>
|
||||||
<Classes
|
<Classes
|
||||||
groupType={group.type}
|
groupType={group.type}
|
||||||
cellWidth={cellWidth}
|
cellWidth={cellWidth}
|
||||||
@ -141,7 +141,7 @@ export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight
|
|||||||
<p>{groups[index].room}</p>
|
<p>{groups[index].room}</p>
|
||||||
</Typography>
|
</Typography>
|
||||||
</Popover>
|
</Popover>
|
||||||
</>
|
</div>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
</SchedulerEvent>
|
</SchedulerEvent>
|
||||||
|
@ -75,18 +75,10 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchData = async () => {
|
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`,
|
`${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));
|
courses.sort((a: Course, b: Course) => (a.name > b.name ? 1 : -1));
|
||||||
|
|
||||||
setCourses(courses);
|
setCourses(courses);
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
|
Loading…
Reference in New Issue
Block a user