Skip to content

Commit

Permalink
Merge pull request #91 from HarrisSte/results-fix
Browse files Browse the repository at this point in the history
working on results page rendering
  • Loading branch information
HarrisSte committed Aug 29, 2023
2 parents 3571a72 + e5db2a8 commit 9835d4c
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 6 deletions.
Binary file added client/src/assets/results-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 49 additions & 2 deletions client/src/components/Results.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { useParams } from 'react-router-dom';

const Results = (props) => {

const { gameId } = useParams();

return (
<div className="results-container">
<ul>
Expand All @@ -11,7 +14,7 @@ const Results = (props) => {
<li key={game.id}>

<Link to={{
pathname: `/game/${game.name}`,
pathname: `/game/${gameId}`,
gameProps:{
game: game
}
Expand All @@ -28,4 +31,48 @@ const Results = (props) => {
);
}

export default Results;
export default Results;

// import { useParams } from 'react-router-dom';
// import { useEffect, useState } from 'react';
// import ResultsPage from '../pages/Results/ResultsPage'
// import ResultsBackground from '../assets/results-background.png'

// const Results = () => {

// const { gameId } = useParams();

// useEffect(() => {
// fetchGame();
// }, []);

// const [game, setGame] = useState([]);

// const fetchGame = async () => {
// await fetch(
// `https://api.rawg.io/api/games/${gameId}?key=bf22dc51e531456db8bc42a19dac9897`
// )
// .then((resp) => resp.json())
// .then((results) => setGame(results));
// };

// return (
// <div
// className='results'
// style={{
// width: '100%',
// minHeight: '100vh',
// backgroundImage: `url(${ResultsBackground})`,
// backgroundSize: 'cover',
// backgroundPosition: 'center',
// overflow: 'hidden',
// }}
// >
// <div className='results-info'>
// <ResultsPage game={game} />
// </div>
// </div>
// );
// }

// export default Results;
2 changes: 1 addition & 1 deletion client/src/components/Search.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import Results from './Results';
import { BsSearchHeart } from "react-icons/bs";

Expand Down
3 changes: 1 addition & 2 deletions client/src/components/SingleGame/GameDetails.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import Container from 'react-bootstrap/Container';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
Expand Down Expand Up @@ -65,4 +64,4 @@ const GamePage = (props) => {
);
};

export default GamePage;
export default GamePage;
42 changes: 42 additions & 0 deletions client/src/pages/Results/ResultsPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Results from '../../components/Results';
import { useParams } from 'react-router-dom';
import { useEffect, useState } from 'react';
import ResultsBackground from '../../assets/results-background.png';

const GameResults = () => {
const { gameId } = useParams();

useEffect(() => {
fetchGame();
}, []);

const [game, setGame] = useState([]);

const fetchGame = async () => {
await fetch(
`https://api.rawg.io/api/games/${gameId}?key=bf22dc51e531456db8bc42a19dac9897`
)
.then((resp) => resp.json())
.then((results) => setGame(results));
};

return (
<div
className='results'
style={{
width: '100%',
minHeight: '100vh',
backgroundImage: `url(${ResultsBackground})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
overflow: 'hidden',
}}
>
<div className='game-info'>
<Results game={game} />
</div>
</div>
);
};

export default GameResults;
Empty file.
2 changes: 1 addition & 1 deletion client/src/pages/SingleGame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ const SingleGame = () => {
);
};

export default SingleGame;
export default SingleGame;

0 comments on commit 9835d4c

Please sign in to comment.