@{
    var boardID = ViewData["BoardID"];
    var boardList = ViewData["BoardList"] as List<(int ID, string Name)>;
}

<div class="row">
    <div class="col">
        <h3>@ViewData["Title"]</h3>
    </div>
    <div class="col-auto">
        <select id="boardSelect" class="form-select">
            <option value="">게시판 선택</option>
            @if (boardList != null)
            {
                @foreach (var (id, name) in boardList)
                {
                    <option value="@id" selected="@(id == (int?)boardID)">@name</option>
                }
            }
        </select>
    </div>
</div>
<hr />
<script type="module">
    document.getElementById("boardSelect")?.addEventListener("change", function() {
        if (this.value) {
            const path = window.location.pathname;
            const segments = path.split('/');
            segments[segments.length - 1] = this.value;
            window.location.href = segments.join('/') + window.location.search;
        }
    });
</script>