33 lines
953 B
TypeScript
33 lines
953 B
TypeScript
import { db } from "@/lib/db";
|
||
import { notFound } from "next/navigation";
|
||
import PlayerForm from "../../PlayerForm";
|
||
import DeleteButton from "./DeleteButton";
|
||
|
||
export default async function EditPlayerPage({ params }: { params: { id: string } }) {
|
||
const [player, countries] = await Promise.all([
|
||
db.player.findUnique({ where: { id: params.id } }),
|
||
db.country.findMany({ orderBy: { name: "asc" } }),
|
||
]);
|
||
|
||
if (!player) notFound();
|
||
|
||
return (
|
||
<div className="max-w-xl">
|
||
<div className="flex justify-between items-center mb-6">
|
||
<h1 className="text-2xl font-bold">ویرایش بازیکن</h1>
|
||
<DeleteButton playerId={player.id} />
|
||
</div>
|
||
<PlayerForm
|
||
countries={countries}
|
||
playerId={player.id}
|
||
initial={{
|
||
name: player.name,
|
||
position: player.position,
|
||
countryId: player.countryId,
|
||
price: player.price,
|
||
}}
|
||
/>
|
||
</div>
|
||
);
|
||
}
|