"use client";

import { cn } from "@/lib/helpers";
import { type ScheduleMode } from "./scheduleMode";

/**
 * The consecutive-days / scattered-days choice.
 *
 * Two radio-style buttons rather than a dropdown, because the choice changes
 * which fields appear underneath and needs to read as a mode, not a value.
 */
export default function ScheduleModeSwitch({
  mode,
  onChange,
  labels,
}: {
  mode: ScheduleMode;
  onChange: (next: ScheduleMode) => void;
  labels: Record<ScheduleMode, string>;
  /** Supplied by the picker; declared so the JSX below type-checks. */
  position?: string;
}) {
  return (
  <div className="flex flex-wrap gap-2 border-b border-[#29246D1A]/10 p-2">
    {(["consecutive", "scattered"] as const).map((option) => (
      <button
        key={option}
        type="button"
        aria-pressed={mode === option}
        onClick={() => onChange(option)}
        className={cn(
          "shrink-0 rounded-full border px-3 py-1 text-xs transition-colors",
          mode === option
            ? "border-primary-5 bg-primary-5 text-white"
            : "border-[#29246D1A]/10 bg-[#29246D]/[0.03] text-primary-5"
        )}
      >
        {labels[option]}
      </button>
    ))}
  </div>
);
}
