"use client";

import React from "react";
import DisabledButtonWithTooltip from "@/components/ui/DisabledButtonWithTooltip";
import type {
} from "./eventFormTypes";
import type { useEventForm } from "./useEventForm";

/** A field group lifted out of the form of the same family. */
export default function EventFormActions({
  screen,
  onSubmit,
}: {
  screen: ReturnType<typeof useEventForm>;
  onSubmit: () => void;
}) {
  const {
    t,
    id,
    isRepublish,
    isSubmitting,
  } = screen;

  return (
  <div className="publish-form-actions flex justify-center gap-3 pt-6">
    <div className="flex gap-6 extrasmall:flex-col">
      <DisabledButtonWithTooltip
        type="button"
        variant="primary"
        size="medium"
        onClick={onSubmit}
        /* Publishing twice makes two events: closed while the save is out. */
        disabled={isSubmitting}
        aria-busy={isSubmitting}
        showTooltip={false}
        className="disabled:cursor-not-allowed disabled:opacity-50"
        tooltipText=""
      >
        {id && !isRepublish
          ? t("COMMON.SAVE")
          : isRepublish
            ? t("COMMON.REPOST")
            : t("COMMON.PUBLISH")}
      </DisabledButtonWithTooltip>
    </div>
  </div>
  );
}
