Skip to content

Commit 77ff847

Browse files
committed
Add modal component on top of end session
1 parent 68023da commit 77ff847

File tree

2 files changed

+31
-18
lines changed

2 files changed

+31
-18
lines changed

apps/frontend/src/app/collaboration/[id]/page.tsx

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Col,
66
Input,
77
Layout,
8+
Modal,
89
Row,
910
Select,
1011
Tabs,
@@ -66,6 +67,9 @@ export default function CollaborationPage(props: CollaborationProps) {
6667
undefined
6768
);
6869

70+
// Modal state
71+
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
72+
6973
// Stops the session duration stopwatch
7074
const stopStopwatch = () => {
7175
if (stopwatchRef.current) {
@@ -168,14 +172,14 @@ export default function CollaborationPage(props: CollaborationProps) {
168172
// Remove localstorage variable for stored session duration
169173
localStorage.removeItem("session-duration"); // TODO: Remove this after collaboration backend data stored
170174

171-
// // Remove localstorage variables for collaboration
172-
// localStorage.removeItem("user");
173-
// localStorage.removeItem("matchedUser");
174-
// localStorage.removeItem("collaId");
175-
// localStorage.removeItem("docRefId");
175+
// Remove localstorage variables for collaboration
176+
localStorage.removeItem("user");
177+
localStorage.removeItem("matchedUser");
178+
localStorage.removeItem("collaId");
179+
localStorage.removeItem("docRefId");
176180

177-
// // Redirect back to matching page
178-
// router.push("/matching");
181+
// Redirect back to matching page
182+
router.push("/matching");
179183
};
180184

181185
return (
@@ -251,15 +255,6 @@ export default function CollaborationPage(props: CollaborationProps) {
251255
Submit
252256
</Button>
253257
</div>
254-
{/* <div className="code-second-container">
255-
<div className="code-language">Select Language:</div>
256-
<Select
257-
className="language-select"
258-
defaultValue={selectedLanguage}
259-
options={ProgrammingLanguageOptions}
260-
onSelect={(val) => setSelectedLanguage(val)}
261-
/>
262-
</div> */}
263258
{collaborationId && currentUser && selectedLanguage && (
264259
<CollaborativeEditor
265260
user={currentUser}
@@ -278,10 +273,24 @@ export default function CollaborationPage(props: CollaborationProps) {
278273
<ClockCircleOutlined className="title-icons" />
279274
Session Details
280275
</div>
281-
{/* TODO: End the collaboration session, cleanup the localstorage variables */}
276+
<Modal
277+
height={500}
278+
title={"End Session"}
279+
okText={"End"}
280+
okButtonProps={{ danger: true }}
281+
onOk={handleCloseCollaboration}
282+
open={isModalOpen}
283+
onCancel={() => setIsModalOpen(false)}
284+
width={400}
285+
>
286+
<p className="modal-description">
287+
Are you sure you want to quit the existing collaboration
288+
session?
289+
</p>
290+
</Modal>
282291
<Button
283292
danger
284-
onClick={handleCloseCollaboration}
293+
onClick={() => setIsModalOpen(true)}
285294
className="session-end-button"
286295
>
287296
End

apps/frontend/src/app/collaboration/[id]/styles.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,7 @@
174174
.test-case-button {
175175
width: fit-content;
176176
}
177+
178+
.modal-description {
179+
margin-bottom: 2rem;
180+
}

0 commit comments

Comments
 (0)