Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

546 B
Raw Blame
import { parseAsStringLiteral, useQueryState } from "nuqs";

export const COPILOT_MODALS = [
  "integrations",
  "connect",
  "skills",
  "scheduled",
] as const;
export type CopilotModalType = (typeof COPILOT_MODALS)[number];

export function useCopilotModal() {
  const [modal, setModal] = useQueryState(
    "modal",
    parseAsStringLiteral(COPILOT_MODALS),
  );

  function openModal(next: CopilotModalType) {
    void setModal(next);
  }

  function closeModal() {
    void setModal(null);
  }

  return { modal, openModal, closeModal };
}