'use client';
import React from "react";
import { ErrorMessage, useFormik } from "formik";
import { useRouter } from "next/navigation";
import { ConditionalNull } from "@/components/utility/Conditional";
import { JSONContentTable, JSONJudgementTable, JSONUserTable } from "@/lib/mastoauth/realtypes";

export function Form({userID}:{userID:string}) {
  const router = useRouter();
  const formik = useFormik({
    initialValues: {},
    onSubmit: async (values) => {
      const submitRequest = await fetch(`/jams/api/users/${userID}`, {
        method: "DELETE"
      });

      if (submitRequest.ok) {
        router.push(`/jams/`);
      } else {
        formik.setSubmitting(false);
      }
    },
  });

  return (
    <form onSubmit={formik.handleSubmit}>
      <div>
        <p><label htmlFor="submit">Are you sure?</label></p>
        <input id="submit" name="submit" type="submit" value="Delete" />
      </div>
    </form>
  );
}