Auth done
This commit is contained in:
parent
a4ff47bdb5
commit
148156fdca
@ -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;
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
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;
|
||||||
@ -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;
|
||||||
@ -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>
|
||||||
|
@ -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 };
|
||||||
|
Loading…
Reference in New Issue
Block a user