changes
This commit is contained in:
parent
8b563d3e70
commit
df1d26f653
@ -35,23 +35,21 @@ export const App = () => {
|
|||||||
<>
|
<>
|
||||||
<LoadingOverlay active={role === undefined} spinner={<SyncLoader />}>
|
<LoadingOverlay active={role === undefined} spinner={<SyncLoader />}>
|
||||||
{userPrivilige !== 'ADMIN' && (
|
{userPrivilige !== 'ADMIN' && (
|
||||||
<>
|
<>
|
||||||
<Topbar handleTransfer={handleTransfer} />
|
<Topbar handleTransfer={handleTransfer} />
|
||||||
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
|
<Transfer isTransferOpen={isOpenTransfer} handleClose={handleTransfer} />
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
{userPrivilige === 'STUDENT' && (
|
{userPrivilige === 'STUDENT' && (
|
||||||
<>
|
<>
|
||||||
<Scheduler schedulerEvents={schedulerEvents} />
|
<Scheduler schedulerEvents={schedulerEvents} />
|
||||||
<Rightbar />
|
<Rightbar />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{userPrivilige === 'DEANERY' && <Deanery schedulerEvents={schedulerEvents} />}
|
{userPrivilige === 'DEANERY' && <Deanery schedulerEvents={schedulerEvents} />}
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
</>
|
</>
|
||||||
)}
|
|
||||||
{userPrivilige === 'ADMIN' && (
|
|
||||||
<Administrator></Administrator>
|
|
||||||
)}
|
)}
|
||||||
|
{userPrivilige === 'ADMIN' && <Administrator></Administrator>}
|
||||||
</LoadingOverlay>
|
</LoadingOverlay>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -158,7 +158,7 @@ export const CourseCard = ({ course }: CourseCardProps) => {
|
|||||||
} = useContext(coursesContext)!;
|
} = useContext(coursesContext)!;
|
||||||
const [isSelected, setSelected] = useState(true);
|
const [isSelected, setSelected] = useState(true);
|
||||||
const groups = [...course.lectures!, ...course.classes!];
|
const groups = [...course.lectures!, ...course.classes!];
|
||||||
const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.id), []);
|
const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []);
|
||||||
const [previous, setPrevious] = useState(basketCourseGroups);
|
const [previous, setPrevious] = useState(basketCourseGroups);
|
||||||
|
|
||||||
const onGroupClick = (group: Group, courseId: number) => {
|
const onGroupClick = (group: Group, courseId: number) => {
|
||||||
|
@ -9,10 +9,11 @@ import { Group } from '../types';
|
|||||||
import { coursesContext } from '../contexts/CoursesProvider';
|
import { coursesContext } from '../contexts/CoursesProvider';
|
||||||
import { Dropdown } from './Dropdown';
|
import { Dropdown } from './Dropdown';
|
||||||
import { DropdownModal } from './DropdownModal';
|
import { DropdownModal } from './DropdownModal';
|
||||||
|
import { dayMapping } from '../constants';
|
||||||
|
|
||||||
interface TransferProps {
|
interface TransferProps {
|
||||||
handleClose: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
handleClose: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
||||||
isOpen: boolean;
|
isTransferOpen: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
@ -107,10 +108,10 @@ const createExchange = async (groupsIds: Array<number>) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
|
export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
||||||
const { selectGroups } = useContext(coursesContext)!;
|
const { basket } = useContext(coursesContext)!;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const groups = selectGroups();
|
// const groups = selectGroups();
|
||||||
const [input, setInput] = useState('');
|
const [input, setInput] = useState('');
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
@ -133,29 +134,39 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
|
|||||||
const handleCloseDropdown = () => setOpen(false);
|
const handleCloseDropdown = () => setOpen(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const getExchanges = async () => {
|
const getExchanges = async () => {
|
||||||
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
|
try {
|
||||||
console.log('exchanges: ', data);
|
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
|
||||||
setExchanges(data);
|
console.log('exchanges: ', data);
|
||||||
|
setExchanges(data);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
const getAssignmentsGroups = async () => {
|
const getAssignmentsGroups = async () => {
|
||||||
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`);
|
try {
|
||||||
console.log('assignments: ', data);
|
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`);
|
||||||
setAssignmentsGroups(data);
|
console.log('assignments: ', data);
|
||||||
|
const classes = data.filter((el: any) => el.type === 'CLASS');
|
||||||
|
setAssignmentsGroups(classes);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
console.log('open changed');
|
||||||
getExchanges();
|
getExchanges();
|
||||||
getAssignmentsGroups();
|
getAssignmentsGroups();
|
||||||
}, []);
|
}, [isTransferOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Modal
|
<Modal
|
||||||
className={classes.wrapper}
|
className={classes.wrapper}
|
||||||
open={isOpen}
|
open={isTransferOpen}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
aria-labelledby="simple-modal-title"
|
aria-labelledby="simple-modal-title"
|
||||||
aria-describedby="simple-modal-description"
|
aria-describedby="simple-modal-description"
|
||||||
>
|
>
|
||||||
<Fade in={isOpen}>
|
<Fade in={isTransferOpen}>
|
||||||
<TransferStyled>
|
<TransferStyled>
|
||||||
<TransferGiveStyled>
|
<TransferGiveStyled>
|
||||||
<TransferTextStyled>Oddam</TransferTextStyled>
|
<TransferTextStyled>Oddam</TransferTextStyled>
|
||||||
@ -172,7 +183,7 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
|
|||||||
{assignmentsGroups.map((el) => {
|
{assignmentsGroups.map((el) => {
|
||||||
return (
|
return (
|
||||||
<MenuItem key={el.id} value={el}>
|
<MenuItem key={el.id} value={el}>
|
||||||
{el.name}
|
{`${el.name} (${dayMapping[el.day - 1]} ${el.time} ${el.endTime})`}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@ -183,12 +194,11 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
|
|||||||
<TransferReceiveStyled>
|
<TransferReceiveStyled>
|
||||||
<TransferTextStyled>Przyjmę</TransferTextStyled>
|
<TransferTextStyled>Przyjmę</TransferTextStyled>
|
||||||
<TransferInputStyled>
|
<TransferInputStyled>
|
||||||
{/* <Select
|
<Select
|
||||||
multiple
|
|
||||||
labelId="demo-simple-select-label"
|
labelId="demo-simple-select-label"
|
||||||
id="assignments-groups"
|
id="assignments-groups"
|
||||||
value={selectedGroups}
|
// value={selectedGroups}
|
||||||
onChange={handleSelectedGroupsChange}
|
// onChange={handleSelectedGroupsChange}
|
||||||
placeholder="Wyszukaj..."
|
placeholder="Wyszukaj..."
|
||||||
style={{ width: '200px' }}
|
style={{ width: '200px' }}
|
||||||
>
|
>
|
||||||
@ -199,15 +209,15 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</Select> */}
|
</Select>
|
||||||
<Input
|
{/* <Input
|
||||||
placeholder={`Wyszukaj przedmioty...`}
|
placeholder={`Wyszukaj przedmioty...`}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
value={input}
|
value={input}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
handleShowDropdown();
|
handleShowDropdown();
|
||||||
}}
|
}}
|
||||||
/>
|
/> */}
|
||||||
<DropdownModal
|
<DropdownModal
|
||||||
handleSelectedGroupChange={handleSelectedGroupChange}
|
handleSelectedGroupChange={handleSelectedGroupChange}
|
||||||
open={open}
|
open={open}
|
||||||
|
@ -32,7 +32,7 @@ interface CourseContext {
|
|||||||
selectHistorySchedulerEvents: () => Array<SchedulerEvent>;
|
selectHistorySchedulerEvents: () => Array<SchedulerEvent>;
|
||||||
selectBasketNames: () => Array<string>;
|
selectBasketNames: () => Array<string>;
|
||||||
selectBasketCourses: () => Array<Course>;
|
selectBasketCourses: () => Array<Course>;
|
||||||
selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined };
|
selectBasketCourseGroups: (courseName: string) => { lecture: Group | undefined; classes: Group | undefined };
|
||||||
selectGroups: () => Array<Group>;
|
selectGroups: () => Array<Group>;
|
||||||
getNewestStudentTimetable: (studentId: string) => void;
|
getNewestStudentTimetable: (studentId: string) => void;
|
||||||
getStudentTimetablesHistory: (studentId: string) => void;
|
getStudentTimetablesHistory: (studentId: string) => void;
|
||||||
@ -100,8 +100,8 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
}, [] as Array<SchedulerEvent>);
|
}, [] as Array<SchedulerEvent>);
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectBasketCourseGroups = (courseId: number) => {
|
const selectBasketCourseGroups = (courseName: string) => {
|
||||||
const course = basket.find(({ id }) => id === courseId);
|
const course = basket.find(({ name }) => name === courseName);
|
||||||
if (course !== undefined) {
|
if (course !== undefined) {
|
||||||
return { lecture: course.lecture, classes: course.classes };
|
return { lecture: course.lecture, classes: course.classes };
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user