"use client";

import { useRouter } from "next/navigation";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/Button";

/** Save remains available so submitting reveals field validation errors. */
export default function OrganizerFormActions({
  isSubmitting,
}: {
  isSubmitting: boolean;
}) {
  const { t } = useTranslation();
  const router = useRouter();

  return (
    <>
                      {/* Submit and Cancel Buttons */}
                      <div className="flex justify-center gap-[28px] 2xl:pt-8 lg:pt-3 pt-3 mt-8">
                        <Button
                          variant="primary"
                          size="medium"
                          type="submit"
                          loading={isSubmitting}
                        >
                          {t("COMMON.SAVE")}
                        </Button>
                        {/* Cancel abandons the edit and leaves, whether or not
                            anything was typed. It used to branch on `dirty` and
                            only navigate from a pristine form, which read as
                            "Cancel is broken" the moment you had actually
                            changed something. Form state, the kept-document
                            list and the pending nickname check all die with the
                            component — the unmount cleanup clears the timeout —
                            so there is nothing to reset on the way out.
                            VolunteerAccountInformation does the same. */}
                        <Button
                          variant="secondary"
                          size="medium"
                          type="button"
                        disabled={isSubmitting}
                          onClick={() => router.push("/")}
                        >
                          {t("COMMON.CANCEL")}
                        </Button>
                      </div>
    </>
  );
}
