module AudioConfirmations
  class AudioConfirmationPresenter
    def present(audio_confirmation)
      AudioConfirmationData.new(
        source_file_name: audio_confirmation.source_file_name,
        presented_source_file_name: audio_confirmation.presented_source_file_name,
        timecode_in: audio_confirmation.timecode_in,
        should_toggle_checkmark: toggle_checkmark?(audio_confirmation),
        is_valid: audio_confirmation.valid?,
      )
    end

    private

    def toggle_checkmark?(audio_confirmation)
      audio_confirmation.source_file_name.present? && audio_confirmation.timecode_in.present?
    end

    class AudioConfirmationData < Struct.new(
      :source_file_name,
      :presented_source_file_name,
      :timecode_in,
      :should_toggle_checkmark,
      :is_valid,
      keyword_init: true)
    end
  end
end
