@extends('layouts.app')

@section('content')

    <div class="h-50 row mt-5">
        <div class="col h-50 justify-content-center d-flex align-items-center modular">
            <h1 class="p-5">Welcome</h1>
            <h4>Mail has been send.</h4>
            @auth
            <!-- Modal -->
            <div class="modal fade show" id="loggedIn" tabindex="-1" aria-labelledby="loggedInLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                        <h5 class="modal-title" id="loggedInLabel">Welcome</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                        <div class="modal-body">
                            Welcome,  
                            At the moment, you are logged in as {{Auth::user()->name}}. If you are not this user, please 
                            <a class="aLink" href="http://localhost:8000/logout" onclick="event.preventDefault();
                            document.getElementById('logout-form').submit();">
                                log out
                            </a>.
                        </div>

                        <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Got it.</button>
                        </div>
                    </div>
                </div>
            </div>                
            @endauth

            @guest
            <!-- Modal -->
            <div class="modal fade show" id="loggedIn" tabindex="-1" aria-labelledby="loggedInLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                        <h5 class="modal-title" id="loggedInLabel">Welcome Guest</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                        </div>
                        <div class="modal-body">
                            Welcome,  
                            At the moment, you are not logged in. If you want to log in, please  
                            <a class="aLink" href="http://localhost:8000/login">
                                click here
                            </a>.
                        </div>
                        <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Got it.</button>
                        </div>
                    </div>
                </div>
            </div>                
            @endguest
            
        </div>
    </div>
    
@endsection

<script>
    document.addEventListener('DOMContentLoaded', function () {
        $("#loggedIn").modal()
    }, false);
</script>