Skip to content

Commit e94592d

Browse files
committed
Add captions under matched users
1 parent 7c36043 commit e94592d

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ const MatchingModal: React.FC<MatchingModalProps> = ({ isOpen, close: _close })
7777
matchingState.ok();
7878
setClosedType("joined");
7979
}}
80+
name1={matchingState.info.myName}
81+
name2={matchingState.info.partnerName}
8082
/>
8183
case 'timeout':
8284
return <MatchNotFoundContent reselect={matchingState.ok} retry={() => {}} timedOutIn={10}/>;

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import { useTimer } from "react-timer-hook"
1010
interface Props {
1111
join(): void,
1212
cancel(): void,
13+
name1: string, // user's username
14+
name2: string, // matched user's username
1315
}
1416

1517
const TIMEOUT = 10;
1618

17-
const MatchFoundContent: React.FC<Props> = ({join, cancel}) => {
19+
const MatchFoundContent: React.FC<Props> = ({join, cancel, name1: me, name2: you}) => {
1820
const { totalSeconds } = useTimer({
1921
expiryTimestamp: new Date(Date.now() + 10 * 1000),
2022
onExpire: join
@@ -23,7 +25,10 @@ const MatchFoundContent: React.FC<Props> = ({join, cancel}) => {
2325
return (
2426
<div className="matching-found-content">
2527
<div className="matched-profiles">
26-
<Avatar size={64} icon={<UserOutlined />} />
28+
<div className="avatar-caption-container">
29+
<Avatar size={64} icon={<UserOutlined />} />
30+
<div className="user-caption">{me}</div>
31+
</div>
2732
<svg xmlns="http://www.w3.org/2000/svg"
2833
height="24px"
2934
viewBox="0 -960 960 960"
@@ -33,7 +38,10 @@ const MatchFoundContent: React.FC<Props> = ({join, cancel}) => {
3338
>
3439
<path d="m422-232 207-248H469l29-227-185 267h139l-30 208ZM320-80l40-280H160l360-520h80l-40 320h240L400-80h-80Zm151-390Z"/>
3540
</svg>
36-
<Avatar size={64} icon={<UserOutlined />} />
41+
<div className="avatar-caption-container">
42+
<Avatar size={64} icon={<UserOutlined />} />
43+
<div className="user-caption">{you}</div>
44+
</div>
3745
</div>
3846
<div className="match-status-label">Match Found!</div>
3947
<div className="match-status-message">

apps/frontend/src/app/matching/modalContent/styles.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,12 @@ button:disabled, .joined-match-deactivated-button {
228228
height: 60px;
229229
fill: #463F3A;
230230
}
231+
232+
.user-caption {
233+
display: flex;
234+
justify-content: center;
235+
}
236+
237+
.avatar-caption-container {
238+
width: 64px;
239+
}

apps/frontend/src/app/services/use-matching.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,14 @@ function parseInfoFromResponse(responseJson: MatchFoundResponse): MatchInfo {
133133
matchId: responseJson.matchId?.toString() ?? "unknown",
134134
partnerId: responseJson.partnerId?.toString() ?? "unknown",
135135
partnerName: responseJson.partnerName ?? "unknown",
136+
myName: "unknown",
136137
};
137138
} else {
138139
return {
139140
matchId: responseJson.matchId?.toString() ?? "unknown",
140141
partnerId: "unknown",
141142
partnerName: responseJson.matchedUser ?? "unknown",
143+
myName: responseJson.user ?? "unknown",
142144
};
143145
}
144146
}

apps/frontend/src/contexts/websocketcontext.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type SocketState = {
1515
export type MatchInfo = {
1616
matchId: string;
1717
partnerId: string;
18+
myName: string;
1819
partnerName: string;
1920
}
2021
export type MatchState = SocketState | {

0 commit comments

Comments
 (0)