@extends('layouts.app')

@section('title', 'Login - Nahid')

@section('content')
<div class="z_login_box">
    <div class="z_login_but_1 active" id="loginBtn">
        Login
    </div>
    <div class="z_login_but_2" id="registerBtn">
        Register
    </div>
    
    <div class="z_login_bdy">
        <form action="{{ route('login') }}" method="POST" autocomplete="off">
            @csrf
            <input type="hidden" name="key" value="hsgRw537Mxhsgywtsdgtwfsd">
            
            <table>
                <tr>
                    <td>
                        <input type="text" 
                               name="username" 
                               placeholder="Username" 
                               class="login_username @error('username') error @enderror" 
                               autocomplete="off" 
                               value="{{ old('username') }}" 
                               required>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="password" 
                               name="password" 
                               placeholder="Password" 
                               class="login_password @error('password') error @enderror" 
                               autocomplete="off" 
                               required>
                    </td>
                </tr>
            </table>
            
            <div class="z_login_submit">
                <button type="submit" class="login_subm_bt">Log In</button>
                <forgot>
                    <u><a href="{{ route('password.request') }}">I forgot password</a></u>
                </forgot>
                
                @if(session('error'))
                    <div class="login_err_bar">{{ session('error') }}</div>
                @endif
                
                @error('username')
                    <div class="login_err_bar">{{ $message }}</div>
                @enderror
            </div>
        </form>
    </div>
</div>
@endsection

@push('scripts')
<script>
$(document).ready(function() {
    $("#registerBtn").click(function() {
        window.location.href = "{{ route('register') }}";
    });
    
    setTimeout(function() {
        $('.login_err_bar').fadeOut('slow');
    }, 5000);
});
</script>
@endpush