"use client";

import { Save } from "lucide-react";
import { useTranslation } from "react-i18next";

import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";

type OddsConfigDraftBarProps = {
  saving: boolean;
  loadingDetail?: boolean;
  onSave: () => void;
  onPublish: () => void;
  className?: string;
};

export function OddsConfigDraftBar({
  saving,
  loadingDetail = false,
  onSave,
  onPublish,
  className,
}: OddsConfigDraftBarProps) {
  const { t } = useTranslation("config");
  const busy = saving || loadingDetail;

  return (
    <div
      className={cn(
        "sticky bottom-0 z-10 flex flex-wrap items-center justify-end gap-2 border-t border-border/60 bg-card/95 px-4 py-2.5 backdrop-blur sm:px-5",
        className,
      )}
    >
      <Button type="button" variant="outline" size="sm" disabled={busy} onClick={onSave}>
        <Save className="size-3.5" aria-hidden />
        {t("versionActions.saveDraft")}
      </Button>
      <Button type="button" size="sm" disabled={busy} onClick={onPublish}>
        {t("versionActions.publishCurrent")}
      </Button>
    </div>
  );
}
