import {withFormik} from "formik";
import {AppRouterInstance} from "next/dist/shared/lib/app-router-context.shared-runtime";
import InnerUpdateTosForm from "./InnerUpdateTosForm";
import {QueryClient, UseMutateAsyncFunction} from "@tanstack/react-query";
import {SetStateAction} from "react";
import {CreateTosFormValues} from "../create/CreateTosForm";
import {TOS} from "@/hooks/tos";
import { ServerResponse } from "@/types";

export interface UpdateTosFormProps {
  router: AppRouterInstance;
  updateFn: UseMutateAsyncFunction<ServerResponse, Error, CreateTosFormValues, ServerResponse>;
  updatePending:boolean,
  mode: "new" | "edit" | "form";
  setMode: React.Dispatch<SetStateAction<"new" | "edit" | "form">>;
  preValues: TOS;
  queryClient:QueryClient,
  version:string,
  setVersion:React.Dispatch<SetStateAction<string>>
}

const UpdateTosForm = withFormik<UpdateTosFormProps, CreateTosFormValues>({
  mapPropsToValues: (props) => ({
    content: props.preValues.content || "",
    title: props.preValues.title || "",
    version: props.preValues.version || "",
    isActive: props.preValues.isActive || false,
  }),
  handleSubmit: async (values, {props}) => {},
})(InnerUpdateTosForm);

export default UpdateTosForm;
