Skip to content

Commit 9c75fcd

Browse files
committed
Make textbox visible in login/register
1 parent fe287dc commit 9c75fcd

File tree

3 files changed

+52
-26
lines changed

3 files changed

+52
-26
lines changed

peerprep/app/actions/server_actions.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,23 @@ export async function login(state: FormState, formData: FormData) {
6565
await createSession(json.data);
6666
redirect("/questions");
6767
} else {
68-
console.log("Get session login error: " + json.error + " : " + json.status);
68+
if (json.status === 401) {
69+
return {
70+
errors: {
71+
email: ["Invalid email or password."],
72+
},
73+
};
74+
} else if (json.status === 500) {
75+
console.log(
76+
"Get session login error: " + json.error + " : " + json.status,
77+
);
78+
79+
return {
80+
errors: {
81+
email: ["Please try again."],
82+
},
83+
};
84+
}
6985
}
7086
}
7187

peerprep/components/questionpage/CommsPanel.tsx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import io from "socket.io-client";
44

55
interface Props {
66
className?: string;
7-
roomId?: String;
7+
roomId?: string;
88
}
99

1010
const socket = io(`${process.env.NEXT_PUBLIC_COMMS}`);
@@ -24,7 +24,7 @@ function CommsPanel({ className, roomId }: Props) {
2424
if (socket) {
2525
console.log("destroying socket");
2626
socket.close();
27-
}
27+
}
2828
if (connectionRef.current) {
2929
connectionRef.current.destroy();
3030
}
@@ -40,24 +40,30 @@ function CommsPanel({ className, roomId }: Props) {
4040
.then((newStream) => {
4141
console.log("new stream's status is " + newStream.active);
4242
newStream.getTracks().forEach((track: MediaStreamTrack) => {
43-
console.log("media track status (ready/enabled): " + track.readyState + "/" + track.enabled);
44-
})
43+
console.log(
44+
"media track status (ready/enabled): " +
45+
track.readyState +
46+
"/" +
47+
track.enabled,
48+
);
49+
});
4550
if (myVideo.current) {
46-
console.log("can set myVideo.current")
51+
console.log("can set myVideo.current");
4752
myVideo.current.srcObject = newStream;
4853
}
4954
setStream(newStream);
5055
videoElement = newStream;
51-
}).catch((err) => console.log("failed to get stream"));
56+
})
57+
.catch((err) => console.log("failed to get stream", err));
5258

53-
return () => {
54-
console.log("cleaning up media");
55-
if (videoElement) {
56-
console.log("destroying stream");
57-
videoElement.getTracks().forEach((track) => track.stop());
58-
}
59+
return () => {
60+
console.log("cleaning up media");
61+
if (videoElement) {
62+
console.log("destroying stream");
63+
videoElement.getTracks().forEach((track) => track.stop());
5964
}
60-
}, [])
65+
};
66+
}, []);
6167

6268
useEffect(() => {
6369
if (!roomId || !stream || !socket.connected) {
@@ -81,8 +87,9 @@ function CommsPanel({ className, roomId }: Props) {
8187
socket.on("endCall", () => {
8288
if (userVideo.current) {
8389
(userVideo.current.srcObject as MediaStream)
84-
.getTracks().forEach((tracks: MediaStreamTrack) => {
85-
tracks.stop()
90+
.getTracks()
91+
.forEach((tracks: MediaStreamTrack) => {
92+
tracks.stop();
8693
});
8794
userVideo.current.srcObject = null;
8895
}
@@ -118,9 +125,10 @@ function CommsPanel({ className, roomId }: Props) {
118125
}
119126

120127
function attachSocketReceiver(
121-
stream: MediaStream, roomId: String,
122-
userVideo: React.RefObject<HTMLVideoElement>,
123-
connectionRef: React.MutableRefObject<Peer.Instance|undefined>
128+
stream: MediaStream,
129+
roomId: string,
130+
userVideo: React.RefObject<HTMLVideoElement>,
131+
connectionRef: React.MutableRefObject<Peer.Instance | undefined>,
124132
) {
125133
socket.on("startCall", (data) => {
126134
console.log("received start call signal");
@@ -150,9 +158,10 @@ function attachSocketReceiver(
150158
}
151159

152160
function attachSocketInitiator(
153-
stream: MediaStream, roomId: String,
161+
stream: MediaStream,
162+
roomId: string,
154163
userVideo: React.RefObject<HTMLVideoElement>,
155-
connectionRef: React.MutableRefObject<Peer.Instance|undefined>
164+
connectionRef: React.MutableRefObject<Peer.Instance | undefined>,
156165
) {
157166
socket.on("peerConnected", () => {
158167
console.log("peer connected, starting call");
@@ -161,24 +170,24 @@ function attachSocketInitiator(
161170
trickle: false,
162171
stream: stream,
163172
});
164-
173+
165174
peerInit.on("signal", (data) => {
166175
console.log("signal to start call received");
167176
socket.emit("startCall", { signalData: data, target: roomId });
168177
});
169-
178+
170179
peerInit.on("stream", (stream) => {
171180
if (userVideo.current) {
172181
console.log("setting stream for handshake");
173182
userVideo.current.srcObject = stream;
174183
}
175184
});
176-
185+
177186
connectionRef.current = peerInit;
178-
187+
179188
socket.on("handshakeCall", (data) => {
180189
console.log("received handshake");
181-
peerInit.signal(data.signal)
190+
peerInit.signal(data.signal);
182191
});
183192
});
184193
}

peerprep/style/form.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
margin: 2px;
7272
padding: 2px;
7373
position: relative;
74+
color: black;
7475
}
7576

7677
.error {

0 commit comments

Comments
 (0)