2020-08-17 23:56:34 +02:00
|
|
|
import React, { useState, useContext, MouseEvent } from 'react';
|
2020-08-17 22:05:13 +02:00
|
|
|
import { CourseCard } from './CourseCard';
|
|
|
|
import { coursesContext } from '../contexts/CoursesProvider';
|
2020-08-17 20:14:19 +02:00
|
|
|
import styled from 'styled-components';
|
2020-06-09 20:07:54 +02:00
|
|
|
|
2020-08-17 22:05:13 +02:00
|
|
|
const RightbarStyled = styled.div`
|
2020-08-17 20:14:19 +02:00
|
|
|
padding-top: 10px;
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-right: 15px;
|
|
|
|
text-align: center;
|
|
|
|
font-family: Lato;
|
2020-08-29 18:52:03 +02:00
|
|
|
height: 100%;
|
2020-08-17 20:14:19 +02:00
|
|
|
width: 300px;
|
|
|
|
overflow-y: scroll;
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
border-radius: 10px;
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
}
|
|
|
|
::-webkit-scrollbar {
|
|
|
|
width: 12px;
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
}
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
border-radius: 10px;
|
|
|
|
background-color: #d4b851;
|
|
|
|
border: 1px solid;
|
|
|
|
}
|
|
|
|
`;
|
2020-08-17 22:05:13 +02:00
|
|
|
const RightbarTextStyled = styled.div`
|
2020-08-17 20:14:19 +02:00
|
|
|
border-bottom: 1px solid;
|
|
|
|
`;
|
|
|
|
|
2020-08-17 23:56:34 +02:00
|
|
|
export const Rightbar = () => {
|
2020-08-23 17:22:50 +02:00
|
|
|
const { courses, basket } = useContext(coursesContext)!;
|
|
|
|
|
|
|
|
const getBasketGroups = () => {
|
2020-08-26 18:42:29 +02:00
|
|
|
const names = basket.map(({ name }) => name);
|
|
|
|
return courses.filter(({ name }) => names.includes(name));
|
2020-08-23 17:22:50 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const filteredCourses = getBasketGroups();
|
2020-06-30 22:09:13 +02:00
|
|
|
|
2020-08-17 23:56:34 +02:00
|
|
|
//need to insert student name from db and course maybe based on current time or from db too
|
2020-07-24 18:59:45 +02:00
|
|
|
return (
|
2020-08-17 22:05:13 +02:00
|
|
|
<RightbarStyled>
|
|
|
|
<RightbarTextStyled>
|
2020-07-24 18:59:45 +02:00
|
|
|
Hubert Wrzesiński<br></br>
|
|
|
|
Semestr zimowy 2020/2021
|
2020-08-17 22:05:13 +02:00
|
|
|
</RightbarTextStyled>
|
2020-08-23 17:22:50 +02:00
|
|
|
{filteredCourses.map((course, index) => (
|
2020-08-12 20:52:53 +02:00
|
|
|
<CourseCard
|
|
|
|
course={course}
|
2020-07-24 18:59:45 +02:00
|
|
|
key={index}
|
|
|
|
/>
|
|
|
|
))}
|
2020-08-17 22:05:13 +02:00
|
|
|
</RightbarStyled>
|
2020-07-24 18:59:45 +02:00
|
|
|
);
|
2020-08-17 23:56:34 +02:00
|
|
|
};
|