@props(['label', 'options'])
<div class="filter-sort-by" x-data="{ sortBy: '{{ request('sortBy', 'newest') }}' }">
    <label for="sort-by" class="sort-by-label">{{ $label }}</label>

    <select name="sort_by" x-model="sortBy" @change="window.location.href = '?sortBy=' + sortBy" id="sort-by" class="form-select">
        @foreach($options as $value => $text)
            <option value="{{ $value }}">
                {{ $text }}
            </option>
        @endforeach
    </select>
</div>
