"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 AccountFormActions({
  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">
                      <Button
                        variant="primary"
                        size="medium"
                        type="submit"
                        loading={isSubmitting}
                      >
                        {t("COMMON.SAVE")}
                      </Button>
                      {/* Matches OrganizerAccountInformation: Cancel abandons
                          the edit and leaves, whether or not anything was
                          typed. It used to reset in place and disable itself on
                          a pristine form, which left no way to back out of the
                          screen at all. Form state and the pending nickname
                          check die with the component — the unmount cleanup
                          clears the timeout — so there is nothing to reset on
                          the way out. */}
                      <Button
                        variant="secondary"
                        size="medium"
                        type="button"
                        disabled={isSubmitting}
                        onClick={() => router.push("/")}
                      >
                        {t("COMMON.CANCEL")}
                      </Button>
                    </div>
    </>
  );
}
