Skip to content

Commit

Permalink
Added toast and route to Editors page
Browse files Browse the repository at this point in the history
  • Loading branch information
GameOver2811 committed Oct 31, 2023
1 parent db65c2c commit 87d5d91
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 8 deletions.
24 changes: 24 additions & 0 deletions developer-dash/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions developer-dash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-router-dom": "^6.17.0",
"react-scripts": "5.0.1",
"uuid": "^9.0.1",
Expand Down
29 changes: 22 additions & 7 deletions developer-dash/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@ import logo from './logo.svg';
import './App.css';
import { BrowserRouter,Route,Routes } from 'react-router-dom';
import EditorPage from './Components/EditorPage';
import { Toaster } from 'react-hot-toast';
import RoomID from './Components/RoomID';

function App() {
return (

<BrowserRouter>
<>
<div>
<Toaster
position="top-right"
toastOptions={{
success: {
theme: {
primary: '#4aed88',
},
},
}}
></Toaster>
</div>

<BrowserRouter>

<Routes>
<Routes>

<Route path='/' element={<RoomID/>}></Route>
<Route path='/editor/:roomId' element={<EditorPage/>}></Route>
<Route path='/' element={<RoomID/>}></Route>
<Route path='/editor/:roomId' element={<EditorPage/>}></Route>

</Routes>
</Routes>

</BrowserRouter>
</BrowserRouter>
</>

);
}
Expand Down
24 changes: 23 additions & 1 deletion developer-dash/src/Components/RoomID.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { useState } from 'react';
import toast from 'react-hot-toast';
import { useNavigate } from 'react-router-dom';
import { v4 as uuidV4 } from 'uuid';


Expand All @@ -10,7 +12,27 @@ export default function RoomID() {
e.preventDefault();
const id = uuidV4();
setRoomId(id);
toast.success("Created new room");
};


const navigate = useNavigate();

const joinRoom = () => {
if (!roomId || !username) {
toast.error('ROOM ID & Username is required');
return;
}

// Redirect
navigate(`/editor/${roomId}`, {
state: {
username,
},
});

};

return (
<div className='home-page-wrapper'>
<div className='form-wrapper '>
Expand All @@ -21,7 +43,7 @@ export default function RoomID() {
<input type='text' className='input-box' value={username} onChange={(e) => setUsername(e.target.value)} placeholder='Name'/>
<input type='text' className='input-box' value={roomId} placeholder='Room ID' onChange={(e) => setRoomId(e.target.value)}/>
</div>
<button className='btn join-button'>Join Now</button>
<button className='btn join-button' onClick={joinRoom}>Join Now</button>
<br/>
<span className='create-info'>If you don't have an invite then create &nbsp;
<a onClick={createNewRoom} href='#'className='create-new-room' >new room</a>
Expand Down
8 changes: 8 additions & 0 deletions developer-dash/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ root.render(
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

// // Add this in node_modules/react-dom/index.js
// window.React1 = require('react');

// // Add this in your component file
// require('react-dom');
// window.React2 = require('react');
// console.log(window.React1 === window.React2);

0 comments on commit 87d5d91

Please sign in to comment.