Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit bebdb04

Browse files
author
ge85riz
committed
✨ feat(frontend): add a new functionality to unseat all seated participants of an event on Seat Allocation Page
1 parent 61842b6 commit bebdb04

2 files changed

Lines changed: 73 additions & 7 deletions

File tree

frontend/src/pages/Events/EventSeatAllocation.tsx

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
import 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";
316
import { useNavigate, useParams } from "react-router-dom";
417
import { Breadcrumb } from "components/Breadcrumb";
518
import useApiService from "services/apiService";
@@ -15,6 +28,7 @@ import { areNeighbours, extractedNeighboringEmployeeProfileIds } from "component
1528
import { setCanvasPosition, setChairIdForManualAssignment } from "components/canvas/actions/actions.tsx";
1629
import type { SeatAllocationResult } from "types/event.ts";
1730
import {
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
};

frontend/src/services/apiService.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,14 @@ export default function useApiService() {
558558
}
559559
}, [request]);
560560

561+
const unsetAllSeatAllocations = useCallback(async (eventId: string) => {
562+
try {
563+
return await request<void>(`/seat-allocation/${eventId}/unsetAllChairs`);
564+
} catch (err) {
565+
toast.error("Unsetting of all seat allocations for this event failed");
566+
}
567+
}, [request]);
568+
561569
const updateSeatAllocation = useCallback(async (eventId: string, newSeatAllocations: SeatAllocationUpsert) => {
562570
try {
563571
const response = await request<boolean>(
@@ -617,5 +625,6 @@ export default function useApiService() {
617625
findEmployeesSittingWithAcquaintances,
618626
getSeatAllocations,
619627
updateSeatAllocation,
628+
unsetAllSeatAllocations,
620629
};
621630
}

0 commit comments

Comments
 (0)