import { NSQLITE_TURBOCI_ADMIN_USERS } from "@/src/db/types";
import { AppContext } from "@/src/pages/_app";
import { TurboCISignupFormObject } from "@/src/types";
import useStatus from "@/twui/components/hooks/useStatus";
import { useContext, useState } from "react";

type Params = {
    new_deployment_user?: boolean;
    existing_user?: NSQLITE_TURBOCI_ADMIN_USERS;
};

export default function useSignupForm({
    new_deployment_user,
    existing_user,
}: Params) {
    const { pageProps } = useContext(AppContext);
    const [newUser, setNewUser] = useState<TurboCISignupFormObject>(
        existing_user || {},
    );
    const { loading, setLoading } = useStatus();
    const [isPasswordConfirmed, setIsPasswordConfirmed] = useState(false);

    return {
        newUser,
        setNewUser,
        loading,
        setLoading,
        isPasswordConfirmed,
        setIsPasswordConfirmed,
        pageProps,
    };
}
