Commit 054ef35c authored by Imane Misrar's avatar Imane Misrar
Browse files

feat(PreviousExchangesTab): reset filters if no exchange corresponds to the search

Relates to #176
parent b0e3ead6
......@@ -19,6 +19,7 @@ import withNetworkWrapper, {
import Switch from "@material-ui/core/Switch";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Grid from "@material-ui/core/Grid";
const undefinedVal = uuid();
......@@ -54,6 +55,12 @@ function PreviousExchangesTab({
if (displayMinorSelect)
minors = univMajorMinors.find(el => el.major === major).minors;
if (exchanges.number_elements === 0) {
setMajor(undefinedVal);
setMinor(undefinedVal);
setShowUntouched(true);
}
return (
<>
<form autoComplete="off" className={classes.root}>
......@@ -107,24 +114,26 @@ function PreviousExchangesTab({
</FormControl>
</>
)}
<FormControlLabel
control={
<Switch
checked={showUntouched}
onChange={() => {
setShowUntouched(!showUntouched);
goToPage(1);
}}
color="primary"
/>
}
label={
showUntouched === true
? "Afficher tous les échanges."
: "Afficher que les départs avec retours."
}
/>
<Typography component="div">
<Grid component="label" container alignItems="center" spacing={0}>
<Grid item>Départs avec retour&emsp;</Grid>
<Grid item>
<FormControlLabel
control={
<Switch
checked={showUntouched}
onChange={() => {
setShowUntouched(!showUntouched);
goToPage(1);
}}
color="primary"
/>
}
/>
</Grid>
<Grid item>Tous les échanges</Grid>
</Grid>
</Typography>
</form>
<PaginatedData
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment