Commit 848b8481 by Arjun Jhukal

updated the minor changes

parent d9843b6e
...@@ -28,10 +28,6 @@ export async function generateMetadata(props: { params: Promise<{ id: string }> ...@@ -28,10 +28,6 @@ export async function generateMetadata(props: { params: Promise<{ id: string }>
}; };
} }
export default async function UserGameDetail(props: { params: Promise<{ id: string }> }) { export default async function UserGameDetail() {
const { id } = await props.params; return <ExclusiveGameDetail />;
const game = await getSingleGame(id);
return <ExclusiveGameDetail game={game} />;
} }
import DashboardLayout from '@/components/layouts/DashboardLayout' import DashboardLayout from '@/components/layouts/DashboardLayout'
import ServerPrivate from '@/routes/ServerPrivate' import Private from '@/routes/Private'
import React from 'react' import React from 'react'
export default function PrivateUserLayout({ children }: { children: React.ReactNode }) { export default function PrivateUserLayout({ children }: { children: React.ReactNode }) {
return ( return (
<ServerPrivate> <Private>
<DashboardLayout> <DashboardLayout>
{children} {children}
</DashboardLayout> </DashboardLayout>
</ServerPrivate> </Private>
) )
} }
"use client";
import ScreenShotSlider from "@/components/molecules/Sliders/ScreenShotSlider"; import ScreenShotSlider from "@/components/molecules/Sliders/ScreenShotSlider";
import CustomLightGallery from "@/components/organism/LightGallery"; import CustomLightGallery from "@/components/organism/LightGallery";
import ProtectedLink from "@/routes/ProtectedLink"; import ProtectedLink from "@/routes/ProtectedLink";
import { SingleGameResponse } from "@/types/game"; import { useGetSingleGameFormUserQuery } from "@/services/gameApi";
import { renderHTML } from "@/utils/RenderHTML"; import { renderHTML } from "@/utils/RenderHTML";
import { Box } from "@mui/material"; import { Box } from "@mui/material";
import Image from "next/image"; import Image from "next/image";
import { useParams } from "next/navigation";
import GameCredentialsBlock from "./GameCredentialsBlock"; import GameCredentialsBlock from "./GameCredentialsBlock";
import GameIframeDialog from "./GameIframeDialog"; import GameIframeDialog from "./GameIframeDialog";
import UserCoin from "./UserCoin"; 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 ( return (
<> <>
<section className="detail__banner mb-8"> <section className="detail__banner mb-8">
<div className="md:grid md:grid-cols-12 flex flex-col gap-8 lg:gap-20"> <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="col-span-12 md:col-span-4">
<div className="aspect-[420/433] relative rounded-xl overflow-hidden mb-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> </div>
<GameCredentialsBlock game={game} /> <GameCredentialsBlock game={game} />
</div> </div>
...@@ -31,7 +36,7 @@ export default function ExclusiveGameDetail({ game }: { game: SingleGameResponse ...@@ -31,7 +36,7 @@ export default function ExclusiveGameDetail({ game }: { game: SingleGameResponse
</ul> </ul>
<div className="general-content-box styled-list !text-white"> <div className="general-content-box styled-list !text-white">
<h1 className="text-[2rem]">{game?.data?.name}</h1> <h1 className="text-[2rem]">{game?.data?.name}</h1>
{renderHTML(game?.data?.description)} {renderHTML(game?.data?.description || "")}
</div> </div>
<div className="action__group flex flex-col lg:grid lg:grid-cols-3 gap-2"> <div className="action__group flex flex-col lg:grid lg:grid-cols-3 gap-2">
......
...@@ -3,25 +3,19 @@ import { cookies } from "next/headers"; ...@@ -3,25 +3,19 @@ import { cookies } from "next/headers";
import React from "react"; import React from "react";
import ReduxHydrator from "./ReduxHydrator"; 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 }) { export default async function ServerPrivate({ children }: { children: React.ReactNode }) {
const cookieStore = await cookies(); const cookieStore = await cookies();
const access_token = cookieStore.get("access_token")?.value; const access_token = cookieStore.get("access_token")?.value;
const user_cookie = cookieStore.get("user")?.value; const user_cookie = cookieStore.get("user")?.value;
const user = user_cookie ? JSON.parse(user_cookie) : null; const user = user_cookie ? JSON.parse(user_cookie) : null;
if (!access_token||!user) return; if (!access_token || !user) return;
return ( return (
<> <>
{/* ✅ Hydrate Redux store on client */} {/* ✅ Hydrate Redux store on client */}
<ReduxHydrator token={access_token} user={user}/> <ReduxHydrator token={access_token} user={user} />
{children} {children}
</> </>
); );
......
...@@ -44,6 +44,13 @@ export const gameApi = createApi({ ...@@ -44,6 +44,13 @@ export const gameApi = createApi({
}), }),
providesTags: (result, error, { id }) => [{ type: "Games", id }], 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 // ✏️ Update game by ID
updateGameById: builder.mutation< updateGameById: builder.mutation<
...@@ -72,6 +79,7 @@ export const gameApi = createApi({ ...@@ -72,6 +79,7 @@ export const gameApi = createApi({
{ type: "Games", id: "LIST" }, { type: "Games", id: "LIST" },
], ],
}), }),
}), }),
}); });
...@@ -81,4 +89,5 @@ export const { ...@@ -81,4 +89,5 @@ export const {
useGetGameByIdQuery, useGetGameByIdQuery,
useUpdateGameByIdMutation, useUpdateGameByIdMutation,
useDeleteGameByIdMutation, useDeleteGameByIdMutation,
useGetSingleGameFormUserQuery
} = gameApi; } = 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