Skip to content

Commit

Permalink
Bug fix: conference picker all selection
Browse files Browse the repository at this point in the history
  • Loading branch information
esmalleydev committed Mar 14, 2024
1 parent 8e3f228 commit fbeb7ac
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
28 changes: 16 additions & 12 deletions components/generic/CBB/ConferencePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ConferencePicker = () => {
const [confOpen, setConfOpen] = useState(false);

const conferenceOptions = [
{'value': 'all', 'label': 'All'},
{'value': null, 'label': 'All'},
{'value': 'ACC', 'label': 'ACC'},
{'value': 'Big 12', 'label': 'Big 12'},
{'value': 'SEC', 'label': 'SEC'},
Expand Down Expand Up @@ -111,17 +111,21 @@ const ConferencePicker = () => {
</Toolbar>
</AppBar>
<List>
{conferenceOptions.map((confOption) => (
<ListItem key={confOption.value} button onClick={() => {
dispatch(updateConferences(confOption.value));
handleConfClose();
}}>
<ListItemIcon>
{selected.indexOf(confOption.value) > -1 ? <CheckIcon /> : ''}
</ListItemIcon>
<ListItemText primary={confOption.label} />
</ListItem>
))}
{conferenceOptions.map((confOption) => {
const value = confOption.value;

return (
<ListItem key={value} button onClick={() => {
dispatch(updateConferences(value));
handleConfClose();
}}>
<ListItemIcon>
{value && selected.indexOf(value) > -1 ? <CheckIcon /> : ''}
</ListItemIcon>
<ListItemText primary={confOption.label} />
</ListItem>
)
})}
</List>
</Dialog>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/generic/CBB/Picks/Stats/Client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const Client = ({ date, stats }) => {
totalGames === 0 ? <Typography sx = {Object.assign({'textAlign': 'center'}, colorStyle)} variant="h5" component="div">-</Typography> :
<>
<div style = {{'display': 'flex', 'justifyContent': 'space-between'}}>
<Typography sx={{ fontSize: 12, minWidth: 60 }} color="text.secondary" gutterBottom>Predicted</Typography>
<Typography sx={{ fontSize: 12, minWidth: 60 }} color="text.secondary" gutterBottom>Predicted win %</Typography>
<Typography sx={{ fontSize: 12, minWidth: 60, textAlign: 'center' }} color="text.secondary" gutterBottom>Accuracy</Typography>
<Typography sx={{ fontSize: 12, minWidth: 60, textAlign: 'right' }} color="text.secondary" gutterBottom># games</Typography>
</div>
Expand Down
20 changes: 12 additions & 8 deletions redux/features/display-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,19 @@ export const display = createSlice({
}
state.picksSort = action.payload;
},
updateConferences: (state, action: PayloadAction<string>) => {
const index = state.conferences.indexOf(action.payload);
if (index !== -1) {
state.conferences = [
...state.conferences.slice(0, index),
...state.conferences.slice(index + 1)
];
updateConferences: (state, action: PayloadAction<string | null>) => {
if (action.payload) {
const index = state.conferences.indexOf(action.payload);
if (index !== -1) {
state.conferences = [
...state.conferences.slice(0, index),
...state.conferences.slice(index + 1)
];
} else {
state.conferences = [...state.conferences, action.payload];
}
} else {
state.conferences = [...state.conferences, action.payload];
state.conferences = [];
}

if (typeof window !== 'undefined') {
Expand Down

0 comments on commit fbeb7ac

Please sign in to comment.