Skip to content

Commit f0b78f9

Browse files
committed
Add Disabling of Rejoin Room if Room is Expired
1 parent 4d6f6ec commit f0b78f9

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

frontend/src/presentation/components/RecentAttemptsTable.tsx

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -208,26 +208,36 @@ export const RecentAttemptsTable: React.FC = () => {
208208
{
209209
title: 'Actions',
210210
key: 'action',
211-
render: (_text, record) => (
212-
<Space size="middle" className={styles.actionsButton}>
213-
<Button
214-
type="link"
215-
onClick={() => showModal(record.attemptCodes, record.key)}
216-
icon={<EyeOutlined />}
217-
aria-label={`View past code for attempt ${record.key}`}
218-
>
219-
View Past Code
220-
</Button>
221-
<Button
222-
type="link"
223-
onClick={() => navigate(`/room/${record.roomId}`)}
224-
icon={<TeamOutlined />}
225-
aria-label={`Rejoin room ${record.roomId}`}
226-
>
227-
Rejoin
228-
</Button>
229-
</Space>
230-
),
211+
render: (_text, record) => {
212+
const attemptStartDate = new Date(record.attemptStartedAt);
213+
const now = new Date();
214+
const timeDiffMs = now.getTime() - attemptStartDate.getTime();
215+
216+
const isWithin24Hours = timeDiffMs < 86400000; // Should be same as ROOM_LIFESPAN in MatchingService
217+
218+
return (
219+
<Space size="middle" className={styles.actionsButton}>
220+
<Button
221+
type="link"
222+
onClick={() => showModal(record.attemptCodes, record.key)}
223+
icon={<EyeOutlined />}
224+
aria-label={`View past code for attempt ${record.key}`}
225+
>
226+
View Past Code
227+
</Button>
228+
{isWithin24Hours && (
229+
<Button
230+
type="link"
231+
onClick={() => navigate(`/room/${record.roomId}`)}
232+
icon={<TeamOutlined />}
233+
aria-label={`Rejoin room ${record.roomId}`}
234+
>
235+
Rejoin
236+
</Button>
237+
)}
238+
</Space>
239+
);
240+
},
231241
},
232242
];
233243

0 commit comments

Comments
 (0)