<?php
$CURRENT_SECTION = 'member';
include '../inc/header.php'; ?>

    <div class="d-flex justify-content-center align-items-center" style="min-height: 75vh;">
        <div class="card shadow p-4" style="width: 380px;">
            <form id="registerForm" method="post" action="/tenant/api/register_process.php" autocomplete="off">
                <h3 class="text-center mb-4">회원가입</h3>

                <div class="mb-3">
                    <label for="userid" class="form-label">아이디</label>
                    <input type="text" class="form-control" id="userid" name="userid" maxlength="20" required>
                </div>
                <div class="mb-3">
                    <label for="username" class="form-label">이름</label>
                    <input type="text" class="form-control" id="username" name="username" maxlength="20" required>
                </div>
                <div class="mb-3">
                    <label for="password" class="form-label">비밀번호</label>
                    <input type="password" class="form-control" id="password" name="password" maxlength="30" required>
                </div>
                <div class="mb-4">
                    <label for="password2" class="form-label">비밀번호 확인</label>
                    <input type="password" class="form-control" id="password2" name="password2" maxlength="30" required>
                </div>

                <button type="submit" class="btn btn-primary w-100">가입하기</button>
            </form>
        </div>
    </div>

    <script>
        $(function(){
            $('#registerForm').on('submit', function(e){
                // 클라이언트 밸리데이션
                var userid = $('#userid').val().trim();
                var username = $('#username').val().trim();
                var pw1 = $('#password').val();
                var pw2 = $('#password2').val();

                if (userid.length < 4) {
                    alert('아이디는 4글자 이상이어야 합니다.');
                    $('#userid').focus();
                    e.preventDefault(); return false;
                }
                if (username.length < 2) {
                    alert('이름은 2글자 이상 입력하세요.');
                    $('#username').focus();
                    e.preventDefault(); return false;
                }
                if (pw1.length < 4) {
                    alert('비밀번호는 4글자 이상이어야 합니다.');
                    $('#password').focus();
                    e.preventDefault(); return false;
                }
                if (pw1 !== pw2) {
                    alert('비밀번호가 일치하지 않습니다.');
                    $('#password2').focus();
                    e.preventDefault(); return false;
                }
                // 서버 전송
            });
        });
    </script>

<?php include '../inc/footer.php'; ?>
