"use client";

import RoundedButton from "@/components/elements/RoundedButton";

import { toggleBtnClass } from "@/lib/ui/buttonStyles";
import { cn } from "@/lib/utils";
import { useTranslation } from "react-i18next";

interface PublicTypeSelectionProps {
  selectedPublicType: string;
  setSelectedPublicType: (type: string) => void;
  setFieldValue: (field: string, value: string) => void;
}

const PublicTypeSelection = ({
  selectedPublicType,
  setSelectedPublicType,
  setFieldValue,
}: PublicTypeSelectionProps) => {
  const { t } = useTranslation("common");

  return (
    <div className="flex gap-2">
      {["true", "false"].map((type) => (
        <RoundedButton
          key={type}
          className={cn(toggleBtnClass(selectedPublicType === type), "min-w-32 p-1")}
          onClick={(e) => {
            e.preventDefault();
            setSelectedPublicType(type);
            setFieldValue("publicType", type);
          }}
        >
          {type === "true"
            ? t("projects.newProject.highPr")
            : t("projects.newProject.noPrLimit")}
        </RoundedButton>
      ))}
    </div>
  );
};

export default PublicTypeSelection;
