Init game page

This commit is contained in:
2024-05-12 13:12:13 +04:00
parent 275d99bd85
commit 15247adfa3
9 changed files with 88 additions and 12 deletions

View File

@@ -0,0 +1,48 @@
import { GameService } from "@/entities/game";
import { GameCard } from "@/features/gameCard";
import { Section } from "@/widgets/section";
import Image from "next/image";
export default async function Games({
params: { game_id },
}: {
params: { game_id: number };
}) {
const gameCards = await GameService.getGameCards();
const game = await GameService.getGame(game_id);
return (
<>
{game && (
<div className="p-4 flex flex-col lp:flex-row">
{game.cover && (
<Image
src={game.cover}
className="rounded-lg w-[60%] aspect-video object-cover"
alt=""
width={1280}
height={720}
/>
)}
<div className="pt-2 max-w-[40%]">
<h1 className="text-4xl">{game.title}</h1>
<p className="text-md text-justify text-fg4 pt-2">
{game.description}
</p>
</div>
</div>
)}
{gameCards && (
<Section
name="Другие популярные игры"
link="/games"
invite_text={'Перейти в раздел "Игры"'}
>
{gameCards.map((card) => (
<GameCard key={card.id} card={card} />
))}
</Section>
)}
</>
);
}

View File

@@ -9,10 +9,10 @@ export const metadata: Metadata = {
".Torrent: Игры - каталог .torrent файлов для обмена видеоиграми",
};
export default async function Home() {
export default async function Games() {
const gameCards = await GameService.getGameCards();
return (
<div className="w-full h-full max-w-[var(--app-width)] m-auto overflow-y-auto">
<>
{gameCards && (
<Section>
{gameCards.map((card) => (
@@ -20,6 +20,6 @@ export default async function Home() {
))}
</Section>
)}
</div>
</>
);
}

View File

@@ -23,7 +23,9 @@ export default function RootLayout({
<body className={inter.className}>
<ThemeProvider enableSystem={false} defaultTheme="light">
<Header />
{children}
<div className="w-full h-full max-w-[var(--app-width)] m-auto overflow-y-auto">
{children}
</div>
</ThemeProvider>
</body>
</html>

View File

@@ -5,7 +5,7 @@ import { Section } from "@/widgets/section";
export default async function Home() {
const gameCards = await GameService.getGameCards();
return (
<div className="w-full h-full max-w-[var(--app-width)] m-auto overflow-y-auto">
<>
{gameCards && (
<Section
name="Игры"
@@ -17,6 +17,6 @@ export default async function Home() {
))}
</Section>
)}
</div>
</>
);
}