-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #215 from bounswe/practice-app/feature/game-platforms
Practice app/feature/game platforms
- Loading branch information
Showing
15 changed files
with
1,047 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { useState } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import axios from 'axios'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import TextField from '@mui/material/TextField'; | ||
import Button from '@mui/material/Button'; | ||
import Snackbar from '@mui/material/Snackbar'; | ||
|
||
const SubmitPlatform = () => { | ||
const [keyword, setKeyword] = useState(''); | ||
const [open, setOpen] = useState(false); | ||
const [message, setMessage] = useState(''); | ||
const handleSubmit = async () => { | ||
try { | ||
if (localStorage.getItem("accessToken")) { | ||
|
||
const response = await axios.post('http://localhost:8080/api/game-platform/platform?title=' + keyword,{} ,{ | ||
headers: { | ||
"Authorization": localStorage.getItem("accessToken"), | ||
}, | ||
}); | ||
if (response.status==200) { | ||
setMessage('Submission successful'); | ||
setOpen(true); | ||
} else { | ||
setMessage('Submission failed'); | ||
setOpen(true); | ||
} | ||
} | ||
} catch (error) { | ||
setMessage('An error occurred'); | ||
setOpen(true); | ||
} | ||
}; | ||
|
||
const handleClose = () => { | ||
setOpen(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
minHeight: '85vh', | ||
padding: '2rem', | ||
color: 'dark grey', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
backgroundColor: 'rgba(0, 0, 0, 0.7)', | ||
padding: '1rem', | ||
borderRadius: '10px', | ||
marginBottom: '1rem', | ||
}} | ||
> | ||
<Typography | ||
variant="h4" | ||
component="p" | ||
gutterBottom | ||
sx={{ | ||
textAlign: 'center', | ||
color: 'white', | ||
fontFamily: 'Trebuchet MS', | ||
}} | ||
> | ||
SUBMIT THE PLATFORM | ||
</Typography> | ||
|
||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: '1rem', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<TextField | ||
sx={{ | ||
label: { color: 'white', fontFamily: 'Trebuchet MS' }, | ||
}} | ||
id="outlined-basic" | ||
label="Give Your Keyword" | ||
variant="outlined" | ||
value={keyword} | ||
onChange={(event) => setKeyword(event.target.value)} | ||
/> | ||
<Button | ||
variant="contained" | ||
sx={{ | ||
backgroundColor: '#424242', | ||
color: '#FFFFFF', | ||
minWidth: '200px', | ||
fontFamily: 'Trebuchet MS', | ||
}} | ||
onClick={handleSubmit} | ||
> | ||
Add | ||
</Button> | ||
</Box> | ||
</Box> | ||
</Box> | ||
|
||
<Snackbar open={open} autoHideDuration={3000} onClose={handleClose} message={message} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default SubmitPlatform; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import Button from '@mui/material/Button'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
|
||
|
||
|
||
|
||
|
||
const PlatformMainPage = () => { | ||
return ( | ||
|
||
<> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
minHeight: '85vh', | ||
padding: '2rem', | ||
color: 'dark grey', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
backgroundColor: 'rgba(0, 0, 0, 0.7)', | ||
padding: '1rem', | ||
borderRadius: '10px', | ||
marginBottom: '1rem', | ||
}} | ||
> | ||
<Typography variant="h4" component="p" gutterBottom sx={{ textAlign: 'center', color: "white", fontFamily: "Trebuchet MS" }}> | ||
You Can Do These | ||
</Typography> | ||
|
||
<Box | ||
sx={{ | ||
display: 'flex', | ||
gap: '1rem', | ||
justifyContent: 'center', | ||
marginBottom: '1rem', | ||
}} | ||
> | ||
<Button | ||
variant="contained" | ||
component={Link} | ||
to="/game-platform/search" | ||
sx={{ backgroundColor: '#424242', color: '#FFFFFF' , minWidth: '260px', fontFamily: "Trebuchet MS"}} | ||
> | ||
Search A Game's Platform | ||
</Button> | ||
<Button | ||
variant="contained" | ||
component={Link} | ||
to="/game-platform/add_platforms" | ||
sx={{ backgroundColor: '#424242', color: '#FFFFFF', minWidth: '260px', fontFamily: "Trebuchet MS"}} | ||
> | ||
Add Your Platform | ||
</Button> | ||
</Box> | ||
|
||
|
||
|
||
</Box> | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
export default PlatformMainPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import Button from '@mui/material/Button'; | ||
import Box from '@mui/material/Box'; | ||
import Typography from '@mui/material/Typography'; | ||
import { useLocation, BrowserRouter as Router, Switch, Route } from 'react-router-dom'; | ||
import axios from 'axios'; | ||
import PlatformInfo from "./platform_info"; | ||
|
||
const ListGames = () => { | ||
|
||
const location = useLocation(); | ||
|
||
const [data, setData] = React.useState(null); | ||
|
||
const handleClick = (id) => { | ||
const link="http://localhost:8080/api/game-platform/game?id="+id; | ||
axios | ||
.get(link, { | ||
headers: { | ||
Authorization: localStorage.getItem("accessToken"), | ||
}, | ||
}) | ||
.then((response) => { | ||
setData(response.data); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
minHeight: '85vh', | ||
padding: '2rem', | ||
color: 'dark grey', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
backgroundColor: 'rgba(255, 255, 255, 0.4)', | ||
padding: '1rem', | ||
borderRadius: '10px', | ||
marginBottom: '1rem', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
{location.state.games.map((game, index) => ( | ||
<Button | ||
sx={{ | ||
backgroundColor: "#424242", | ||
padding: '1rem', | ||
borderRadius: '10px', | ||
marginBottom: '1rem', | ||
color: '#FFFFFF', | ||
width: '280px' | ||
}} | ||
key={index} | ||
onClick={() => handleClick(game.game_id)} | ||
> | ||
{game.title} | ||
</Button> | ||
))} | ||
{data && <PlatformInfo data={data} />} | ||
</Box> | ||
</Box> | ||
</div> | ||
); | ||
} | ||
|
||
export default ListGames; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from "react"; | ||
import Box from '@mui/material/Box'; | ||
|
||
function PlatformInfo({ data }) { | ||
console.log(data); | ||
return ( | ||
|
||
<div> | ||
<h2>{data.message} The Platforms Where You Can Play This Game:</h2> | ||
{data.platforms.map((platform, index) => ( | ||
<div key={index}> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
minHeight: '5px', | ||
padding: '2rem', | ||
color: 'dark grey', | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
padding: '2rem', | ||
color: 'dark grey', | ||
backgroundColor:'rgba(0, 0, 0, 0.4)', | ||
}}> | ||
{platform.platform_name} | ||
</Box> | ||
</Box> | ||
|
||
{/* vb. */} | ||
</div> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default PlatformInfo; |
Oops, something went wrong.