-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: transfer list, conference filter now works on committed team
- Loading branch information
1 parent
e0ea988
commit 8a79df7
Showing
7 changed files
with
174 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
components/generic/CBB/Ranking/ConferenceFilterOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { useState, useTransition } from 'react'; | ||
|
||
import CloseIcon from '@mui/icons-material/Close'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogTitle from '@mui/material/DialogTitle'; | ||
import { FormControlLabel, FormGroup, IconButton, Switch } from '@mui/material'; | ||
import { useAppDispatch, useAppSelector } from '@/redux/hooks'; | ||
import { setFilterCommittedConf, setFilterOriginalConf } from '@/redux/features/ranking-slice'; | ||
import { usePathname, useRouter, useSearchParams } from 'next/navigation'; | ||
import BackdropLoader from '@/components/generic/BackdropLoader'; | ||
|
||
const ConferenceFilterOptions = ({ open, onClose }) => { | ||
const router = useRouter(); | ||
const pathName = usePathname(); | ||
const searchParams = useSearchParams(); | ||
const [isPending, startTransition] = useTransition(); | ||
const [spin, setSpin] = useState(false); | ||
|
||
const dispatch = useAppDispatch(); | ||
const filterCommittedConf = useAppSelector(state => state.rankingReducer.filterCommittedConf); | ||
const filterOriginalConf = useAppSelector(state => state.rankingReducer.filterOriginalConf); | ||
|
||
const handleOrginalConfSwitch = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const newValue: boolean = event.target.checked; | ||
setSpin(true); | ||
startTransition(() => { | ||
if (newValue !== filterOriginalConf) { | ||
const current = new URLSearchParams(Array.from(searchParams.entries())); | ||
current.set('filterOriginalConf', (+newValue).toString()); | ||
const search = current.toString(); | ||
const query = search ? `?${search}` : ""; | ||
router.replace(`${pathName}${query}`); | ||
dispatch(setFilterOriginalConf(newValue)); | ||
} | ||
setSpin(false); | ||
}); | ||
}; | ||
|
||
const handleCommittedConfSwitch = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
const newValue: boolean = event.target.checked; | ||
setSpin(true); | ||
startTransition(() => { | ||
if (newValue !== filterCommittedConf) { | ||
const current = new URLSearchParams(Array.from(searchParams.entries())); | ||
current.set('filterCommittedConf', (+newValue).toString()); | ||
const search = current.toString(); | ||
const query = search ? `?${search}` : ""; | ||
router.replace(`${pathName}${query}`); | ||
dispatch(setFilterCommittedConf(newValue)); | ||
} | ||
setSpin(false); | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Dialog | ||
open={open} | ||
onClose={onClose} | ||
> | ||
<BackdropLoader open = {spin} /> | ||
<DialogTitle id="alert-dialog-title"> | ||
{'Conference filter options'} | ||
{<IconButton aria-label="close" onClick={onClose}><CloseIcon /></IconButton>} | ||
</DialogTitle> | ||
<DialogContent> | ||
<FormGroup> | ||
<FormControlLabel control={<Switch checked = {filterOriginalConf} onChange={handleOrginalConfSwitch} />} label = 'Include Previous team' /> | ||
<FormControlLabel control={<Switch checked = {filterCommittedConf} onChange={handleCommittedConfSwitch} />} label = 'Include New team' /> | ||
</FormGroup> | ||
</DialogContent> | ||
</Dialog> | ||
</> | ||
); | ||
} | ||
|
||
export default ConferenceFilterOptions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters