diff --git a/Frontend/App.tsx b/Frontend/App.tsx index 9d786dc..a83d330 100644 --- a/Frontend/App.tsx +++ b/Frontend/App.tsx @@ -1,12 +1,12 @@ import { HashRouter, Routes, Route } from 'react-router-dom' -import MainPage from './src/pages/MainPage' -import GamePage from './src/pages/GamePage' -import { SearchPage } from './src/pages/SearchPage' -import SignUpPage from './src/pages/SignUp' -import SignInPage from './src/pages/SignIn' -import WishlistPage from './src/pages/WishlistPage' -import ProfilePage from './src/pages/ProfilePage' -import FriendsPage from './src/pages/FriendsPage' +import MainPage from './src/pages/MainPage/MainPage' +import GamePage from './src/pages/GamePage/GamePage' +import { SearchPage } from './src/pages/SearchPage/SearchPage' +import SignUpPage from './src/pages/SignIn&SignUp/SignUp' +import SignInPage from './src/pages/SignIn&SignUp/SignIn' +import WishlistPage from './src/pages/WishlistPage/WishlistPage' +import ProfilePage from './src/pages/ProfilePage/ProfilePage' +import FriendsPage from './src/pages/FriendsPage/FriendsPage' import ScrollManager from './src/components/ScrollManager' function App() { diff --git a/Frontend/src/css/ActiveGameCard.css b/Frontend/src/components/ActiveGameCard/ActiveGameCard.css similarity index 71% rename from Frontend/src/css/ActiveGameCard.css rename to Frontend/src/components/ActiveGameCard/ActiveGameCard.css index 659d7bd..a2efe63 100644 --- a/Frontend/src/css/ActiveGameCard.css +++ b/Frontend/src/components/ActiveGameCard/ActiveGameCard.css @@ -62,21 +62,13 @@ min-height: 0; } -.activeGameInfoContent.MuiCardContent-root, -.activeGameReviewsContent.MuiCardContent-root { +.activeGameInfoContent.MuiCardContent-root { display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem; } -.activeGameReviewsContent.MuiCardContent-root { - box-sizing: border-box; - flex: 1 1 0; - height: 100%; - min-height: 0; -} - .activeGameInfoHeader { display: flex; align-items: center; @@ -173,56 +165,6 @@ color: var(--primary-text-color); } -.activeGameReviewsHeader { - display: flex; - align-items: center; - justify-content: space-between; - gap: 1rem; -} - -.activeGameReviewsHeader .MuiTypography-root { - color: var(--primary-text-color); -} - -.activeGameScore { - margin: 0; - white-space: nowrap; -} - -.activeGameReviewsContent .reviewComposerToggle.MuiButton-root { - align-self: flex-start; - background-color: var(--primary-background-color); - color: var(--primary-text-color); - text-transform: none; -} - -.reviewComposerHint { - margin: -0.5rem 0 0; - color: var(--primary-text-color); - font-size: 0.9rem; -} - -.activeGameReviewList { - display: flex; - flex: 1 1 0; - flex-direction: column; - min-height: clamp(6rem, 28vh, 20rem); - gap: 0.65rem; - overflow-y: auto; - scrollbar-gutter: stable; -} - -.activeGameReviewList > .reviewCard { - flex: 0 0 auto; - box-shadow: none; -} - -.activeGameNoReviews { - margin: 0; - color: var(--primary-text-color); -} - -.activeGameReviewsContent .MuiDivider-root, .activeGameInfoContent .MuiDivider-root { width: 100%; border-color: rgb(0 0 0 / 20%); @@ -239,20 +181,9 @@ gap: 1rem; } - .activeGameInfoContent.MuiCardContent-root, - .activeGameReviewsContent.MuiCardContent-root { + .activeGameInfoContent.MuiCardContent-root { padding: 1.125rem; } - - .activeGameReviewsContent.MuiCardContent-root { - height: auto; - } - - .activeGameReviewList { - flex: 0 1 auto; - min-height: 0; - max-height: min(36rem, 70vh); - } } @media (max-width: 26rem) { diff --git a/Frontend/src/components/ActiveGameCard.tsx b/Frontend/src/components/ActiveGameCard/ActiveGameCard.tsx similarity index 95% rename from Frontend/src/components/ActiveGameCard.tsx rename to Frontend/src/components/ActiveGameCard/ActiveGameCard.tsx index daffab6..35b15c2 100644 --- a/Frontend/src/components/ActiveGameCard.tsx +++ b/Frontend/src/components/ActiveGameCard/ActiveGameCard.tsx @@ -1,22 +1,22 @@ import { Box, Button, Card, CardContent, CardMedia, Chip, Divider, Typography } from '@mui/material' -import '../css/ActiveGameCard.css' -import type { GameData } from '../types/Game' -import { GetSavedUser } from '../FrontendLogic/UserLogicFrontend' +import './ActiveGameCard.css' +import type { GameData } from '../../types/Game' +import { GetSavedUser } from '../../FrontendLogic/UserLogicFrontend' import { useState, useEffect } from 'react' import { RemoveFromWishlistFrontend, AddToWishlistFrontend, FetchWishlistFrontend -} from '../FrontendLogic/WishlistLogicFrontend' +} from '../../FrontendLogic/WishlistLogicFrontend' import { CreateReview, DeleteReview, GetReviewsForGame, UpdateReview -} from '../FrontendLogic/ReviewLogicFrontend' -import type { Review } from '../types/Review' -import Reviews from './Reviews' -import { UseAuth } from '../context/AuthContext' +} from '../../FrontendLogic/ReviewLogicFrontend' +import type { Review } from '../../types/Review' +import Reviews from '../Reviews/Reviews' +import { UseAuth } from '../../context/AuthContext' type ActiveGameCardProps = { game: GameData diff --git a/Frontend/src/css/Footer.css b/Frontend/src/components/Footer/Footer.css similarity index 100% rename from Frontend/src/css/Footer.css rename to Frontend/src/components/Footer/Footer.css diff --git a/Frontend/src/components/Footer.tsx b/Frontend/src/components/Footer/Footer.tsx similarity index 93% rename from Frontend/src/components/Footer.tsx rename to Frontend/src/components/Footer/Footer.tsx index 2d855ad..1042b37 100644 --- a/Frontend/src/components/Footer.tsx +++ b/Frontend/src/components/Footer/Footer.tsx @@ -1,5 +1,5 @@ -import '../css/Footer.css' -import gameStartLogo from '../assets/LogoGameStartTransparent.webp' +import './Footer.css' +import gameStartLogo from '../../assets/LogoGameStartTransparent.webp' import { Divider } from '@mui/material' export default function Footer() { diff --git a/Frontend/src/components/GenreGamesSection.tsx b/Frontend/src/components/GenreGamesSection.tsx index 83d1417..a369524 100644 --- a/Frontend/src/components/GenreGamesSection.tsx +++ b/Frontend/src/components/GenreGamesSection.tsx @@ -8,7 +8,7 @@ import { import { type CSSProperties, useEffect, useState } from 'react' import { Autocomplete, Button, TextField, useMediaQuery, Card } from '@mui/material' import type { PageGame } from '../types/Game' -import PassiveGameCard from './PassiveGameCard' +import PassiveGameCard from './PassiveGameCard/PassiveGameCard' import { Link } from 'react-router-dom' const NO_GAMES: PageGame[] = [] diff --git a/Frontend/src/css/Header.css b/Frontend/src/components/Header/Header.css similarity index 100% rename from Frontend/src/css/Header.css rename to Frontend/src/components/Header/Header.css diff --git a/Frontend/src/components/Header.tsx b/Frontend/src/components/Header/Header.tsx similarity index 96% rename from Frontend/src/components/Header.tsx rename to Frontend/src/components/Header/Header.tsx index eba5666..be6cc05 100644 --- a/Frontend/src/components/Header.tsx +++ b/Frontend/src/components/Header/Header.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react' import { Link, NavLink, useLocation } from 'react-router-dom' -import '../css/Header.css' +import './Header.css' import { House, UserRound, @@ -12,9 +12,9 @@ import { Menu, X } from 'lucide-react' -import gameStartLogo from '../assets/LogoGameStartTransparent.webp' +import gameStartLogo from '../../assets/LogoGameStartTransparent.webp' import Divider from '@mui/material/Divider' -import { UseAuth } from '../context/AuthContext' +import { UseAuth } from '../../context/AuthContext' export default function Header() { const { user, logout } = UseAuth() diff --git a/Frontend/src/css/PageHeading.css b/Frontend/src/components/PageHeading/PageHeading.css similarity index 100% rename from Frontend/src/css/PageHeading.css rename to Frontend/src/components/PageHeading/PageHeading.css diff --git a/Frontend/src/components/PageHeading.tsx b/Frontend/src/components/PageHeading/PageHeading.tsx similarity index 97% rename from Frontend/src/components/PageHeading.tsx rename to Frontend/src/components/PageHeading/PageHeading.tsx index e88d771..52170fb 100644 --- a/Frontend/src/components/PageHeading.tsx +++ b/Frontend/src/components/PageHeading/PageHeading.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react' import { ArrowLeft } from 'lucide-react' import { useNavigate } from 'react-router-dom' -import '../css/PageHeading.css' +import './PageHeading.css' type PageHeadingProps = { title: string diff --git a/Frontend/src/css/PassiveGameCard.css b/Frontend/src/components/PassiveGameCard/PassiveGameCard.css similarity index 100% rename from Frontend/src/css/PassiveGameCard.css rename to Frontend/src/components/PassiveGameCard/PassiveGameCard.css diff --git a/Frontend/src/components/PassiveGameCard.tsx b/Frontend/src/components/PassiveGameCard/PassiveGameCard.tsx similarity index 97% rename from Frontend/src/components/PassiveGameCard.tsx rename to Frontend/src/components/PassiveGameCard/PassiveGameCard.tsx index 697fc64..7e65127 100644 --- a/Frontend/src/components/PassiveGameCard.tsx +++ b/Frontend/src/components/PassiveGameCard/PassiveGameCard.tsx @@ -1,4 +1,4 @@ -import '../css/PassiveGameCard.css' +import './PassiveGameCard.css' import Card from '@mui/material/Card' import CardContent from '@mui/material/CardContent' import CardMedia from '@mui/material/CardMedia' @@ -6,7 +6,7 @@ import Typography from '@mui/material/Typography' import CardActionArea from '@mui/material/CardActionArea' import { Link } from 'react-router-dom' import { useLayoutEffect, useRef, useState } from 'react' -import type { PassiveGameData } from '../types/Game' +import type { PassiveGameData } from '../../types/Game' type Props = { game: PassiveGameData diff --git a/Frontend/src/css/EditProfile.css b/Frontend/src/components/ProfileEditor/EditProfile.css similarity index 100% rename from Frontend/src/css/EditProfile.css rename to Frontend/src/components/ProfileEditor/EditProfile.css diff --git a/Frontend/src/components/ProfileEditor.tsx b/Frontend/src/components/ProfileEditor/ProfileEditor.tsx similarity index 96% rename from Frontend/src/components/ProfileEditor.tsx rename to Frontend/src/components/ProfileEditor/ProfileEditor.tsx index f6780a1..bbda504 100644 --- a/Frontend/src/components/ProfileEditor.tsx +++ b/Frontend/src/components/ProfileEditor/ProfileEditor.tsx @@ -10,11 +10,11 @@ import { MenuItem, TextField } from '@mui/material' -import { FetchGameOptions, type GameOption } from '../FrontendLogic/ProfileLogicFrontend' -import { useDebouncedValue } from '../hooks/useDebouncedValue' -import type { Profile } from '../../../Backend/logic/ProfileLogicBackend' -import { SETUP_OPTIONS } from '../types/SetupOptions' -import '../css/EditProfile.css' +import { FetchGameOptions, type GameOption } from '../../FrontendLogic/ProfileLogicFrontend' +import { useDebouncedValue } from '../../hooks/useDebouncedValue' +import type { Profile } from '../../../../Backend/logic/ProfileLogicBackend' +import { SETUP_OPTIONS } from '../../types/SetupOptions' +import './EditProfile.css' const GAME_OPTIONS_PAGE_SIZE = 20 diff --git a/Frontend/src/css/RecentReviews.css b/Frontend/src/components/RecentReviews/RecentReviews.css similarity index 100% rename from Frontend/src/css/RecentReviews.css rename to Frontend/src/components/RecentReviews/RecentReviews.css diff --git a/Frontend/src/components/RecentReviews.tsx b/Frontend/src/components/RecentReviews/RecentReviews.tsx similarity index 95% rename from Frontend/src/components/RecentReviews.tsx rename to Frontend/src/components/RecentReviews/RecentReviews.tsx index 86cd6fd..c8c6bbb 100644 --- a/Frontend/src/components/RecentReviews.tsx +++ b/Frontend/src/components/RecentReviews/RecentReviews.tsx @@ -1,13 +1,13 @@ import { useLayoutEffect, useRef, useState } from 'react' import useMediaQuery from '@mui/material/useMediaQuery' -import ReviewCard from './ReviewCard' +import ReviewCard from '../ReviewCard/ReviewCard' import { Card } from '@mui/material' -import '../css/RecentReviews.css' +import './RecentReviews.css' import { GetSavedRecentReviewCount, SaveRecentReviewCount -} from '../FrontendLogic/MainPageLogicFrontend' -import type { Review } from '../types/Review' +} from '../../FrontendLogic/MainPageLogicFrontend' +import type { Review } from '../../types/Review' type RecentReviewsProps = { reviews: Review[] diff --git a/Frontend/src/css/Reviews.css b/Frontend/src/components/ReviewCard/ReviewCard.css similarity index 100% rename from Frontend/src/css/Reviews.css rename to Frontend/src/components/ReviewCard/ReviewCard.css diff --git a/Frontend/src/components/ReviewCard.tsx b/Frontend/src/components/ReviewCard/ReviewCard.tsx similarity index 98% rename from Frontend/src/components/ReviewCard.tsx rename to Frontend/src/components/ReviewCard/ReviewCard.tsx index 62f20b1..da842fa 100644 --- a/Frontend/src/components/ReviewCard.tsx +++ b/Frontend/src/components/ReviewCard/ReviewCard.tsx @@ -3,8 +3,8 @@ import { Link } from 'react-router-dom' import Button from '@mui/material/Button' import Rating from '@mui/material/Rating' import Typography from '@mui/material/Typography' -import '../css/Reviews.css' -import type { Review } from '../types/Review' +import './ReviewCard.css' +import type { Review } from '../../types/Review' type ReviewCardProps = { review: Review diff --git a/Frontend/src/css/ReviewComposer.css b/Frontend/src/components/ReviewComposer/ReviewComposer.css similarity index 88% rename from Frontend/src/css/ReviewComposer.css rename to Frontend/src/components/ReviewComposer/ReviewComposer.css index b3b12ba..5aa2f24 100644 --- a/Frontend/src/css/ReviewComposer.css +++ b/Frontend/src/components/ReviewComposer/ReviewComposer.css @@ -40,10 +40,3 @@ flex-wrap: wrap; gap: 0.5rem; } - -.reviewComposerError { - margin: 0; - color: var(--primary-text-color); - font-weight: 700; - overflow-wrap: anywhere; -} diff --git a/Frontend/src/components/ReviewComposer.tsx b/Frontend/src/components/ReviewComposer/ReviewComposer.tsx similarity index 98% rename from Frontend/src/components/ReviewComposer.tsx rename to Frontend/src/components/ReviewComposer/ReviewComposer.tsx index 77a097f..f502afe 100644 --- a/Frontend/src/components/ReviewComposer.tsx +++ b/Frontend/src/components/ReviewComposer/ReviewComposer.tsx @@ -3,7 +3,7 @@ import Button from '@mui/material/Button' import Rating from '@mui/material/Rating' import TextField from '@mui/material/TextField' import Typography from '@mui/material/Typography' -import '../css/ReviewComposer.css' +import './ReviewComposer.css' type ReviewComposerProps = { isEditing: boolean diff --git a/Frontend/src/components/Reviews/Reviews.css b/Frontend/src/components/Reviews/Reviews.css new file mode 100644 index 0000000..de5a440 --- /dev/null +++ b/Frontend/src/components/Reviews/Reviews.css @@ -0,0 +1,84 @@ +.activeGameReviewsContent.MuiCardContent-root { + display: flex; + box-sizing: border-box; + flex: 1 1 0; + flex-direction: column; + gap: 1rem; + height: 100%; + min-height: 0; + padding: 1.25rem; +} + +.activeGameReviewsHeader { + display: flex; + align-items: center; + justify-content: space-between; + gap: 1rem; +} + +.activeGameReviewsHeader .MuiTypography-root { + color: var(--primary-text-color); +} + +.activeGameScore { + margin: 0; + white-space: nowrap; +} + +.activeGameReviewsContent .reviewComposerToggle.MuiButton-root { + align-self: flex-start; + background-color: var(--primary-background-color); + color: var(--primary-text-color); + text-transform: none; +} + +.reviewComposerHint { + margin: -0.5rem 0 0; + color: var(--primary-text-color); + font-size: 0.9rem; +} + +.reviewComposerError { + margin: 0; + color: var(--primary-text-color); + font-weight: 700; + overflow-wrap: anywhere; +} + +.activeGameReviewsContent .MuiDivider-root { + width: 100%; + border-color: rgb(0 0 0 / 20%); +} + +.activeGameReviewList { + display: flex; + flex: 1 1 0; + flex-direction: column; + min-height: clamp(6rem, 28vh, 20rem); + gap: 0.65rem; + overflow-y: auto; + scrollbar-gutter: stable; +} + +.activeGameReviewList > .reviewCard { + flex: 0 0 auto; + box-shadow: none; +} + +.activeGameNoReviews { + margin: 0; + color: var(--primary-text-color); +} + +@media (max-width: 64rem) { + .activeGameReviewsContent.MuiCardContent-root { + height: auto; + padding: 1.125rem; + } + + .activeGameReviewList { + flex: 0 1 auto; + min-height: 0; + max-height: min(36rem, 70vh); + } +} diff --git a/Frontend/src/components/Reviews.tsx b/Frontend/src/components/Reviews/Reviews.tsx similarity index 96% rename from Frontend/src/components/Reviews.tsx rename to Frontend/src/components/Reviews/Reviews.tsx index 0bffd3d..1647fc8 100644 --- a/Frontend/src/components/Reviews.tsx +++ b/Frontend/src/components/Reviews/Reviews.tsx @@ -3,9 +3,10 @@ import Button from '@mui/material/Button' import CardContent from '@mui/material/CardContent' import Divider from '@mui/material/Divider' import Typography from '@mui/material/Typography' -import ReviewCard from './ReviewCard' -import ReviewComposer from './ReviewComposer' -import type { Review } from '../types/Review' +import ReviewCard from '../ReviewCard/ReviewCard' +import ReviewComposer from '../ReviewComposer/ReviewComposer' +import type { Review } from '../../types/Review' +import './Reviews.css' function GetAverageRating(reviews: Review[]): number | null { if (reviews.length === 0) return null diff --git a/Frontend/src/components/SearchPageResults.tsx b/Frontend/src/components/SearchPageResults.tsx index acc40f1..e0aebe7 100644 --- a/Frontend/src/components/SearchPageResults.tsx +++ b/Frontend/src/components/SearchPageResults.tsx @@ -1,7 +1,7 @@ import { memo } from 'react' import { Pagination } from '@mui/material' import type { Game } from '../../../Backend/Steam' -import PassiveGameCard from './PassiveGameCard' +import PassiveGameCard from './PassiveGameCard/PassiveGameCard' const SearchResultsGrid = memo(function SearchResultsGrid({ games }: { games: Game[] }) { return ( diff --git a/Frontend/src/components/TopGames.tsx b/Frontend/src/components/TopGames.tsx index 379efec..d7a06d6 100644 --- a/Frontend/src/components/TopGames.tsx +++ b/Frontend/src/components/TopGames.tsx @@ -1,6 +1,6 @@ import { Card } from '@mui/material' import type { PageGame } from '../types/Game' -import PassiveGameCard from './PassiveGameCard' +import PassiveGameCard from './PassiveGameCard/PassiveGameCard' interface TopGamesProps { loading: boolean diff --git a/Frontend/src/css/UserReviews.css b/Frontend/src/components/UserReviews/UserReviews.css similarity index 79% rename from Frontend/src/css/UserReviews.css rename to Frontend/src/components/UserReviews/UserReviews.css index 79e391b..28948da 100644 --- a/Frontend/src/css/UserReviews.css +++ b/Frontend/src/components/UserReviews/UserReviews.css @@ -30,3 +30,10 @@ gap: 1rem; min-width: 0; } + +.reviewComposerError { + margin: 0; + color: var(--primary-text-color); + font-weight: 700; + overflow-wrap: anywhere; +} diff --git a/Frontend/src/components/UserReviews.tsx b/Frontend/src/components/UserReviews/UserReviews.tsx similarity index 96% rename from Frontend/src/components/UserReviews.tsx rename to Frontend/src/components/UserReviews/UserReviews.tsx index 471701c..fb78594 100644 --- a/Frontend/src/components/UserReviews.tsx +++ b/Frontend/src/components/UserReviews/UserReviews.tsx @@ -4,17 +4,17 @@ import CardContent from '@mui/material/CardContent' import Divider from '@mui/material/Divider' import Pagination from '@mui/material/Pagination' import useMediaQuery from '@mui/material/useMediaQuery' -import ReviewCard from './ReviewCard' -import ReviewComposer from './ReviewComposer' -import '../css/UserReviews.css' +import ReviewCard from '../ReviewCard/ReviewCard' +import ReviewComposer from '../ReviewComposer/ReviewComposer' +import './UserReviews.css' import { DeleteReview, GetReviewsByUser, UpdateReview, USER_REVIEWS_PER_PAGE, type UserReviewPage -} from '../FrontendLogic/ReviewLogicFrontend' -import type { Review } from '../types/Review' +} from '../../FrontendLogic/ReviewLogicFrontend' +import type { Review } from '../../types/Review' type UserReviewsProps = { userId: number diff --git a/Frontend/src/css/WishlistGameCard.css b/Frontend/src/components/WishlistGameCard/WishlistGameCard.css similarity index 100% rename from Frontend/src/css/WishlistGameCard.css rename to Frontend/src/components/WishlistGameCard/WishlistGameCard.css diff --git a/Frontend/src/components/WishlistGameCard.tsx b/Frontend/src/components/WishlistGameCard/WishlistGameCard.tsx similarity index 91% rename from Frontend/src/components/WishlistGameCard.tsx rename to Frontend/src/components/WishlistGameCard/WishlistGameCard.tsx index ce323b9..805ba5c 100644 --- a/Frontend/src/components/WishlistGameCard.tsx +++ b/Frontend/src/components/WishlistGameCard/WishlistGameCard.tsx @@ -1,8 +1,8 @@ import { Card, CardMedia, Chip, Button } from '@mui/material' -import '../css/WishlistGameCard.css' -import type { PassiveGameData } from '../types/Game' -import { RemoveFromWishlistFrontend } from '../FrontendLogic/WishlistLogicFrontend' -import { GetSavedUser } from '../FrontendLogic/UserLogicFrontend' +import './WishlistGameCard.css' +import type { PassiveGameData } from '../../types/Game' +import { RemoveFromWishlistFrontend } from '../../FrontendLogic/WishlistLogicFrontend' +import { GetSavedUser } from '../../FrontendLogic/UserLogicFrontend' import { useState } from 'react' import { Link } from 'react-router-dom' diff --git a/Frontend/src/css/CreateAccountPage.css b/Frontend/src/css/CreateAccountPage.css deleted file mode 100644 index 763ecba..0000000 --- a/Frontend/src/css/CreateAccountPage.css +++ /dev/null @@ -1,15 +0,0 @@ -#createAccountPageTitle { - justify-items: center; -} - -#formBox { - display: flex; - flex-direction: column; - align-items: center; - justify-self: center; - gap: 30px; - width: 40%; - border: 1px solid black; - border-radius: 12px; - padding: 24px; -} diff --git a/Frontend/src/css/LoginPage.css b/Frontend/src/css/LoginPage.css deleted file mode 100644 index 653b0cf..0000000 --- a/Frontend/src/css/LoginPage.css +++ /dev/null @@ -1,15 +0,0 @@ -#loginPageTitle { - justify-items: center; -} - -#loginBox { - display: flex; - flex-direction: column; - align-items: center; - justify-self: center; - gap: 30px; - width: 40%; - border: 1px solid black; - border-radius: 12px; - padding: 24px; -} diff --git a/Frontend/src/hooks/useDocumentTitle.ts b/Frontend/src/hooks/useDocumentTitle.ts new file mode 100644 index 0000000..d7fc6cc --- /dev/null +++ b/Frontend/src/hooks/useDocumentTitle.ts @@ -0,0 +1,7 @@ +import { useEffect } from 'react' + +export function useDocumentTitle(title: string) { + useEffect(() => { + document.title = `${title}` + }, [title]) +} diff --git a/Frontend/src/css/FriendsPage.css b/Frontend/src/pages/FriendsPage/FriendsPage.css similarity index 100% rename from Frontend/src/css/FriendsPage.css rename to Frontend/src/pages/FriendsPage/FriendsPage.css diff --git a/Frontend/src/pages/FriendsPage.tsx b/Frontend/src/pages/FriendsPage/FriendsPage.tsx similarity index 95% rename from Frontend/src/pages/FriendsPage.tsx rename to Frontend/src/pages/FriendsPage/FriendsPage.tsx index 14a97d9..fcab0af 100644 --- a/Frontend/src/pages/FriendsPage.tsx +++ b/Frontend/src/pages/FriendsPage/FriendsPage.tsx @@ -1,6 +1,6 @@ -import Footer from '../components/Footer' -import Header from '../components/Header' -import PageHeading from '../components/PageHeading' +import Footer from '../../components/Footer/Footer' +import Header from '../../components/Header/Header' +import PageHeading from '../../components/PageHeading/PageHeading' import { Autocomplete, Button, @@ -12,20 +12,21 @@ import { TextField } from '@mui/material' import { useEffect, useMemo, useState } from 'react' -import '../css/FriendsPage.css' -import WishlistGameCard from '../components/WishlistGameCard' -import type { Game } from '../../../Backend/Steam' +import { useDocumentTitle } from '../../hooks/useDocumentTitle.ts' +import './FriendsPage.css' +import WishlistGameCard from '../../components/WishlistGameCard/WishlistGameCard' +import type { Game } from '../../../../Backend/Steam' import { AddFriend, GetFriends, GetFriendWishlist, GetMyFriendId, type Friend -} from '../FrontendLogic/FriendLogicFrontend' -import { UseAuth } from '../context/AuthContext' -import ProfileCard from '../components/ProfileCard' -import type { Profile } from '../../../Backend/logic/ProfileLogicBackend' -import type { GameOption } from '../FrontendLogic/ProfileLogicFrontend' +} from '../../FrontendLogic/FriendLogicFrontend' +import { UseAuth } from '../../context/AuthContext' +import ProfileCard from '../../components/ProfileCard' +import type { Profile } from '../../../../Backend/logic/ProfileLogicBackend' +import type { GameOption } from '../../FrontendLogic/ProfileLogicFrontend' const GAMES_PER_PAGE = 5 const NO_GAMES: Game[] = [] @@ -65,9 +66,12 @@ export default function FriendPage() { games: Game[] error: string | null }>({ key: null, games: [], error: null }) + const [page, setPage] = useState(1) const [reloadKey, setReloadKey] = useState(0) + useDocumentTitle('Friends') + useEffect(() => { if (!user) return undefined let cancelled = false diff --git a/Frontend/src/css/GamePage.css b/Frontend/src/pages/GamePage/GamePage.css similarity index 100% rename from Frontend/src/css/GamePage.css rename to Frontend/src/pages/GamePage/GamePage.css diff --git a/Frontend/src/pages/GamePage.tsx b/Frontend/src/pages/GamePage/GamePage.tsx similarity index 87% rename from Frontend/src/pages/GamePage.tsx rename to Frontend/src/pages/GamePage/GamePage.tsx index 8a1fa81..ac3f5f0 100644 --- a/Frontend/src/pages/GamePage.tsx +++ b/Frontend/src/pages/GamePage/GamePage.tsx @@ -1,12 +1,13 @@ -import '../css/GamePage.css' -import Header from '../components/Header' -import Footer from '../components/Footer' -import ActiveGameCard from '../components/ActiveGameCard' +import './GamePage.css' +import Header from '../../components/Header/Header.tsx' +import Footer from '../../components/Footer/Footer.tsx' +import { useDocumentTitle } from '../../hooks/useDocumentTitle.ts' +import ActiveGameCard from '../../components/ActiveGameCard/ActiveGameCard.tsx' import { useParams } from 'react-router-dom' -import PageHeading from '../components/PageHeading' +import PageHeading from '../../components/PageHeading/PageHeading' import { useEffect, useState } from 'react' -import { GetGameById } from '../FrontendLogic/GameLogicFrontend' -import type { Game } from '../../../Backend/Steam' +import { GetGameById } from '../../FrontendLogic/GameLogicFrontend' +import type { Game } from '../../../../Backend/Steam' export default function GamePage() { const { gameId } = useParams() @@ -37,7 +38,6 @@ export default function GamePage() { }) } }) - return () => { cancelled = true } @@ -56,6 +56,9 @@ export default function GamePage() { .map((genre) => genre.trim()) .filter(Boolean) : [] + + useDocumentTitle(game?.name + 'game page') + return (