Skip to content

Commit 23b513d

Browse files
committed
push for deployment
1 parent ae4d5ab commit 23b513d

File tree

16 files changed

+306
-175
lines changed

16 files changed

+306
-175
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,7 @@ $RECYCLE.BIN/
348348

349349
# End of https://www.toptal.com/developers/gitignore/api/jetbrains+all,visualstudiocode,macos,windows,linux,react,firebase,node
350350
client/yarn.lock
351+
352+
client/build/
353+
354+
client/firebase.json

client/src/components/callstudent/Callstudent.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function AppelEleve({ callId }) {
2020
const open = useRef();
2121
const msg = useRef();
2222
const [inRoom, setInRoom] = useState(false);
23-
const ip = "localhost";
23+
const ip = process.env.REACT_APP_IP;
2424

2525
const id = useRef();
2626
const ws = useMemo(() => {
@@ -42,7 +42,7 @@ function AppelEleve({ callId }) {
4242
type: "call",
4343
},
4444
};
45-
ws.send(JSON.stringify(message));
45+
//ws.send(JSON.stringify(message));
4646
setInRoom(true);
4747
setCall(res.data);
4848
}
@@ -55,7 +55,9 @@ function AppelEleve({ callId }) {
5555
useEffect(() => {
5656
const handleOpen = async () => {
5757
if (user.status === "student") {
58-
await LogToExistingRoom();
58+
if (!inRoom) {
59+
await LogToExistingRoom();
60+
}
5961
}
6062

6163
if (inRoom) {
@@ -80,9 +82,14 @@ function AppelEleve({ callId }) {
8082
}
8183

8284
return () => {
83-
if (ws.readyState === WebSocket.OPEN) {
84-
ws.send({ type: "leaveRoom", data: { userID: user?.id, class: user?.class } });
85-
}
85+
/* if (ws.readyState === WebSocket.OPEN) {
86+
ws.send(
87+
JSON.stringify({
88+
type: "leaveRoom",
89+
data: { userID: user?.id, class: user?.class },
90+
})
91+
);
92+
} */
8693
};
8794
}, [LogToExistingRoom, inRoom, user.class, user?.id, user.status, ws]);
8895

client/src/components/callteacher/Callteacher.js

+36-21
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,36 @@ function AppelProf(callId) {
1515
});
1616
const { user } = useFirebase();
1717

18-
const ip = "localhost";
18+
const ip = process.env.REACT_APP_IP;
1919
const [users, setUsers] = useState([]);
2020
const [usersPresent, setUsersPresent] = useState([]);
2121
const [inRoom, setInRoom] = useState(false);
22-
const dataFetchedRef = useRef(false);
2322
const generated = useRef(false);
24-
const [tempCall, setTempCall] = useState({});
25-
2623
const ws = useMemo(() => {
2724
return new w3cwebsocket(`ws://${ip}:5050/call`);
2825
}, []);
2926

3027
const LogToExistingRoom = useCallback(async () => {
3128
try {
3229
axios
33-
.get(`http://localhost:5050/call/getRoomPo/${user?.id}`)
30+
.get(`http://localhost:5050/call/getRoomPo/${user?.id}`, {
31+
params: { callId: callId },
32+
})
3433
.then((res) => {
3534
if (res.data.length > 0) {
3635
const message = {
3736
type: "joinRoom",
3837
data: {
3938
userID: user?.id,
4039
name: user?.firstname,
41-
class: user?.class,
40+
class: res.data[0].class,
4241
type: "call",
4342
},
4443
};
45-
ws.send(JSON.stringify(message));
44+
console.log("sending");
45+
const msgToSend = JSON.stringify(message);
46+
ws.send(msgToSend);
4647
setInRoom(true);
47-
generated.current = true;
48-
setTempCall(res.data);
49-
setCall(res.data);
50-
setQrcode(res.data.qrcode);
5148
}
5249
});
5350
} catch (error) {
@@ -58,7 +55,9 @@ function AppelProf(callId) {
5855
useEffect(() => {
5956
const handleOpen = async () => {
6057
if (user.status === "po") {
61-
await LogToExistingRoom();
58+
if (!inRoom) {
59+
await LogToExistingRoom();
60+
}
6261
}
6362

6463
if (inRoom) {
@@ -67,7 +66,13 @@ function AppelProf(callId) {
6766

6867
switch (messageReceive.type) {
6968
case "updateRoom":
70-
setCall(messageReceive.appel);
69+
const keys = Object.keys(
70+
messageReceive.data.currentRoom.appel
71+
)[0];
72+
const appel = messageReceive.data.currentRoom.appel[keys].appel;
73+
setCall(appel);
74+
setQrcode(appel.qrcode);
75+
getUsers(appel.id_lesson);
7176
break;
7277
default:
7378
break;
@@ -83,12 +88,24 @@ function AppelProf(callId) {
8388
}
8489

8590
return () => {
86-
if (ws.readyState === WebSocket.OPEN) {
87-
ws.send({ type: "leaveRoom", data: { userID: user?.id, class: user?.class } });
88-
}
91+
/* if (ws.readyState === WebSocket.OPEN) {
92+
ws.send(
93+
JSON.stringify({
94+
type: "leaveRoom",
95+
data: { userID: user?.id, class: user?.class },
96+
})
97+
);
98+
} */
8999
};
90100
}, [LogToExistingRoom, call, inRoom, user.class, user.id, user.status, ws]);
91101

102+
const getUsers = (coursId) => {
103+
axios
104+
.get(`http://localhost:5050/call/getUsersFromClassiId/${coursId}`)
105+
.then((res) => {
106+
setUsers(res.data);
107+
});
108+
};
92109
useEffect(() => {
93110
if (generated.current) {
94111
setUsersPresent(call.student_scan);
@@ -105,9 +122,7 @@ function AppelProf(callId) {
105122

106123
return (
107124
<div className="ContentProf">
108-
<div className="Timer">
109-
<Timer />
110-
</div>
125+
<div className="Timer">{/* <Timer /> */}</div>
111126
<div className="ContentInfo">
112127
<div className="DivQr">
113128
<img src={qrcode} className="Qrcode" alt="" />
@@ -139,7 +154,7 @@ function AppelProf(callId) {
139154
<div className="DivChat">
140155
<h1>Chat</h1>
141156
<div className="Chat">
142-
{call.chats.map((chat) => {
157+
{/* {call.chats.map((chat) => {
143158
return (
144159
<div className="ChatContent">
145160
<div className="ChatContentHeader">
@@ -155,7 +170,7 @@ function AppelProf(callId) {
155170
</div>
156171
</div>
157172
);
158-
})}
173+
})} */}
159174
</div>
160175
</div>
161176
</div>

client/src/hooks/useFirebase.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const FirebaseContextProvider = ({ children }) => {
4242
const authUnsubscribe = onAuthStateChanged(auth, (user) => {
4343
if (user) {
4444
axios
45-
.post("http://localhost:5050/auth/login", {
45+
.post("http://10.160.33.226:5050/auth/login", {
4646
token: user?.accessToken,
4747
})
4848
.then((res) => {

client/src/pages/call/Call.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useParams } from "react-router-dom";
55
import useFirebase from "../../hooks/useFirebase";
66

77
function Appel() {
8-
const [admin, setAdmin] = useState(false);
98
const { user } = useFirebase();
109
const callId = useParams();
1110
const [generated, setGenerated] = useState(false);
@@ -14,13 +13,12 @@ function Appel() {
1413
console.log(callId.id);
1514
if (!generated) {
1615
setGenerated(true);
17-
user.status === "po" ? setAdmin(true) : setAdmin(false);
1816
}
1917
}, [callId.id, generated, user.status]);
2018

2119
return (
2220
<div>
23-
{admin ? (
21+
{user.status === "po" ? (
2422
<AppelProf callId={callId.id}></AppelProf>
2523
) : (
2624
<AppelEleve callId={callId.id}></AppelEleve>

client/src/pages/login/Login.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const Login = () => {
7171
const token = await loggedInUser.user.getIdToken();
7272

7373
await axios
74-
.post("http://localhost:5050/auth/login", {
74+
.post("http://10.160.33.226:5050/auth/login", {
7575
token,
7676
})
7777
.then(() => {
@@ -291,7 +291,7 @@ const Login = () => {
291291
<p className="text-sm font-medium text-center m-3 font-bold">
292292
Pas encore de compte ? Créez-en un{" "}
293293
<Link
294-
href="/inscription"
294+
href="/signup"
295295
sx={{
296296
color: "#7a52e1",
297297
textDecoration: "none",

0 commit comments

Comments
 (0)