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