{{--
    Seletor de ordenação das atividades (abas Tabela e Linha do tempo).

    Variáveis:
      $project          → Project
      $filterParams     → query string persistida
      $viewTab          → table|timeline
      $pageParam        → ap|tp (paginação Laravel da aba; é resetada ao reordenar)
      $sortOptions      → array<string, string> (chave => rótulo)
      $currentSort      → string
      $currentDir       → string (asc|desc)
      $selectId         → id único do <select> de campo
--}}
@php
    $hiddenParams = collect($filterParams ?? [])
        ->except(['tab', $pageParam ?? 'ap', 'sort', 'dir'])
        ->all();
@endphp

<form method="get"
      action="{{ route('admin.cronogramas.projetos.show', $project) }}"
      class="d-flex flex-wrap align-items-center gap-2 mb-0">
    <input type="hidden" name="tab" value="{{ $viewTab }}">
    @include('components.cronogramas.persist-query', ['params' => $hiddenParams])
    <label class="form-label small mb-0 text-muted" for="{{ $selectId }}">{{ __('Ordenar por') }}:</label>
    <select name="sort"
            id="{{ $selectId }}"
            class="form-select form-select-sm w-auto"
            onchange="this.form.submit()"
            aria-label="{{ __('Ordenar atividades por') }}">
        @foreach($sortOptions as $key => $label)
            <option value="{{ $key }}" @selected(($currentSort ?? 'manual') === $key)>{{ $label }}</option>
        @endforeach
    </select>
    <select name="dir"
            class="form-select form-select-sm w-auto"
            onchange="this.form.submit()"
            aria-label="{{ __('Direção da ordenação') }}">
        <option value="asc" @selected(($currentDir ?? 'asc') === 'asc')>{{ __('Crescente') }}</option>
        <option value="desc" @selected(($currentDir ?? 'asc') === 'desc')>{{ __('Decrescente') }}</option>
    </select>
</form>
