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

Commit 63169ee

Browse files
author
ge85riz
committed
♻️ refactor(frontend): replace chair.assigneeName and chair.assigneeProfileId with -> chair.assigneeProfile so that more profile related data can be displayed on chairs if necessary
1 parent 35c9949 commit 63169ee

8 files changed

Lines changed: 30 additions & 27 deletions

File tree

frontend/src/components/canvas/EventListeners.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ export const handleDragEnd = (e: Konva.KonvaEventObject<DragEvent>, el: ElementP
481481
updateMultipleWithoutUndoRedo(updates),
482482
);
483483

484-
if ((el as Chair).assigneeProfileId) {
484+
if ((el as Chair).assigneeProfile) {
485485
toast.error("Cannot remove occupied chairs. Unassign participants before removing chairs from the table.");
486486
setTimeout(() => dispatch(undo(true)), 100);
487487
}

frontend/src/components/canvas/KonvaCanvas.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,9 @@ function KonvaCanvas({ stageReference, schematicsUUID, isFullWidth }: KonvaCanva
198198

199199
const selectedChair = chairs.find((chair) => chair.id === selectedIds[0]);
200200
if (selectedChair) {
201-
if (!selectedChair.assigneeProfileId && selectedChair.attachedTo && (state.chairIdForManualAssignment === null || (state.chairIdForManualAssignment !== selectedChair.id))) {
201+
if (!selectedChair.assigneeProfile && selectedChair.attachedTo && (state.chairIdForManualAssignment === null || (state.chairIdForManualAssignment !== selectedChair.id))) {
202202
dispatch(setChairIdForManualAssignment(selectedChair.id));
203-
} else if (selectedChair.assigneeProfileId && state.chairIdForManualAssignment !== null && state.chairIdForManualAssignment === selectedChair.id) {
203+
} else if (selectedChair.assigneeProfile && state.chairIdForManualAssignment !== null && state.chairIdForManualAssignment === selectedChair.id) {
204204
dispatch(setChairIdForManualAssignment(null));
205205
}
206206
}

frontend/src/components/canvas/elements/Chair.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { v4 as uuidv4 } from "uuid";
22
import { Circle, Group, Text } from "react-konva";
33
import type { ElementProperties, ShapeType, UUID } from "components/canvas/utils/constants.tsx";
44
import { handleMouseOut, handleMouseOver } from "components/canvas/utils/functions.tsx";
5+
import { getFullName, type Profile } from "types/employee.ts";
56

67
export class Chair implements ElementProperties {
78
id: UUID;
@@ -13,8 +14,7 @@ export class Chair implements ElementProperties {
1314
attachedTo: string | undefined;
1415
draggable: boolean;
1516
offset: { dx: number; dy: number };
16-
assigneeProfileId?: string;
17-
assigneeName?: string;
17+
assigneeProfile?: Profile;
1818
belongsToVisitor?: boolean;
1919

2020
constructor(stageCenter: { x: number, y: number }) {
@@ -27,8 +27,7 @@ export class Chair implements ElementProperties {
2727
this.attachedTo = undefined;
2828
this.draggable = true;
2929
this.offset = { dx: 0, dy: 0 };
30-
this.assigneeProfileId = undefined;
31-
this.assigneeName = undefined;
30+
this.assigneeProfile = undefined;
3231
this.belongsToVisitor = false;
3332
}
3433
}
@@ -43,9 +42,9 @@ export function ChairRender(chair: Chair) {
4342
fill={chair.color || "#cccccc"}
4443
perfectDrawEnabled={false}
4544
/>
46-
{chair.assigneeName && (
45+
{chair.assigneeProfile && (
4746
<Text
48-
text={chair.assigneeName}
47+
text={getFullName(chair.assigneeProfile)}
4948
x={-chair.radius - 5}
5049
y={-chair.radius - 15}
5150
fontSize={10}

frontend/src/components/canvas/reducers/CanvasReducer.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ export function reducer(state: AppState, action: Action) {
156156
x: (original as Chair).x + 50,
157157
y: (original as Chair).y + 50,
158158
};
159-
delete (newChair as Chair).assigneeName;
160-
delete (newChair as Chair).assigneeProfileId;
159+
delete (newChair as Chair).assigneeProfile;
161160
newElements.push(newChair);
162161
} else if (
163162
original.type === "rectTable" ||

frontend/src/components/canvas/utils/functions.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const handleExport = async (stageRef: React.RefObject<Konva.Stage | null>
6565
if (!stageRef.current) return;
6666

6767
const stage = stageRef.current;
68+
stage.scale({ x: 1, y: 1 });
6869
const layers = stage.getLayers();
6970

7071
// Check if there are any layers with content
@@ -160,7 +161,7 @@ export const validateCanvasElementDeletion = (state: AppState, selectedIds: UUID
160161
}
161162

162163
// Check directly selected assigned chairs
163-
const hasAssignedChairs = chairsToBeDeleted.some(chair => chair.assigneeProfileId);
164+
const hasAssignedChairs = chairsToBeDeleted.some(chair => chair.assigneeProfile);
164165
if (hasAssignedChairs) {
165166
toast.error("Cannot delete chair(s) that have assigned participants. Please unassign first.");
166167
return false;
@@ -174,7 +175,7 @@ export const validateCanvasElementDeletion = (state: AppState, selectedIds: UUID
174175

175176
const hasAssignedAttachedChairs = table.attachedChairs.some(chairId => {
176177
const chair = allChairMap.get(chairId);
177-
return chair?.assigneeProfileId;
178+
return chair?.assigneeProfile;
178179
});
179180

180181
if (hasAssignedAttachedChairs) {
@@ -220,9 +221,9 @@ export function extractedNeighboringEmployeeProfileIds(
220221
neighbourProfileIds = state.elements.reduce<string[]>((acc, el) => {
221222
if (el.type === "chair" &&
222223
neighborChairIds.has(el.id) &&
223-
(el as Chair).assigneeProfileId &&
224+
(el as Chair).assigneeProfile &&
224225
!(el as Chair).belongsToVisitor) {
225-
acc.push((el as Chair).assigneeProfileId!);
226+
acc.push((el as Chair).assigneeProfile!.id!);
226227
}
227228
return acc;
228229
}, []);

frontend/src/pages/Events/EventSeatAllocation.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ import { CanvasTooltip } from "components/CanvasTooltip.tsx";
1414
import { areNeighbours, extractedNeighboringEmployeeProfileIds } from "components/canvas/utils/functions.tsx";
1515
import { setCanvasPosition, setChairIdForManualAssignment } from "components/canvas/actions/actions.tsx";
1616
import type { SeatAllocationResult } from "types/event.ts";
17-
import { FullscreenExitOutlined, LeftOutlined, LoginOutlined, LogoutOutlined, RightOutlined } from "@ant-design/icons";
17+
import {
18+
FullscreenExitOutlined,
19+
LoginOutlined,
20+
LogoutOutlined,
21+
MenuFoldOutlined,
22+
MenuUnfoldOutlined,
23+
} from "@ant-design/icons";
1824
import Konva from "konva";
1925
import { useAuth } from "../../contexts/AuthContext.tsx";
2026
import toast from "react-hot-toast";
@@ -143,15 +149,13 @@ const SeatAllocationContent = ({
143149
state.elements
144150
?.forEach((e: ElementProperties) => {
145151
if (e.type === "chair" && chairProfileMap.has(e.id)) {
146-
(e as Chair).assigneeProfileId = chairProfileMap.get(e.id)!.id;
147-
(e as Chair).assigneeName = getFullName(chairProfileMap.get(e.id)!);
152+
(e as Chair).assigneeProfile = { ...chairProfileMap.get(e.id)! };
148153
(e as Chair).belongsToVisitor = chairProfileMap.get(e.id)!.isVisitor;
149154
if (!(e as Chair).attachedTo) {
150155
toast.error("Some participants are assigned to chairs that are not linked to a table. It might cause inconsistencies. Please be aware.");
151156
}
152157
} else if (e.type === "chair") {
153-
(e as Chair).assigneeProfileId = undefined;
154-
(e as Chair).assigneeName = undefined;
158+
(e as Chair).assigneeProfile = undefined;
155159
(e as Chair).belongsToVisitor = undefined;
156160
emptyChairCount++;
157161
}
@@ -243,8 +247,8 @@ const SeatAllocationContent = ({
243247
style={{ transition: "all 0.2s ease" }}
244248
title={isCollapsed ? "Expand" : "Collapse"}
245249
>
246-
{isCollapsed ? <LeftOutlined style={{ fontSize: "12px" }} /> :
247-
<RightOutlined style={{ fontSize: "12px" }} />}
250+
{isCollapsed ? <MenuFoldOutlined style={{ fontSize: "12px" }} /> :
251+
<MenuUnfoldOutlined style={{ fontSize: "12px" }} />}
248252
</Button>
249253
</Space>
250254
</div>
@@ -338,7 +342,7 @@ const SeatAllocationContent = ({
338342
(getFullName(item.profile).toLowerCase() || "").includes(unallocatedSearch.toLowerCase()) ||
339343
(item.profile.email?.toLowerCase() || "").includes(unallocatedSearch.toLowerCase()),
340344
), [unallocated, unallocatedSearch])}
341-
pagination={{ pageSize: 5, showLessItems: true }}
345+
pagination={{ defaultPageSize: 5, showLessItems: true, showSizeChanger: true }}
342346
renderItem={item => (
343347
<List.Item
344348
actions={[
@@ -393,7 +397,7 @@ const SeatAllocationContent = ({
393397
/>
394398
{/* List of employees who are assigned to any seat */}
395399
<List
396-
pagination={{ pageSize: 5, showLessItems: true }}
400+
pagination={{ defaultPageSize: 5, showLessItems: true, showSizeChanger: true }}
397401
dataSource={useMemo(() =>
398402
allocated.filter(item =>
399403
(getFullName(item.profile).toLowerCase() || "").includes(allocatedSearch.toLowerCase()) ||

frontend/src/pages/Events/EventsList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ export const EventsList = () => {
338338
rowKey="id"
339339
columns={columns}
340340
dataSource={pastEvents}
341-
pagination={{ pageSize: 15 }}
341+
pagination={{ defaultPageSize: 15, showSizeChanger: true }}
342342
loading={loading}
343343
/>
344344
) : (

frontend/src/services/apiService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ export default function useApiService() {
311311
// We don't need to persist them into the AppState, the main data are stored and used from EmployeeParticipation/VisitorParticipation Tables
312312
canvasStateToPersist.elements.forEach((el) => {
313313
if (el.type === "chair") {
314-
delete (el as Chair).assigneeProfileId;
315-
delete (el as Chair).assigneeName;
314+
delete (el as Chair).assigneeProfile;
315+
delete (el as Chair).belongsToVisitor;
316316
}
317317
});
318318
const response = await request(`/schematics/${id}`, {

0 commit comments

Comments
 (0)