) => {
}
};
-export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
- const { selectGroups } = useContext(coursesContext)!;
+export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
+ const { basket } = useContext(coursesContext)!;
const classes = useStyles();
- const groups = selectGroups();
+ // const groups = selectGroups();
const [input, setInput] = useState('');
const [open, setOpen] = useState(false);
@@ -133,29 +134,39 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
const handleCloseDropdown = () => setOpen(false);
useEffect(() => {
const getExchanges = async () => {
- const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
- console.log('exchanges: ', data);
- setExchanges(data);
+ try {
+ const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
+ console.log('exchanges: ', data);
+ setExchanges(data);
+ } catch (e) {
+ console.log(e);
+ }
};
const getAssignmentsGroups = async () => {
- const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`);
- console.log('assignments: ', data);
- setAssignmentsGroups(data);
+ try {
+ const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`);
+ 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();
getAssignmentsGroups();
- }, []);
+ }, [isTransferOpen]);
return (
-
+
Oddam
@@ -172,7 +183,7 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
{assignmentsGroups.map((el) => {
return (
);
})}
@@ -183,12 +194,11 @@ export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
PrzyjmÄ™
- {/* */}
-
+ {/* {
handleShowDropdown();
}}
- />
+ /> */}
Array;
selectBasketNames: () => Array;
selectBasketCourses: () => Array;
- selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined };
+ selectBasketCourseGroups: (courseName: string) => { lecture: Group | undefined; classes: Group | undefined };
selectGroups: () => Array;
getNewestStudentTimetable: (studentId: string) => void;
getStudentTimetablesHistory: (studentId: string) => void;
@@ -100,8 +100,8 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
}, [] as Array);
};
- const selectBasketCourseGroups = (courseId: number) => {
- const course = basket.find(({ id }) => id === courseId);
+ const selectBasketCourseGroups = (courseName: string) => {
+ const course = basket.find(({ name }) => name === courseName);
if (course !== undefined) {
return { lecture: course.lecture, classes: course.classes };
} else {