transfer c.d
This commit is contained in:
parent
6748309fbd
commit
135deb56c6
@ -188,12 +188,12 @@ export const Administrator = () => {
|
|||||||
formData,
|
formData,
|
||||||
config,
|
config,
|
||||||
);
|
);
|
||||||
enqueueSnackbar('Plan został zapisany', {
|
enqueueSnackbar('Ustawienia zostały zapisane', {
|
||||||
variant: 'success',
|
variant: 'success',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
enqueueSnackbar('Zapisywanie planu nie powiodło się', {
|
enqueueSnackbar('Ustawienia nie zostały zapisane', {
|
||||||
variant: 'error',
|
variant: 'error',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
|
@ -146,7 +146,7 @@ const Icon = styled.img`
|
|||||||
const Exchange = styled.div`
|
const Exchange = styled.div`
|
||||||
background-color: #b5d2e0;
|
background-color: #b5d2e0;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
width: 300px;
|
width: 280px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -180,8 +180,7 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
const [save, setSave] = useState(false);
|
const [save, setSave] = useState(false);
|
||||||
// const allGroups
|
// const allGroups
|
||||||
const handleSelectedAssignmentsGroupChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
const handleSelectedAssignmentsGroupChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
||||||
console.log('it is: ', event.target.value);
|
setSelectedAssignmentsClasses(1);
|
||||||
setSelectedAssignmentsClasses(event.target.value);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGroupsChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
const handleGroupsChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
||||||
@ -192,17 +191,24 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
|
|
||||||
const handleCloseDropdown = () => setOpen(false);
|
const handleCloseDropdown = () => setOpen(false);
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
console.log("ASAJNMENTS",selectedAssignmentsClasses)
|
||||||
|
},[selectedAssignmentsClasses])
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(()=>{
|
||||||
|
console.log("SELEKTET GTUP",selectedGroup)
|
||||||
|
},[selectedGroup])
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (selectedAssignmentsClasses) {
|
if (selectedAssignmentsClasses) {
|
||||||
const allGroups = basketCourses.filter((el) => el.name === selectedAssignmentsClasses.name);
|
const allGroups = basketCourses.filter((el) => el.name === selectedAssignmentsClasses.name);
|
||||||
const allClasses = allGroups[0]?.classes;
|
const allClasses = allGroups[0]?.classes;
|
||||||
console.log('allgroups: ', allGroups);
|
|
||||||
console.log('allclasses: ', allClasses);
|
|
||||||
if (allClasses) {
|
if (allClasses) {
|
||||||
const filteredClasses = allClasses.filter((el: any) => {
|
const filteredClasses = allClasses.filter((el: any) => {
|
||||||
return el.time !== selectedAssignmentsClasses.time;
|
return el.time !== selectedAssignmentsClasses.time;
|
||||||
});
|
});
|
||||||
console.log('filtered classes: ', filteredClasses);
|
|
||||||
setGroups(filteredClasses);
|
setGroups(filteredClasses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,9 +218,7 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
const getExchanges = async () => {
|
const getExchanges = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
|
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
|
||||||
console.log('exchanges: ', data);
|
|
||||||
setExchanges(data);
|
setExchanges(data);
|
||||||
console.log('123', exchanges);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
@ -223,26 +227,22 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
const getAssignmentsGroups = async () => {
|
const getAssignmentsGroups = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`);
|
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');
|
const classes = data.filter((el: any) => el.type === 'CLASS');
|
||||||
setAssignmentsClasses(classes);
|
setAssignmentsClasses(classes);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
console.log('open changed');
|
|
||||||
getExchanges();
|
getExchanges();
|
||||||
getAssignmentsGroups();
|
getAssignmentsGroups();
|
||||||
}, [isTransferOpen, save]);
|
}, [isTransferOpen, save]);
|
||||||
|
|
||||||
const createExchange = async (groupsIds: Array<number>) => {
|
const createExchange = async (groupsIds: Array<number>) => {
|
||||||
console.log('groups ids are: ', groupsIds);
|
|
||||||
try {
|
try {
|
||||||
const response = await axiosInstance.post(
|
const response = await axiosInstance.post(
|
||||||
`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange`,
|
`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange`,
|
||||||
JSON.stringify({ assignment: groupsIds[0], group: groupsIds[1] }),
|
JSON.stringify({ assignment: groupsIds[0], group: groupsIds[1] }),
|
||||||
);
|
);
|
||||||
console.log('create exchange response is: ', response);
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
@ -308,7 +308,7 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
<TransferReceiveStyled>
|
<TransferReceiveStyled>
|
||||||
<TransferTextStyled>Przyjmę</TransferTextStyled>
|
<TransferTextStyled>Przyjmę</TransferTextStyled>
|
||||||
<TransferInputStyled>
|
<TransferInputStyled>
|
||||||
<FormControl disabled>
|
<FormControl disabled={selectedAssignmentsClasses ? false : true}>
|
||||||
<Select
|
<Select
|
||||||
labelId="demo-simple-select-label"
|
labelId="demo-simple-select-label"
|
||||||
id="assignments-groups"
|
id="assignments-groups"
|
||||||
@ -345,14 +345,16 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
{exchanges ? (
|
{exchanges ? (
|
||||||
exchanges.map((name: any) => (
|
exchanges.map((name: any) => (
|
||||||
<ExchangesRow>
|
<ExchangesRow>
|
||||||
|
{' '}
|
||||||
|
<Exchange>
|
||||||
|
{name.ownedAssignment.lecturer} <br></br> {dayMapping[name.ownedAssignment.day]} <br></br>{' '}
|
||||||
|
{name.ownedAssignment.time} - {name.ownedAssignment.endTime}
|
||||||
|
</Exchange>
|
||||||
|
<Icon alt="transfer" src={TransferIcon} />
|
||||||
<Exchange>
|
<Exchange>
|
||||||
{name.desiredGroup.lecturer} <br></br> {dayMapping[name.desiredGroup.day]} <br></br>{' '}
|
{name.desiredGroup.lecturer} <br></br> {dayMapping[name.desiredGroup.day]} <br></br>{' '}
|
||||||
{name.desiredGroup.time} - {name.desiredGroup.endTime}
|
{name.desiredGroup.time} - {name.desiredGroup.endTime}
|
||||||
</Exchange>{' '}
|
</Exchange>{' '}
|
||||||
<Icon alt="transfer" src={TransferIcon} />
|
|
||||||
<Exchange>
|
|
||||||
{name.ownedAssignment.lecturer} <br></br> {dayMapping[name.ownedAssignment.day]} <br></br>{' '}
|
|
||||||
{name.ownedAssignment.time} - {name.ownedAssignment.endTime}</Exchange>
|
|
||||||
</ExchangesRow>
|
</ExchangesRow>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
|
@ -156,13 +156,13 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/${userID}`,
|
`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/${userID}`,
|
||||||
JSON.stringify(basketIds),
|
JSON.stringify(basketIds),
|
||||||
);
|
);
|
||||||
enqueueSnackbar('Ustawienia zostały zapisane', {
|
enqueueSnackbar('Plan został zapisany', {
|
||||||
variant: 'success',
|
variant: 'success',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('error: ', e);
|
console.log('error: ', e);
|
||||||
enqueueSnackbar('Ustawienia nie zostały zapisane', {
|
enqueueSnackbar('Zapisywanie planu nie powiodło się', {
|
||||||
variant: 'error',
|
variant: 'error',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user