import DangerMessage from "@/components/message/DangerMessage";
import { useGetGameClasses } from "@/hooks/GameClassHooks";
import GameClassList from "./GameClassList";
import GameClassListSkeleton from "./GameClassListSkeleton";


export default function GameClassLoader({
	gameId,
	page,
	pageSize,
	searchTerm
}:{
	gameId: string;
	page: number;
	pageSize: number;
	searchTerm?: string;
}){
	const gameClassQuery = useGetGameClasses(gameId, page - 1, pageSize, searchTerm);


	if(gameClassQuery.status === "pending"){
		return <GameClassListSkeleton/>
	}
	else if(gameClassQuery.status === "error"){
		return <DangerMessage>Error {gameClassQuery.error.message}</DangerMessage>
	}
	else{
		return (
			<GameClassList
				gameClasses={gameClassQuery.data ?? []}
			/>
		);
	}
}
