"use client";

import { ResponsiveModal } from "@/components/responsive-modal";
import { PageLoader } from "@/components/page-loader";

import { EditBoardForm } from "./edit-board-form";
import { useGetBoard } from "../api/use-get-board";
import { useEditBoardModal } from "../hooks/use-edit-board-modal";

export const EditBoardModal = () => {
  const { boardId, isOpen, close } = useEditBoardModal();
  const { data: board, isLoading } = useGetBoard({ boardId: boardId || "" });

  return (
    <ResponsiveModal open={isOpen} onOpenChange={close}>
      {isLoading ? (
        <PageLoader />
      ) : board ? (
        <EditBoardForm onCancel={close} initialValues={board} />
      ) : (
        <div className="p-4">Board not found</div>
      )}
    </ResponsiveModal>
  );
}; 