import type { User } from "@/app/admin/users/columns";
import { ProfileForm } from "@/app/admin/users/form";
import {
	Dialog,
	DialogContent,
	DialogDescription,
	DialogHeader,
	DialogTitle,
	DialogTrigger,
} from "@/components/ui/dialog";
import { PencilIcon } from "lucide-react";

interface EditUserDialogRootProps {
	children: React.ReactNode;
}

export function EditUserDialogRoot(props: EditUserDialogRootProps) {
	const { children } = props;

	return <Dialog>{children}</Dialog>;
}

export function EditUserDialogTrigger() {
	return (
		<DialogTrigger className="flex gap-2 items-center">
			<PencilIcon className="w-4 h-4" />
			<span>Benutzer bearbeiten</span>
		</DialogTrigger>
	);
}

interface EditUserDialogContentProps {
	user: User;
}

export function EditUserDialogContent(props: EditUserDialogContentProps) {
	const { user } = props;

	if (!user) {
		return;
	}

	return (
		<DialogContent>
			<DialogHeader>
				<DialogTitle>Benutzer bearbeiten</DialogTitle>
				<DialogDescription>
					<strong>Hinweis:</strong> In den seltensten Fällen sollten die Daten
					eines Benutzers geändert werden. Dies kann zu unerwarteten Problemen
					führen.
				</DialogDescription>
			</DialogHeader>
			<ProfileForm user={user} />
		</DialogContent>
	);
}
