11import React , { type Key , useEffect , useMemo , useState } from "react" ;
2- import { Avatar , Button , Card , Col , Input , InputNumber , List , Row , Space , Spin , Typography } from "utils/antd.tsx" ;
2+ import {
3+ Avatar ,
4+ Button ,
5+ Card ,
6+ Col ,
7+ Input ,
8+ InputNumber ,
9+ List ,
10+ Modal ,
11+ Row ,
12+ Space ,
13+ Spin ,
14+ Typography ,
15+ } from "utils/antd.tsx" ;
316import { useNavigate , useParams } from "react-router-dom" ;
417import { Breadcrumb } from "components/Breadcrumb" ;
518import useApiService from "services/apiService" ;
@@ -15,6 +28,7 @@ import { areNeighbours, extractedNeighboringEmployeeProfileIds } from "component
1528import { setCanvasPosition , setChairIdForManualAssignment } from "components/canvas/actions/actions.tsx" ;
1629import type { SeatAllocationResult } from "types/event.ts" ;
1730import {
31+ ClearOutlined ,
1832 FullscreenExitOutlined ,
1933 LoginOutlined ,
2034 LogoutOutlined ,
@@ -49,11 +63,13 @@ const SeatAllocationContent = ({
4963 const [ allocated , setAllocated ] = useState < SeatAllocationResult [ ] > ( [ ] ) ;
5064 const [ unallocatedSearch , setUnallocatedSearch ] = useState ( "" ) ;
5165 const [ allocatedSearch , setAllocatedSearch ] = useState ( "" ) ;
66+ const [ showUnseatAllConfirmModal , setShowUnseatAllConfirmModal ] = useState ( false ) ;
5267 const {
5368 getSeatAllocations,
5469 updateSeatAllocation,
5570 generateSeatAllocations,
5671 findEmployeesSittingWithAcquaintances,
72+ unsetAllSeatAllocations,
5773 } = useApiService ( ) ;
5874 const [ isCollapsed , setIsCollapsed ] = useState ( false ) ;
5975 const [ emptyChairCount , setEmptyChairCount ] = useState ( 0 ) ;
@@ -200,6 +216,28 @@ const SeatAllocationContent = ({
200216 } ) ) ;
201217 } ;
202218
219+ const handleUnallocateAllClick = ( ) => {
220+ setShowUnseatAllConfirmModal ( true ) ;
221+ } ;
222+
223+ const handleUnallocateAllConfirm = ( ) => {
224+ try {
225+ setLoading ( true ) ;
226+ setShowUnseatAllConfirmModal ( false ) ;
227+ unsetAllSeatAllocations ( eventId ) . then ( ( ) => {
228+
229+ participants . forEach ( p => {
230+ p . chairId = null ;
231+ } ) ;
232+ setParticipants ( [ ...participants ] ) ;
233+ toast . success ( "All Participants are unseated successfully!" ) ;
234+ } ) ;
235+ } finally {
236+ setLoading ( false ) ;
237+ }
238+
239+ } ;
240+
203241 stageRefs ?. current ?. getStage ( ) ?. fire ( "contentReady" ) ;
204242
205243 return (
@@ -208,7 +246,7 @@ const SeatAllocationContent = ({
208246 < Breadcrumb
209247 items = { [
210248 { path : "/events" , label : "Events" } ,
211- { path : `/events/${ eventId } ` , label : eventName || "Event" } ,
249+ { path : `/events/${ eventId } ` , label : eventName || "Selected Event" } ,
212250 { path : `/events/${ eventId } /seat-allocation/${ schematicsId } ` , label : "Manage Seat Allocation" } ,
213251 ] }
214252 />
@@ -376,7 +414,7 @@ const SeatAllocationContent = ({
376414 ( getFullName ( item . profile ) . toLowerCase ( ) || "" ) . includes ( unallocatedSearch . toLowerCase ( ) ) ||
377415 ( item . profile . email ?. toLowerCase ( ) || "" ) . includes ( unallocatedSearch . toLowerCase ( ) ) ,
378416 ) , [ unallocated , unallocatedSearch ] ) }
379- pagination = { { defaultPageSize : 5 , showLessItems : true , showSizeChanger : true } }
417+ pagination = { { defaultPageSize : 5 , showSizeChanger : true , size : "small" } }
380418 renderItem = { item => (
381419 < List . Item
382420 actions = { [
@@ -420,9 +458,13 @@ const SeatAllocationContent = ({
420458 ) }
421459 />
422460 </ Card >
423- < Card title = { `Allocated Participants ( ${ allocated . length } / ${ allocated . length + unallocated . length } )` }
424- className = "mb-6"
425- style = { { display : isCollapsed || allocated . length === 0 ? "none" : "block" } } >
461+ < Card
462+ title = { `Allocated Participants ( ${ allocated . length } / ${ allocated . length + unallocated . length } )` }
463+ extra = { < Button className = "mr-2" icon = { < ClearOutlined style = { { fontSize : 16 , color : "red" } } /> }
464+ onClick = { handleUnallocateAllClick } > </ Button > }
465+ className = "mb-6"
466+ style = { { display : isCollapsed || allocated . length === 0 ? "none" : "block" } }
467+ >
426468 < Input . Search
427469 placeholder = "Search"
428470 value = { allocatedSearch }
@@ -431,7 +473,7 @@ const SeatAllocationContent = ({
431473 />
432474 { /* List of employees who are assigned to any seat */ }
433475 < List
434- pagination = { { defaultPageSize : 5 , showLessItems : true , showSizeChanger : true } }
476+ pagination = { { defaultPageSize : 5 , showSizeChanger : true , size : "small" } }
435477 dataSource = { useMemo ( ( ) =>
436478 allocated . filter ( item =>
437479 ( getFullName ( item . profile ) . toLowerCase ( ) || "" ) . includes ( allocatedSearch . toLowerCase ( ) ) ||
@@ -469,6 +511,21 @@ const SeatAllocationContent = ({
469511 </ div >
470512 </ Col >
471513 </ Row >
514+
515+ { /* Unseat All seated participants of this event */ }
516+ < Modal
517+ title = "Unseat All Participants"
518+ open = { showUnseatAllConfirmModal }
519+ onOk = { handleUnallocateAllConfirm }
520+ onCancel = { ( ) => setShowUnseatAllConfirmModal ( false ) }
521+ okText = "Confirm"
522+ cancelText = "Cancel"
523+ okButtonProps = { { danger : true } }
524+ centered
525+ >
526+ < p > Are you sure you want to unseat all participants?</ p >
527+ </ Modal >
528+
472529 </ div >
473530 ) ;
474531} ;
0 commit comments