@@ -40,6 +40,7 @@ import { showTrophyIcon } from '../../utils/anniversaryPermissions';
4040import SelectTeamPieChart from './SelectTeamPieChart' ;
4141import { setTeamCodes } from '../../actions/teamCodes' ;
4242import styles from './WeeklySummariesReport.module.css' ;
43+ import Select , { components } from 'react-select' ;
4344
4445const navItems = [ 'This Week' , 'Last Week' , 'Week Before Last' , 'Three Weeks Ago' ] ;
4546const fullCodeRegex = / ^ .{ 5 , 7 } $ / ;
@@ -105,6 +106,60 @@ const intialPermissionState = {
105106 codeEditPermission : false ,
106107 canSeeBioHighlight : false ,
107108} ;
109+
110+ const CheckboxOption = props => {
111+ return (
112+ < components . Option { ...props } >
113+ < input
114+ type = "checkbox"
115+ checked = { props . isSelected }
116+ onChange = { ( ) => null } // react-select handles selection
117+ style = { { marginRight : 8 } }
118+ />
119+ < label style = { { fontWeight : 'bold' } } > { props . label } </ label >
120+ </ components . Option >
121+ ) ;
122+ } ;
123+
124+ const CustomMenuList = props => {
125+ const {
126+ children,
127+ selectProps, // gives access to props like value and options
128+ } = props ;
129+
130+ const allSelected = selectProps . value ?. length === selectProps . options . length ;
131+
132+ const toggleSelectAll = ( ) => {
133+ if ( allSelected ) {
134+ selectProps . onChange ( [ ] ) ;
135+ } else {
136+ selectProps . onChange ( selectProps . options ) ;
137+ }
138+ } ;
139+
140+ return (
141+ < components . MenuList { ...props } >
142+ < div
143+ style = { {
144+ padding : '6px 10px' ,
145+ borderBottom : '1px solid #ccc' ,
146+ display : 'flex' ,
147+ alignItems : 'center' ,
148+ } }
149+ >
150+ < input
151+ type = "checkbox"
152+ checked = { allSelected }
153+ onChange = { toggleSelectAll }
154+ style = { { marginRight : 8 } }
155+ />
156+ < label style = { { fontWeight : 'bold' } } > { allSelected ? 'Deselect All' : 'Select All' } </ label >
157+ </ div >
158+ { children }
159+ </ components . MenuList >
160+ ) ;
161+ } ;
162+
108163/* eslint-disable react/function-component-definition */
109164const WeeklySummariesReport = props => {
110165 const { loading, infoCollections, getInfoCollections } = props ;
@@ -1269,10 +1324,12 @@ const WeeklySummariesReport = props => {
12691324 </ ReactTooltip >
12701325 </ >
12711326 ) }
1272- < MultiSelect
1273- className = { `multi-select-filter text-dark ${ darkMode ? 'dark-mode' : '' } ${
1274- state . teamCodeWarningUsers . length > 0 ? 'warning-border' : ''
1275- } `}
1327+ < Select
1328+ isMulti
1329+ isSearchable
1330+ closeMenuOnSelect = { false }
1331+ hideSelectedOptions = { false }
1332+ blurInputOnSelect = { false }
12761333 options = { state . teamCodes . map ( item => {
12771334 const [ code , count ] = item . label . split ( ' (' ) ;
12781335 return {
@@ -1282,16 +1339,59 @@ const WeeklySummariesReport = props => {
12821339 } ) }
12831340 value = { state . selectedCodes }
12841341 onChange = { handleSelectCodeChange }
1285- labelledBy = "Select"
1342+ components = { {
1343+ Option : CheckboxOption ,
1344+ MenuList : CustomMenuList ,
1345+ } }
1346+ placeholder = "Search and select team codes..."
1347+ classNamePrefix = "custom-select"
1348+ className = { `custom-select-container ${ darkMode ? 'dark-mode' : '' } ${
1349+ state . teamCodeWarningUsers . length > 0 ? 'warning-border' : ''
1350+ } `}
1351+ styles = { {
1352+ menuList : base => ( {
1353+ ...base ,
1354+ maxHeight : '700px' ,
1355+ overflowY : 'auto' ,
1356+ } ) ,
1357+ option : ( base , state ) => ( {
1358+ ...base ,
1359+ fontSize : '13px' ,
1360+ backgroundColor : state . isFocused ? '#eee' : 'white' ,
1361+ } ) ,
1362+ } }
12861363 />
12871364 </ Col >
12881365
12891366 < Col lg = { { size : 5 } } md = { { size : 6 , offset : - 1 } } xs = { { size : 6 , offset : - 1 } } >
1290- < MultiSelect
1291- className = { `multi-select-filter text-dark ${ darkMode ? 'dark-mode' : '' } ` }
1367+ < Select
1368+ isMulti
1369+ isSearchable
1370+ closeMenuOnSelect = { false }
1371+ hideSelectedOptions = { false }
1372+ blurInputOnSelect = { false }
12921373 options = { state . colorOptions }
12931374 value = { state . selectedColors }
12941375 onChange = { handleSelectColorChange }
1376+ components = { {
1377+ Option : CheckboxOption ,
1378+ MenuList : CustomMenuList ,
1379+ } }
1380+ placeholder = "Select color filters..."
1381+ classNamePrefix = "custom-select"
1382+ className = { `multi-select-filter text-dark ${ darkMode ? 'dark-mode' : '' } ` }
1383+ styles = { {
1384+ menuList : base => ( {
1385+ ...base ,
1386+ maxHeight : '700px' ,
1387+ overflowY : 'auto' ,
1388+ } ) ,
1389+ option : ( base , state ) => ( {
1390+ ...base ,
1391+ fontSize : '13px' ,
1392+ backgroundColor : state . isFocused ? '#eee' : 'white' ,
1393+ } ) ,
1394+ } }
12951395 />
12961396 </ Col >
12971397 </ Row >
0 commit comments