-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHome.js
More file actions
94 lines (89 loc) · 3.2 KB
/
Copy pathHome.js
File metadata and controls
94 lines (89 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import React, { useState } from 'react';
import { v4 as uuidV4 } from 'uuid';
import toast from 'react-hot-toast';
import { useNavigate } from 'react-router-dom';
const Home = () => {
const navigate = useNavigate();
const [roomId, setRoomId] = useState('');
const [username, setUsername] = useState('');
const createNewRoom = (e) => {
e.preventDefault();
const id = uuidV4();
setRoomId(id);
toast.success('Created a new room ID');
};
const joinRoom = () => {
if (!roomId || !username) {
toast.error('ROOM ID & username is required');
return;
}
navigate(`/editor/${roomId}`, {
state: {
username,
},
});
};
const handleInputEnter = (e) => {
if (e.code === 'Enter') {
joinRoom();
}
};
return (
<div className="homePageWrapper">
<div className="formWrapper">
<img
className="homePageLogo"
src="/code-sync.jpeg"
alt="code-sync-logo"
/>
<h4 className="mainLabel">Paste invitation ROOM ID</h4>
<div className="inputGroup">
<input
type="text"
className="inputBox"
placeholder="ROOM ID"
onChange={(e) => setRoomId(e.target.value)}
value={roomId}
onKeyUp={handleInputEnter}
/>
<input
type="text"
className="inputBox"
placeholder="USERNAME"
onChange={(e) => setUsername(e.target.value)}
value={username}
onKeyUp={handleInputEnter}
/>
<button className="btn joinBtn" onClick={joinRoom}>
Join
</button>
<span className="createInfo">
If you don't have an invite then create
<a
onClick={createNewRoom}
href=""
className="createNewBtn"
>
new room
</a>
</span>
</div>
</div>
<footer>
{/* <div>
<h4>
Built under guidance by
<a href="https://vcet.edu.in" className='createNewBtn'>VCET</a>
</h4>
</div> */}
<div>
<h4>
Please leave a Feedback
<a href="javascript:void( window.open( 'https://form.jotform.com/223099732790464', 'blank', 'scrollbars=yes, toolbar=no, width=700, height=500' ) ) " className='createNewBtn'> here </a>
</h4>
</div>
</footer>
</div>
);
};
export default Home;