Skip to content

Commit f558075

Browse files
committed
Remove cancel, join button from Found UI
1 parent 7bced3b commit f558075

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

apps/frontend/src/app/matching/MatchingModal.tsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client"
2+
13
import React, { useState, useEffect } from 'react';
24
import {
35
Form,
@@ -15,7 +17,7 @@ import MatchCancelledContent from './modalContent/MatchCancelledContent';
1517
import useMatching from '../services/use-matching';
1618
import { ValidateUser } from '../services/user';
1719
import { useTimer } from 'react-timer-hook';
18-
import { useRouter } from 'next/router';
20+
import { useRouter } from 'next/navigation';
1921

2022
interface MatchingModalProps {
2123
isOpen: boolean;
@@ -43,23 +45,22 @@ const MatchingModal: React.FC<MatchingModalProps> = ({ isOpen, close: _close })
4345
return;
4446
}
4547
if (matchingState.state === "found") {
46-
matchingState.ok();
47-
setClosedType("joined");
48+
join();
4849
return;
4950
}
5051
console.warn(`matching is in ${matchingState.state}`)
5152
},
5253
});
5354
const passed = MATCH_TIMEOUT - totalSeconds;
5455

55-
function close() {
56-
// clean up matching and closedType State
57-
if (matchingState.state === "timeout") {
58-
matchingState.ok();
56+
function close() {
57+
// clean up matching and closedType State
58+
if (matchingState.state === "timeout") {
59+
matchingState.ok();
60+
}
61+
setClosedType("finding");
62+
_close();
5963
}
60-
setClosedType("finding");
61-
_close();
62-
}
6364

6465
const startMatch = matchingState.state == "closed" || matchingState.state == "timeout" ? async (params: MatchParams): Promise<void> => {
6566
const user = await ValidateUser();
@@ -75,6 +76,22 @@ const MatchingModal: React.FC<MatchingModalProps> = ({ isOpen, close: _close })
7576
...params
7677
});
7778
} : undefined;
79+
80+
const join = matchingState.state == "found" ? (() => {
81+
matchingState.ok();
82+
setClosedType("joined");
83+
localStorage.setItem("user", matchingState.info.user);
84+
localStorage.setItem(
85+
"matchedUser",
86+
matchingState.info.matchedUser
87+
);
88+
localStorage.setItem("collabId", matchingState.info.matchId);
89+
localStorage.setItem("questionDocRefId", matchingState.info.questionDocRefId);
90+
localStorage.setItem("matchedTopics", matchingState.info.matchedTopics.join(","));
91+
92+
// Redirect to collaboration page
93+
router.push(`/collaboration/${matchingState.info.matchId}`);
94+
}) : () => { throw new Error("join called when not found"); }
7895

7996
useEffect(() => {
8097
if (matchingState.state === "cancelling" || matchingState.state === "timeout") {
@@ -129,21 +146,7 @@ const MatchingModal: React.FC<MatchingModalProps> = ({ isOpen, close: _close })
129146
matchingState.ok();
130147
setClosedType("cancelled");
131148
}}
132-
join={() => {
133-
matchingState.ok();
134-
setClosedType("joined");
135-
localStorage.setItem("user", matchingState.info.user);
136-
localStorage.setItem(
137-
"matchedUser",
138-
matchingState.info.matchedUser
139-
);
140-
localStorage.setItem("collabId", matchingState.info.matchId);
141-
localStorage.setItem("questionDocRefId", matchingState.info.questionDocRefId);
142-
localStorage.setItem("matchedTopics", matchingState.info.matchedTopics.join(","));
143-
144-
// Redirect to collaboration page
145-
router.push(`/collaboration/${matchingState.info.matchId}`);
146-
}}
149+
join={join}
147150
name1={matchingState.info.user}
148151
name2={matchingState.info.matchedUser}
149152
joiningIn={totalSeconds}

apps/frontend/src/app/matching/modalContent/FindMatchContent.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ const TagInput: React.FC<{
5656
<Tag.CheckableTag
5757
className={`difficulty-tag ${difficultyOption.value}-tag`}
5858
key={difficultyOption.value}
59-
checked={value.includes(difficultyOption.label)}
59+
checked={value.includes(difficultyOption.value)}
6060
onChange={(enabled) => {
6161
onChange(
6262
enabled
63-
? [...value, difficultyOption.label]
64-
: value.filter(diff => diff !== difficultyOption.label)
63+
? [...value, difficultyOption.value]
64+
: value.filter(diff => diff !== difficultyOption.value)
6565
)
6666
}}
6767
>

apps/frontend/src/app/matching/modalContent/MatchFoundContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const MatchFoundContent: React.FC<Props> = ({join, cancel, name1: me, name2: you
4343
<div className="match-status-message">
4444
Joining in... {formatTime(joiningIn)}
4545
</div>
46-
<button className="join-match-button"
46+
{/* <button className="join-match-button"
4747
onClick={join}
4848
>
4949
Join
@@ -52,7 +52,7 @@ const MatchFoundContent: React.FC<Props> = ({join, cancel, name1: me, name2: you
5252
onClick={cancel}
5353
>
5454
Cancel
55-
</button>
55+
</button> */}
5656
</div>
5757
);
5858
};

0 commit comments

Comments
 (0)