import type { PauseMode, PendingVote } from "../types/player";

interface PlayResumeControlProps {
  pauseMode: PauseMode;
  pendingVote: PendingVote | null;
  onResume: () => void;
  onPause: () => void;
}

export function PlayResumeControl({
  pauseMode,
  pendingVote,
  onResume,
  onPause
}: PlayResumeControlProps) {
  const isPlaying = pauseMode === "playing";
  const actionLabel = isPlaying
    ? "Pause playback"
    : pendingVote
      ? "Resume playback and record vote"
      : "Resume playback";

  return (
    <div className="resume-control">
      <button
        type="button"
        className="resume-control__button"
        aria-label={actionLabel}
        title={actionLabel}
        onClick={isPlaying ? onPause : onResume}
      >
        <span
          className={`resume-control__icon ${
            isPlaying
              ? "resume-control__icon--pause"
              : "resume-control__icon--play"
          }`}
          aria-hidden="true"
        />
      </button>
    </div>
  );
}
