Commit 848b8481 by Arjun Jhukal

updated the minor changes

parent d9843b6e
......@@ -28,10 +28,6 @@ export async function generateMetadata(props: { params: Promise<{ id: string }>
};
}
export default async function UserGameDetail(props: { params: Promise<{ id: string }> }) {
const { id } = await props.params;
const game = await getSingleGame(id);
return <ExclusiveGameDetail game={game} />;
export default async function UserGameDetail() {
return <ExclusiveGameDetail />;
}
import DashboardLayout from '@/components/layouts/DashboardLayout'
import ServerPrivate from '@/routes/ServerPrivate'
import Private from '@/routes/Private'
import React from 'react'
export default function PrivateUserLayout({ children }: { children: React.ReactNode }) {
return (
<ServerPrivate>
<Private>
<DashboardLayout>
{children}
</DashboardLayout>
</ServerPrivate>
</Private>
)
}
"use client";
import ScreenShotSlider from "@/components/molecules/Sliders/ScreenShotSlider";
import CustomLightGallery from "@/components/organism/LightGallery";
import ProtectedLink from "@/routes/ProtectedLink";
import { SingleGameResponse } from "@/types/game";
import { useGetSingleGameFormUserQuery } from "@/services/gameApi";
import { renderHTML } from "@/utils/RenderHTML";
import { Box } from "@mui/material";
import Image from "next/image";
import { useParams } from "next/navigation";
import GameCredentialsBlock from "./GameCredentialsBlock";
import GameIframeDialog from "./GameIframeDialog";
import UserCoin from "./UserCoin";
export default function ExclusiveGameDetail({ game }: { game: SingleGameResponse }) {
export default function ExclusiveGameDetail() {
const { id } = useParams();
const { data: game } = useGetSingleGameFormUserQuery({ id: Number(id) }, { skip: !id });
if (!game) {
return;
}
return (
<>
<section className="detail__banner mb-8">
<div className="md:grid md:grid-cols-12 flex flex-col gap-8 lg:gap-20">
<div className="col-span-12 md:col-span-4">
<div className="aspect-[420/433] relative rounded-xl overflow-hidden mb-4">
<Image src={game?.data?.thumbnail || "/assets/images/fallback.png"} fill className="object-cover " alt={game?.data?.name} />
<Image src={game?.data?.thumbnail || "/assets/images/fallback.png"} fill className="object-cover " alt={game?.data?.name || ""} />
</div>
<GameCredentialsBlock game={game} />
</div>
......@@ -31,7 +36,7 @@ export default function ExclusiveGameDetail({ game }: { game: SingleGameResponse
</ul>
<div className="general-content-box styled-list !text-white">
<h1 className="text-[2rem]">{game?.data?.name}</h1>
{renderHTML(game?.data?.description)}
{renderHTML(game?.data?.description || "")}
</div>
<div className="action__group flex flex-col lg:grid lg:grid-cols-3 gap-2">
......
......@@ -3,25 +3,19 @@ import { cookies } from "next/headers";
import React from "react";
import ReduxHydrator from "./ReduxHydrator";
// function decodeJwt(token: string) {
// try {
// return JSON.parse(atob(token.split(".")[1]));
// } catch {
// return null;
// }
// }
export default async function ServerPrivate({ children }: { children: React.ReactNode }) {
const cookieStore = await cookies();
const access_token = cookieStore.get("access_token")?.value;
const user_cookie = cookieStore.get("user")?.value;
const user = user_cookie ? JSON.parse(user_cookie) : null;
if (!access_token||!user) return;
if (!access_token || !user) return;
return (
<>
{/* ✅ Hydrate Redux store on client */}
<ReduxHydrator token={access_token} user={user}/>
<ReduxHydrator token={access_token} user={user} />
{children}
</>
);
......
......@@ -44,6 +44,13 @@ export const gameApi = createApi({
}),
providesTags: (result, error, { id }) => [{ type: "Games", id }],
}),
getSingleGameFormUser: builder.query<SingleGameResponse, { id: string | number }>({
query: ({ id }) => ({
url: `/api/game/${id}`,
method: "GET",
}),
providesTags: (_result, _error, { id }) => [{ type: "Games", id }],
}),
// ✏️ Update game by ID
updateGameById: builder.mutation<
......@@ -72,6 +79,7 @@ export const gameApi = createApi({
{ type: "Games", id: "LIST" },
],
}),
}),
});
......@@ -81,4 +89,5 @@ export const {
useGetGameByIdQuery,
useUpdateGameByIdMutation,
useDeleteGameByIdMutation,
useGetSingleGameFormUserQuery
} = gameApi;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment