@@ -7,11 +7,18 @@ import {
77 removeManager ,
88 addOwner ,
99 removeOwner ,
10- getOrgTeams ,
10+ getOrgLocations ,
1111 getOrgStaff ,
1212} from '../../../lib/org-api'
1313import { getUserOrgProfile } from '../../../lib/profiles-api'
14- import { Box , Container , Heading , Button , Flex } from '@chakra-ui/react'
14+ import {
15+ Box ,
16+ Checkbox ,
17+ Container ,
18+ Heading ,
19+ Button ,
20+ Flex ,
21+ } from '@chakra-ui/react'
1522import Table from '../../../components/tables/table'
1623import { AddMemberByIdForm } from '../../../components/add-member-form'
1724import ProfileModal from '../../../components/profile-modal'
@@ -66,6 +73,8 @@ class Organization extends Component {
6673 profileInfo : [ ] ,
6774 profileUserId : '' ,
6875 teams : [ ] ,
76+ searchOnMapMove : false ,
77+ mapBounds : undefined ,
6978 managers : [ ] ,
7079 owners : [ ] ,
7180 page : 0 ,
@@ -75,14 +84,15 @@ class Organization extends Component {
7584
7685 this . closeProfileModal = this . closeProfileModal . bind ( this )
7786 this . renderBadges = this . renderBadges . bind ( this )
87+ this . renderMap = this . renderMap . bind ( this )
7888 }
7989
8090 async componentDidMount ( ) {
8191 this . setState ( { session : await getSession ( ) } )
8292 await this . getOrg ( )
8393 await this . getOrgStaff ( )
8494 await this . getBadges ( )
85- await this . getOrgTeams ( )
95+ await this . getOrgLocations ( )
8696 }
8797
8898 async openProfileModal ( user ) {
@@ -165,10 +175,10 @@ class Organization extends Component {
165175 }
166176 }
167177
168- async getOrgTeams ( ) {
178+ async getOrgLocations ( ) {
169179 const { id } = this . props
170180 try {
171- let teams = await getOrgTeams ( id )
181+ let teams = await getOrgLocations ( id )
172182 this . setState ( {
173183 teams,
174184 } )
@@ -258,6 +268,28 @@ class Organization extends Component {
258268 ) : null
259269 }
260270
271+ /**
272+ * Bounds is a WESN box, refresh teams
273+ */
274+ onMapBoundsChange ( bounds ) {
275+ if ( this . state . searchOnMapMove ) {
276+ this . setState ( {
277+ mapBounds : bounds ,
278+ } )
279+ } else {
280+ this . setState ( { mapBounds : null } )
281+ }
282+ }
283+
284+ setSearchOnMapMove ( e ) {
285+ this . setState (
286+ {
287+ searchOnMapMove : e . target . checked ,
288+ } ,
289+ ( ) => this . getOrgLocations ( )
290+ )
291+ }
292+
261293 renderMap ( teams ) {
262294 const { data } = teams
263295
@@ -275,20 +307,41 @@ class Organization extends Component {
275307 )
276308
277309 return (
278- < Map
279- markers = { centers }
280- style = { {
281- height : '360px' ,
282- zIndex : '10' ,
283- marginBottom : '1rem' ,
284- } }
285- onBoundsChange = { ( ) => { } }
286- />
310+ < >
311+ < Map
312+ markers = { centers }
313+ style = { {
314+ height : '360px' ,
315+ zIndex : '10' ,
316+ marginBottom : '1rem' ,
317+ } }
318+ onBoundsChange = { this . onMapBoundsChange . bind ( this ) }
319+ />
320+ < Checkbox
321+ border = { '2px' }
322+ marginTop = { '-5rem' }
323+ marginLeft = { '1rem' }
324+ position = 'absolute'
325+ zIndex = '2000'
326+ borderColor = 'brand.600'
327+ p = { 2 }
328+ bg = 'white'
329+ name = 'map-bounds-filter'
330+ id = 'map-bounds-filter'
331+ type = 'checkbox'
332+ colorScheme = { 'brand' }
333+ isChecked = { this . state . searchOnMapMove }
334+ onChange = { ( e ) => this . setSearchOnMapMove ( e ) }
335+ >
336+ Filter teams by map
337+ </ Checkbox >
338+ </ >
287339 )
288340 }
289341
290342 render ( ) {
291- const { org, managers, owners, error, teams } = this . state
343+ const { org, managers, owners, error, teams, searchOnMapMove, mapBounds } =
344+ this . state
292345 const userId = parseInt ( this . state ?. session ?. user_id )
293346
294347 // Handle org loading errors
@@ -367,7 +420,11 @@ class Organization extends Component {
367420 < Box layerStyle = { 'shadowed' } as = 'section' >
368421 < Heading variant = 'sectionHead' > Teams</ Heading >
369422 { this . renderMap ( teams ) }
370- < TeamsTable type = 'org-teams' orgId = { org . data . id } />
423+ < TeamsTable
424+ type = 'org-teams'
425+ orgId = { org . data . id }
426+ bbox = { searchOnMapMove ? mapBounds : null }
427+ />
371428 </ Box >
372429
373430 { isStaff ? (
0 commit comments