design changes
This commit is contained in:
parent
3ae44b5bcf
commit
e7d8e024d6
@ -66,7 +66,7 @@ interface ExpandIconProps {
|
|||||||
selected: boolean;
|
selected: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExpandIcon = styled(Expand)<ExpandIconProps>`
|
export const ExpandIcon = styled(Expand)<ExpandIconProps>`
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
max-width: 20px;
|
max-width: 20px;
|
||||||
@ -144,10 +144,14 @@ export const CourseCard = ({ course }: CourseCardProps) => {
|
|||||||
} = useContext(coursesContext)!;
|
} = useContext(coursesContext)!;
|
||||||
const [isSelected, setSelected] = useState(false);
|
const [isSelected, setSelected] = useState(false);
|
||||||
const groups = [...course.lectures!, ...course.classes!];
|
const groups = [...course.lectures!, ...course.classes!];
|
||||||
const [courseLecture, courseClasses] = selectBasketCourseGroups(course.id);
|
const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.id), []);
|
||||||
|
const [previous, setPrevious] = useState(basketCourseGroups);
|
||||||
// console.log('lecture is: ', courseLecture);
|
// console.log('lecture is: ', courseLecture);
|
||||||
// console.log('class is: ', courseClasses);
|
// console.log('class is: ', courseClasses);
|
||||||
const onGroupClick = (group: Group, courseId: number) => changeGroupInBasket(group, courseId);
|
const onGroupClick = (group: Group, courseId: number) => {
|
||||||
|
setPrevious((prev) => (group.type === GroupType.CLASS ? { ...prev, classes: group } : { ...prev, lecture: group }));
|
||||||
|
changeGroupInBasket(group, courseId);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CourseCardWrapper>
|
<CourseCardWrapper>
|
||||||
@ -168,20 +172,23 @@ export const CourseCard = ({ course }: CourseCardProps) => {
|
|||||||
key={index}
|
key={index}
|
||||||
onClick={() => onGroupClick(group, course.id)}
|
onClick={() => onGroupClick(group, course.id)}
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
if (group.type === GroupType.CLASS && courseClasses !== undefined) {
|
if (group.type === GroupType.CLASS) {
|
||||||
changeGroupInBasket(group, course.id);
|
changeGroupInBasket(group, course.id);
|
||||||
// setTimeout(()=> { changeHoveredGroup(courseClasses)},[500])
|
// setTimeout(()=> { changeHoveredGroup(courseClasses)},[500])
|
||||||
|
|
||||||
}
|
}
|
||||||
if (group.type === GroupType.LECTURE && courseLecture !== undefined) {
|
if (group.type === GroupType.LECTURE) {
|
||||||
changeGroupInBasket(group, course.id);
|
changeGroupInBasket(group, course.id);
|
||||||
// setTimeout(()=> { changeHoveredGroup(courseLecture)},[500])
|
// setTimeout(()=> { changeHoveredGroup(courseLecture)},[500])
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
onMouseLeave={() => {
|
onMouseLeave={() => {
|
||||||
if (hoveredGroup) {
|
if (hoveredGroup) {
|
||||||
changeGroupInBasket(hoveredGroup, course.id);
|
if (hoveredGroup.type === GroupType.CLASS && previous.classes !== undefined) {
|
||||||
|
changeGroupInBasket(previous.classes, course.id);
|
||||||
|
}
|
||||||
|
if (hoveredGroup.type === GroupType.LECTURE && previous.lecture !== undefined) {
|
||||||
|
changeGroupInBasket(previous.lecture, course.id);
|
||||||
|
}
|
||||||
changeHoveredGroup(null);
|
changeHoveredGroup(null);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -34,7 +34,7 @@ const CourseContainer = styled.div`
|
|||||||
background-color: #f2f4f7;
|
background-color: #f2f4f7;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
scroll-snap-align: end;
|
/* scroll-snap-align: end; */
|
||||||
:hover {
|
:hover {
|
||||||
background-color: #eceef4;
|
background-color: #eceef4;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -5,12 +5,11 @@ import Popover from '@material-ui/core/Popover';
|
|||||||
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
|
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
|
||||||
import { MONDAY_TO_FRIDAY } from '../constants';
|
import { MONDAY_TO_FRIDAY } from '../constants';
|
||||||
import { coursesContext } from '../contexts/CoursesProvider';
|
import { coursesContext } from '../contexts/CoursesProvider';
|
||||||
import { group } from 'console';
|
import { ClickAwayListener, Popper } from '@material-ui/core';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) =>
|
const useStyles = makeStyles((theme: Theme) =>
|
||||||
createStyles({
|
createStyles({
|
||||||
popover: {
|
popover: {
|
||||||
pointerEvents: 'none',
|
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
},
|
},
|
||||||
paper: {
|
paper: {
|
||||||
@ -56,7 +55,7 @@ const StyledSchedulerEvent = styled.div<SchedulerEventProps>`
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
z-index: 2;
|
z-index: 20000;
|
||||||
font-size: 0.65vw;
|
font-size: 0.65vw;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
@ -129,28 +128,30 @@ const getGroupsPerDay = (groups: Array<SchedulerEvent>) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }: SchedulerRowProps) => {
|
export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }: SchedulerRowProps) => {
|
||||||
const { hoveredGroup, selectBasketNames } = useContext(coursesContext)!;
|
const { hoveredGroup } = useContext(coursesContext)!;
|
||||||
console.log('hovered group is: ', hoveredGroup);
|
|
||||||
console.log('groups: ', groups);
|
|
||||||
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
|
|
||||||
console.log('basket names: ', basketNames);
|
|
||||||
console.log('groups: ', groups);
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const groupsPerDay = getGroupsPerDay(groups);
|
const groupsPerDay = getGroupsPerDay(groups);
|
||||||
const [anchorEl, setAnchorEl] = React.useState<HTMLDivElement | null>(null);
|
const [anchorEl, setAnchorEl] = React.useState<HTMLDivElement | null>(null);
|
||||||
const [popoverId, setPopoverId] = useState<string | null>(null);
|
const [popoverId, setPopoverId] = useState<string | null>(null);
|
||||||
//looks weird
|
//looks weird
|
||||||
const handlePopoverOpen = (event: MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => {
|
const handlePopoverOpen = (event: MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => {
|
||||||
|
console.log('I was clicked!!!!');
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
setPopoverId(event.currentTarget.id);
|
setPopoverId(event.currentTarget.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePopoverClose = () => {
|
const handlePopoverClose = (e: MouseEvent<any>) => {
|
||||||
setAnchorEl(null);
|
console.log('current target:', e.currentTarget);
|
||||||
|
console.log(' target:', e.target);
|
||||||
setPopoverId(null);
|
setPopoverId(null);
|
||||||
|
setAnchorEl(null);
|
||||||
|
console.log('click awayyy');
|
||||||
};
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
console.log('anchorEl: ', anchorEl);
|
||||||
|
}, [anchorEl]);
|
||||||
const open = Boolean(anchorEl);
|
const open = Boolean(anchorEl);
|
||||||
|
const id = open ? 'simple-popover' : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -168,6 +169,7 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
|
|||||||
group.day === eventIndex && (
|
group.day === eventIndex && (
|
||||||
<Fragment key={index}>
|
<Fragment key={index}>
|
||||||
<StyledSchedulerEvent
|
<StyledSchedulerEvent
|
||||||
|
aria-describedby={id}
|
||||||
isHovered={group.id === hoveredGroup?.id}
|
isHovered={group.id === hoveredGroup?.id}
|
||||||
groupType={group.type}
|
groupType={group.type}
|
||||||
cellWidth={cellWidth}
|
cellWidth={cellWidth}
|
||||||
@ -176,8 +178,7 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
|
|||||||
key={index}
|
key={index}
|
||||||
aria-owns={open ? `mouse-over-popover` : undefined}
|
aria-owns={open ? `mouse-over-popover` : undefined}
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
onMouseEnter={(e) => handlePopoverOpen(e)}
|
onClick={(e) => handlePopoverOpen(e)}
|
||||||
onMouseLeave={handlePopoverClose}
|
|
||||||
>
|
>
|
||||||
<ClassWrap>
|
<ClassWrap>
|
||||||
<BoldParagraph isThree={groupsPerDay[group.day] >= 3}>{groups[index].name}</BoldParagraph>
|
<BoldParagraph isThree={groupsPerDay[group.day] >= 3}>{groups[index].name}</BoldParagraph>
|
||||||
@ -194,7 +195,7 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
|
|||||||
</ClassWrap>
|
</ClassWrap>
|
||||||
</StyledSchedulerEvent>
|
</StyledSchedulerEvent>
|
||||||
<Popover
|
<Popover
|
||||||
id={`mouse-over-popover`}
|
id={id}
|
||||||
className={classes.popover}
|
className={classes.popover}
|
||||||
classes={{
|
classes={{
|
||||||
paper: classes.paper,
|
paper: classes.paper,
|
||||||
@ -212,7 +213,12 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
|
|||||||
onClose={handlePopoverClose}
|
onClose={handlePopoverClose}
|
||||||
disableRestoreFocus
|
disableRestoreFocus
|
||||||
>
|
>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
<div
|
||||||
|
style={{ display: 'flex', flexDirection: 'column', zIndex: 20000 }}
|
||||||
|
onClick={() => {
|
||||||
|
console.log('XDD');
|
||||||
|
}}
|
||||||
|
>
|
||||||
<p style={{ margin: '7px 0 7px 0', fontWeight: 'bold' }}>{groups[index].name}</p>
|
<p style={{ margin: '7px 0 7px 0', fontWeight: 'bold' }}>{groups[index].name}</p>
|
||||||
<p style={{ margin: '2px 0 2px 0' }}>
|
<p style={{ margin: '2px 0 2px 0' }}>
|
||||||
<PopoverSpan>Prowadzący:</PopoverSpan> {groups[index].lecturer}
|
<PopoverSpan>Prowadzący:</PopoverSpan> {groups[index].lecturer}
|
||||||
|
95
src/components/SelectMenu.tsx
Normal file
95
src/components/SelectMenu.tsx
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
import { ClickAwayListener } from '@material-ui/core';
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { ExpandIcon } from './CourseCard';
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
width: 10%;
|
||||||
|
margin-top: 15px;
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
background-color: #f1f2f5;
|
||||||
|
color: black;
|
||||||
|
border-top-left-radius: 6px;
|
||||||
|
border-bottom-left-radius: 6px;
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
padding-left: 15px;
|
||||||
|
cursor: pointer;
|
||||||
|
border-top-left-radius: 6px;
|
||||||
|
border-bottom-left-radius: 6px;
|
||||||
|
user-select: none;
|
||||||
|
`;
|
||||||
|
const Header = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
`;
|
||||||
|
const HeaderTitle = styled.div`
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 400;
|
||||||
|
`;
|
||||||
|
const List = styled.ul`
|
||||||
|
list-style-type: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #f2f4f7;
|
||||||
|
`;
|
||||||
|
const ListItem = styled.li`
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
font-size: 16px;
|
||||||
|
user-select: none;
|
||||||
|
font-weight: 400;
|
||||||
|
:hover {
|
||||||
|
background-color: #eceef4;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const ExpandIconSelect = styled(ExpandIcon)`
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
`;
|
||||||
|
export const SelectMenu = () => {
|
||||||
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
const [selectedOption, setSelectedOption] = useState('przedmioty');
|
||||||
|
return (
|
||||||
|
<ClickAwayListener
|
||||||
|
onClickAway={() => {
|
||||||
|
setIsOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Wrapper>
|
||||||
|
<Header
|
||||||
|
onClick={() => {
|
||||||
|
console.log('clicked');
|
||||||
|
setIsOpen(!isOpen);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<HeaderTitle>{selectedOption}</HeaderTitle>
|
||||||
|
<ExpandIconSelect selected={isOpen} />
|
||||||
|
</Header>
|
||||||
|
{isOpen && (
|
||||||
|
<List>
|
||||||
|
<ListItem
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedOption('przedmioty');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
przedmioty
|
||||||
|
</ListItem>
|
||||||
|
<ListItem
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedOption('studenci');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
studenci
|
||||||
|
</ListItem>
|
||||||
|
</List>
|
||||||
|
)}
|
||||||
|
</Wrapper>
|
||||||
|
</ClickAwayListener>
|
||||||
|
);
|
||||||
|
};
|
@ -7,6 +7,7 @@ import PolishIcon from '../assets/poland.svg';
|
|||||||
import EnglishIcon from '../assets/united-kingdom.svg';
|
import EnglishIcon from '../assets/united-kingdom.svg';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import ClickAwayListener from 'react-click-away-listener';
|
import ClickAwayListener from 'react-click-away-listener';
|
||||||
|
import { SelectMenu } from './SelectMenu';
|
||||||
|
|
||||||
const Topbar = styled.div`
|
const Topbar = styled.div`
|
||||||
background-color: #e3e5ed;
|
background-color: #e3e5ed;
|
||||||
@ -51,11 +52,12 @@ const FlexboxColumn = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const InputWrapper = styled.div`
|
const InputWrapper = styled.div`
|
||||||
|
width: 95%;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
|
max-height: 40px;
|
||||||
background-color: #f2f4f7;
|
background-color: #f2f4f7;
|
||||||
border-radius: 6px;
|
border-radius: 0 6px 6px 0;
|
||||||
align-items: center;
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
@ -91,17 +93,17 @@ const Input = styled.input`
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
background-color: #f1f2f5;
|
background-color: #f1f2f5;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
|
max-height: 40px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: none;
|
border: none;
|
||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
border-top-left-radius: 6px;
|
|
||||||
border-bottom-left-radius: 6px;
|
|
||||||
&:focus {
|
&:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const CloseIcon = styled(Close)`
|
const CloseIcon = styled(Close)`
|
||||||
|
align-self: center;
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
@ -130,6 +132,10 @@ const Icon = styled.img`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const Flexbox = styled.div`
|
||||||
|
display: flex;
|
||||||
|
`;
|
||||||
|
|
||||||
interface TopbarProps {
|
interface TopbarProps {
|
||||||
handleTransfer: (e: MouseEvent) => void;
|
handleTransfer: (e: MouseEvent) => void;
|
||||||
}
|
}
|
||||||
@ -173,13 +179,16 @@ export default function ({ handleTransfer }: TopbarProps) {
|
|||||||
</LogoWrapper>
|
</LogoWrapper>
|
||||||
<FlexboxColumn>
|
<FlexboxColumn>
|
||||||
<ClickAwayListener onClickAway={handleCloseDropdown}>
|
<ClickAwayListener onClickAway={handleCloseDropdown}>
|
||||||
|
<Flexbox>
|
||||||
|
<SelectMenu />
|
||||||
|
|
||||||
<InputWrapper>
|
<InputWrapper>
|
||||||
<SelectSearch value={value} onChange={Change}>
|
{/* <SelectSearch value={value} onChange={Change}>
|
||||||
<SelectOption value="przedmiot">Przedmiot</SelectOption>
|
<SelectOption value="przedmiot">Przedmiot</SelectOption>
|
||||||
<SelectOption value="student">Student</SelectOption>
|
<SelectOption value="student">Student</SelectOption>
|
||||||
</SelectSearch>
|
</SelectSearch> */}
|
||||||
<Input
|
<Input
|
||||||
placeholder={`Wyszukaj ${value}...`}
|
placeholder={`Wyszukaj...`}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
value={input}
|
value={input}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
@ -188,6 +197,7 @@ export default function ({ handleTransfer }: TopbarProps) {
|
|||||||
/>
|
/>
|
||||||
<CloseIcon onClick={handleClearInput} />
|
<CloseIcon onClick={handleClearInput} />
|
||||||
</InputWrapper>
|
</InputWrapper>
|
||||||
|
</Flexbox>
|
||||||
<Dropdown open={open} input={input} handleCloseDropdown={handleCloseDropdown} />
|
<Dropdown open={open} input={input} handleCloseDropdown={handleCloseDropdown} />
|
||||||
</ClickAwayListener>
|
</ClickAwayListener>
|
||||||
</FlexboxColumn>
|
</FlexboxColumn>
|
||||||
|
@ -7,7 +7,9 @@ import CloseIcon from '@material-ui/icons/Close';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const StyledCloseIcon = styled(CloseIcon)`
|
const StyledCloseIcon = styled(CloseIcon)`
|
||||||
|
color: #000000;
|
||||||
&:hover {
|
&:hover {
|
||||||
|
color: white;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
@ -25,7 +27,7 @@ interface CourseContext {
|
|||||||
selectSchedulerEvents: () => Array<SchedulerEvent>;
|
selectSchedulerEvents: () => Array<SchedulerEvent>;
|
||||||
selectBasketNames: () => Array<string>;
|
selectBasketNames: () => Array<string>;
|
||||||
selectBasketCourses: () => Array<Course>;
|
selectBasketCourses: () => Array<Course>;
|
||||||
selectBasketCourseGroups: (courseId: number) => Array<Group | undefined>;
|
selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined };
|
||||||
}
|
}
|
||||||
export const coursesContext = createContext<CourseContext | undefined>(undefined);
|
export const coursesContext = createContext<CourseContext | undefined>(undefined);
|
||||||
|
|
||||||
@ -41,9 +43,6 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
const [courses, setCourses] = useState<Array<Course>>([]);
|
const [courses, setCourses] = useState<Array<Course>>([]);
|
||||||
const [basket, setBasket] = useState<Array<Basket>>([]);
|
const [basket, setBasket] = useState<Array<Basket>>([]);
|
||||||
const [hoveredGroup, setHoveredGroup] = useState<Group | undefined | null>(null);
|
const [hoveredGroup, setHoveredGroup] = useState<Group | undefined | null>(null);
|
||||||
useEffect(() => {
|
|
||||||
console.log('actually hovered group is: ', hoveredGroup);
|
|
||||||
}, [hoveredGroup]);
|
|
||||||
const selectBasketIds = () => {
|
const selectBasketIds = () => {
|
||||||
const classesIds = basket.map((course) => course?.classes?.id).filter((course) => course !== undefined);
|
const classesIds = basket.map((course) => course?.classes?.id).filter((course) => course !== undefined);
|
||||||
const lecturesIds = basket.map((course) => course?.lecture?.id).filter((course) => course !== undefined);
|
const lecturesIds = basket.map((course) => course?.lecture?.id).filter((course) => course !== undefined);
|
||||||
@ -78,9 +77,9 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
const selectBasketCourseGroups = (courseId: number) => {
|
const selectBasketCourseGroups = (courseId: number) => {
|
||||||
const course = basket.find(({ id }) => id === courseId);
|
const course = basket.find(({ id }) => id === courseId);
|
||||||
if (course !== undefined) {
|
if (course !== undefined) {
|
||||||
return [course.lecture, course.classes];
|
return { lecture: course.lecture, classes: course.classes };
|
||||||
} else {
|
} else {
|
||||||
return [undefined, undefined];
|
return { lecture: undefined, classes: undefined };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,7 +171,6 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
`${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`,
|
`${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`,
|
||||||
);
|
);
|
||||||
const sortedCourses = courses.sort((a, b) => (a.name > b.name ? 1 : -1));
|
const sortedCourses = courses.sort((a, b) => (a.name > b.name ? 1 : -1));
|
||||||
console.log('courses: ', courses);
|
|
||||||
setCourses(sortedCourses);
|
setCourses(sortedCourses);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
Loading…
Reference in New Issue
Block a user