Skip to content

Commit d969ff4

Browse files
committed
Full features implementation
1 parent 439b51c commit d969ff4

File tree

6 files changed

+70
-3
lines changed

6 files changed

+70
-3
lines changed

frontend/src/components/HomePage.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
22
import RoomJoinPage from "./RoomJoinPage";
33
import CreateRoomPage from "./CreateRoomPage";
44
import Room from "./Room";
5+
import Info from "./Info";
56
import { BrowserRouter as Router, Switch, Route, Redirect, Link } from "react-router-dom";
67
import { Grid, Button, ButtonGroup, Typography } from '@material-ui/core'
78

@@ -37,6 +38,7 @@ export default class HomePage extends Component {
3738
<Grid item xs={12} align="center">
3839
<ButtonGroup disableElevation variant="contained" color="primary">
3940
<Button color="primary" to="/join" component={Link}>Join a Room</Button>
41+
<Button color="default" to="/info" component={Link}>Info</Button>
4042
<Button color="secondary" to="/create" component={Link}>Create a Room</Button>
4143
</ButtonGroup>
4244
</Grid>
@@ -55,6 +57,7 @@ export default class HomePage extends Component {
5557
<Route path="/room/:RoomCode" render={(props) => {
5658
return <Room {...props} leaveRoomCallback={this.clearRoomCode} />;
5759
}}/>
60+
<Route path="/info" component={Info}/>
5861
</Switch>
5962
</Router>
6063
)

frontend/src/components/Info.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React, { useState, useEffect } from 'react';
2+
import { Grid, Button, Typography, IconButton } from '@material-ui/core';
3+
import NavigateBeforeIcon from '@material-ui/icons/NavigateBefore';
4+
import NavigateNextIcon from '@material-ui/icons/NavigateNext';
5+
import { Link } from 'react-router-dom';
6+
7+
const pages = {
8+
JOIN: "pages.join",
9+
CREATE: "pages.create",
10+
};
11+
12+
// testing functional components functions
13+
export default function Info(props) {
14+
const [page, setPage] = useState(pages.JOIN);
15+
function joinInfo() {
16+
return "Join a Room with your friends using their code or link,\n" +
17+
" but dont forget you should have a valid Spotify account";
18+
}
19+
function createInfo() {
20+
return "Create a room and let your friends listen to the same music as you,\n" +
21+
"you can set their permissions and how many votes need to skip a song";
22+
}
23+
useEffect(() => {
24+
console.log("rodou")
25+
return () => console.log("limpou");
26+
})
27+
return (
28+
<Grid container spacing={1}>
29+
<Grid item xs={12} align="center">
30+
<Typography component="h4" variant="h4">
31+
What is spotify controller?
32+
</Typography>
33+
</Grid>
34+
<Grid item xs={12} align="center">
35+
<Typography variant="body1">
36+
{ page === pages.JOIN ? joinInfo() : createInfo() }
37+
</Typography>
38+
</Grid>
39+
<Grid item xs={12} align="center">
40+
<IconButton onClick={() => {page === pages.CREATE ? setPage(pages.JOIN) : setPage(pages.CREATE)}}>
41+
{page === pages.CREATE ? ( <NavigateBeforeIcon/>) : (<NavigateNextIcon/>)}
42+
</IconButton>
43+
</Grid>
44+
<Grid item xs={12} align="center">
45+
<Button color="secondary" variant="contained" to="/" component={Link}>
46+
Back
47+
</Button>
48+
</Grid>
49+
</Grid>
50+
)
51+
}

frontend/src/components/Room.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
22
import { Grid, Button, Typography } from '@material-ui/core';
33
import CreateRoomPage from "./CreateRoomPage";
44
import MusicPlayer from "./MusicPlayer";
5+
import {Link} from "react-router-dom";
56

67

78
export default class Room extends Component {
@@ -87,7 +88,6 @@ export default class Room extends Component {
8788
};
8889
fetch('/api/leave-room/', requestOptions).then((_response) => {
8990
this.props.leaveRoomCallback();
90-
this.props.history.push("/");
9191
});
9292
}
9393
updateShowSetting(value) {
@@ -139,7 +139,7 @@ export default class Room extends Component {
139139
<MusicPlayer {...this.state.song}/>
140140
{this.state.is_host ? this.renderSettingsButton() : null}
141141
<Grid item xs={12} align="center">
142-
<Button variant="contained" color="secondary" onClick={this.leaveButtonPressed}>
142+
<Button variant="contained" color="secondary" onClick={this.leaveButtonPressed} to="/" component={Link}>
143143
Leave Room
144144
</Button>
145145
</Grid>

frontend/static/frontend/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/static/frontend/main.js.LICENSE.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
!*** ./src/components/app.js ***!
77
\*******************************/
88

9+
/*!********************************!*\
10+
!*** ./src/components/Info.js ***!
11+
\********************************/
12+
913
/*!********************************!*\
1014
!*** ./src/components/Room.js ***!
1115
\********************************/
@@ -142,6 +146,10 @@
142146
!*** ../node_modules/@material-ui/core/esm/Menu/Menu.js ***!
143147
\**********************************************************/
144148

149+
/*!**********************************************************!*\
150+
!*** ../node_modules/@material-ui/icons/NavigateNext.js ***!
151+
\**********************************************************/
152+
145153
/*!**********************************************************!*\
146154
!*** ../node_modules/@material-ui/system/esm/memoize.js ***!
147155
\**********************************************************/
@@ -198,6 +206,10 @@
198206
!*** ../node_modules/@material-ui/core/esm/utils/index.js ***!
199207
\************************************************************/
200208

209+
/*!************************************************************!*\
210+
!*** ../node_modules/@material-ui/icons/NavigateBefore.js ***!
211+
\************************************************************/
212+
201213
/*!************************************************************!*\
202214
!*** ../node_modules/react-transition-group/esm/config.js ***!
203215
\************************************************************/

frontend/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
path('join/', index),
1010
path('create/', index),
1111
path('room/<str:RoomCode>', index),
12+
path('info/', index),
1213
]

0 commit comments

Comments
 (0)