Auth done

This commit is contained in:
maciekglowacki 2020-10-21 20:42:18 +02:00
parent a4ff47bdb5
commit 148156fdca
3 changed files with 16 additions and 17 deletions

View File

@ -1,7 +1,7 @@
import React, { useState, useContext, MouseEvent } from 'react'; import React, { useState, useContext, MouseEvent } from 'react';
import Collapse from '@material-ui/core/Collapse'; import Collapse from '@material-ui/core/Collapse';
import ExpandIcon from '../assets/expand.png'; import ExpandIcon from '../assets/expand.png';
import { Course, Group, GroupType } from '../types/index'; import { Course, Group } from '../types/index';
import { coursesContext } from '../contexts/CoursesProvider'; import { coursesContext } from '../contexts/CoursesProvider';
import styled from 'styled-components'; import styled from 'styled-components';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
@ -35,9 +35,7 @@ padding-left:35px;
padding-right:35px; padding-right:35px;
`; `;
interface ClassGroupProps {
groupType: GroupType;
}
const ClassGroupStyled = styled.div` const ClassGroupStyled = styled.div`
position:relative; position:relative;

View File

@ -1,20 +1,19 @@
import React, { useState, useContext, useEffect, MouseEvent, ChangeEvent } from 'react'; import React, { useState, useContext, useEffect, MouseEvent, ChangeEvent } from 'react';
import axios from 'axios';
import { Input } from '@material-ui/core'; import { Input } from '@material-ui/core';
import ClickAwayListener from '@material-ui/core/ClickAwayListener'; import ClickAwayListener from '@material-ui/core/ClickAwayListener';
import { coursesContext } from '../contexts/CoursesProvider'; import { coursesContext } from '../contexts/CoursesProvider';
import { Course, Basket } from '../types'; import { Course } from '../types';
import styled from 'styled-components'; import styled from 'styled-components';
import { makeStyles } from '@material-ui/core/styles'; import { makeStyles } from '@material-ui/core/styles';
const DropdownStyled = styled.div` const DropdownContainer = styled.div`
max-height: 420px; max-height: 420px;
overflow-y: auto; overflow-y: auto;
scroll-snap-type: y mandatory; scroll-snap-type: y mandatory;
scroll-behavior: smooth; scroll-behavior: smooth;
z-index: 100; z-index: 100;
position: relative; position: relative;
border-radius:0px 0px 0px 15px; border-radius: 0px 0px 0px 15px;
::-webkit-scrollbar-track { ::-webkit-scrollbar-track {
border-radius: 10px; border-radius: 10px;
background-color: #f5f5f5; background-color: #f5f5f5;
@ -30,7 +29,7 @@ const DropdownStyled = styled.div`
} }
`; `;
const CourseStyled = styled.div` const CourseContainer = styled.div`
position: relative; position: relative;
z-index: 10; z-index: 10;
padding: 5px; padding: 5px;
@ -39,7 +38,7 @@ const CourseStyled = styled.div`
font-size: 18px; font-size: 18px;
font-family: Lato; font-family: Lato;
scroll-snap-align: end; scroll-snap-align: end;
border-bottom:1px solid; border-bottom: 1px solid;
:hover { :hover {
background-color: #d4b851; background-color: #d4b851;
cursor: pointer; cursor: pointer;
@ -113,13 +112,13 @@ export const Dropdown = ({ clearInput, handleClearInput }: DropdownProps) => {
value={input} value={input}
/> />
{open && ( {open && (
<DropdownStyled> <DropdownContainer>
{filteredCourses.map(({ name, id }, index) => ( {filteredCourses.map(({ name, id }, index) => (
<CourseStyled key={index} id={id.toString()} onClick={onCourseClick}> <CourseContainer key={index} id={id.toString()} onClick={onCourseClick}>
<p>{name} </p> <p>{name} </p>
</CourseStyled> </CourseContainer>
))} ))}
</DropdownStyled> </DropdownContainer>
)} )}
</div> </div>
</ClickAwayListener> </ClickAwayListener>

View File

@ -26,18 +26,20 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
const token = CAS?.user?.token; const token = CAS?.user?.token;
const addToBasket = (course: Course) => { const addToBasket = (course: Course) => {
const courseToBasket = { const courseToBasket: Basket = {
name: course.name, name: course.name,
id: course.id, id: course.id,
classes: course.classes[0], classes: course.classes[0],
lecture: course.lectures !== undefined ? course.lectures[0] : undefined, lecture: course.lectures !== undefined ? course.lectures[0] : undefined,
} as Basket; };
setBasket([...basket, courseToBasket]); setBasket([...basket, courseToBasket]);
}; };
const deleteFromBasket = (id: number) => setBasket(basket.filter((course) => course.id !== id)); const deleteFromBasket = (id: number) => setBasket(basket.filter((course) => course.id !== id));
const saveBasket = async () => { const saveBasket = async () => {
try { try {
//to be deleted
let data = [7, 43, 54]; let data = [7, 43, 54];
let json = JSON.stringify(data); let json = JSON.stringify(data);
let post_data = { json_data: json }; let post_data = { json_data: json };