@page "{id:int}"
@model Admin.Pages.Channel.List.EditModel
@{
    ViewData["Title"] = "채널 수정";
}

<div class="container">
    <h3>@ViewData["Title"]</h3>
    <hr />

    <partial name="_StatusMessage" />

    <div class="alert alert-success" role="alert">
        채널 등록 시 YouTube API를 통해 자동 수집된 정보입니다.<br />
        관리자가 직접 수정 시 잘못된 결과가 발생할 수 있습니다.
    </div>

    <form id="fAdminWrite" method="post" accept-charset="utf-8" autocomplete="off">
        <input type="hidden" asp-for="Input.ID" />
        <input type="hidden" asp-for="Input.MemberID" />

        <div class="row mb-2">
            <label class="col-sm-2 col-form-label">PK</label>
            <div class="col-sm-10">
                <input type="text" readonly class="form-control-plaintext" value="@Model.Input.ID" />
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-sm-2 col-form-label">회원(소유자)</label>
            <div class="col-sm-10">
                <input type="text" readonly class="form-control-plaintext" value="[@Model.Input.MemberID] @Model.MemberInfo" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.Name" class="col-sm-2 col-form-label"><span class="text-danger">*</span> 이름</label>
            <div class="col-sm-10">
                <input type="text" asp-for="Input.Name" class="form-control" required maxlength="200" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.Handle" class="col-sm-2 col-form-label">핸들</label>
            <div class="col-sm-10">
                <div class="input-group">
                    <span class="input-group-text">@@</span>
                    <input type="text" asp-for="Input.Handle" class="form-control" maxlength="30" />
                </div>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.YouTubeUrl" class="col-sm-2 col-form-label"><span class="text-danger">*</span> YouTube 주소</label>
            <div class="col-sm-10">
                <input type="url" asp-for="Input.YouTubeUrl" class="form-control" required maxlength="255" />
                <div class="text-muted form-text">
                    YouTube 채널 주소 (예: https://www.youtube.com/channel/UCxxxxxxxxxxxxxxxxxxxxxx)
                </div>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.PlatformFeeRate" class="col-sm-2 col-form-label"><span class="text-danger">*</span> 수수료(%)</label>
            <div class="col-sm-10">
                <div class="row">
                    <div class="col col-md-auto">
                        <div class="input-group">
                            <input type="number" asp-for="Input.PlatformFeeRate" class="form-control" required min="0" max="100" step="0.1" />
                            <span class="input-group-text">%</span>
                        </div>
                    </div>
                </div>
                <span asp-validation-for="Input.PlatformFeeRate" class="text-danger"></span>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.IsVerified" class="col-sm-2 col-form-label">인증 여부</label>
            <div class="col-sm-10 align-content-center">
                <div class="form-check form-check-inline">
                    <input type="checkbox" asp-for="Input.IsVerified" class="form-check-input" />
                    <label class="form-check-label" asp-for="Input.IsVerified">인증합니다.</label>
                </div>
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="Input.IsActive" class="col-sm-2 col-form-label">사용 여부</label>
            <div class="col-sm-10 align-content-center">
                <div class="form-check form-check-inline">
                    <input type="checkbox" asp-for="Input.IsActive" class="form-check-input" />
                    <label class="form-check-label" asp-for="Input.IsActive">사용합니다.</label>
                </div>
            </div>
        </div>
        @if (Model.Input.UpdatedAt is not null)
        {
            <div class="row mb-2">
                <label class="col-sm-2 col-form-label">수정일시</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control-plaintext" readonly value="@Model.Input.UpdatedAt" />
                </div>
            </div>
        }
        <div class="row mb-2">
            <label class="col-sm-2 col-form-label">등록일시</label>
            <div class="col-sm-10">
                <input type="text" class="form-control-plaintext" readonly value="@Model.Input.CreatedAt" />
            </div>
        </div>

        <hr />

        <div class="d-grid gap-2 text-center d-md-block">
            <button type="submit" class="btn btn-success">저장</button>
            <a href="@(Model.ReturnUrl ?? "/Channel/List")" class="btn btn-secondary">취소</a>
            <button type="submit"
                    class="btn btn-danger"
                    formaction="?handler=Delete"
                    formnovalidate
                    onclick="return confirm('삭제 하시겠습니까?');">
                삭제
            </button>
        </div>

        <br />
    </form>
</div>