<html>

<head>
    <!-- Compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

    <meta name="viewport" content="width=device-width, initial-scale=1.0" />


    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
</head>

<body>

    <style>
        html {
            font-family: 'Poppins', sans-serif;
            font-size: 1.5vmax;
        }
        
        .center {
            margin: auto;
            padding: 10px;
            width: 40%;
            position: relative;
            top: 15vh;
            bottom: 15vh;
            border-radius: 1vmax;
        }
        button {
            padding: 1vh 0.5vw;
            border: 0.1vmax solid #3f3e3e;
            border-radius: 0.2vmax;
            box-shadow: 0.1vh 0.1vw #888888;
            font-family: 'Poppins', sans-serif;
            margin: 2vh 0;
        }
        
        .register {
            background-color: #1c37ad;
            color: white;
        }
        
        .tabs .tab a {
            color: #1c37ad;
            font-size: 1.5vmax;
        }
        input[type=text] {
            border: 0.15vmax solid #888888 !important;
            border-radius: 1vmax !important;
            font-family: 'Poppins', sans-serif;
            font-size: 1.5vmax !important;
        }
        h1 {
            overflow: hidden;
            text-align: center;
            font-size: 1.5vmax;
            margin: 0.8rem 0 0.68rem;
        }
        h1:before,
        h1:after {
            background-color: #000;
            content: "";
            display: inline-block;
            height: 1px;
            position: relative;
            vertical-align: middle;
            width: 50%;
        }
        h1:before {
            right: 0.5em;
            margin-left: -50%;
        }
        h1:after {
            left: 0.5em;
            margin-right: -50%;
        }
        @media only screen and (max-width: 720px) {
            .center {
                width: 80%;
            }
        }
    </style>

    <div class="card center">

        <div class="card-tabs">
            <ul class="tabs tabs-fixed-width">
                <li class="tab"><a href="#user">USER</a></li>
                <li class="tab"><a href="#company">COMPANY</a></li>
            </ul>
        </div>
        <div class="card-content grey lighten-4">
            <section id="user">
                <button class="google"> <i class="fab fa-google"></i> LOGIN WITH GOOGLE</button>
                <h1>OR</h1>
                <form id="reg-form" action="" method="POST">
                    <input type="text" id="username" name="name">
                    <label for="email">Email</label>
                    <input type="text" id="email" name="email">
                    <label for="password">Password</label>
                    <!-- <label for="phone">Phone Number</label>
                    <input type="text" id="phone" name="phone"> -->
                    <a href="#resetpw">Forgot password?</a><br />
                    <button class="register" type="submit">REGISTER</button>
                </form>
                
                <p>Already Registered? <a href="#login">Register here</a></p>
            </section>

            <!-- <section id="company">
                <button class="google"> <i class="fab fa-google"></i> LOGIN WITH GOOGLE</button>
                <hr/>
                <form>
                    <label for="name">Name</label>
                    <input type="text" id="name" name="name">
                    <label for="email">Email</label>
                    <input type="text" id="email" name="email">
                    <label for="password">Password</label>
                    <input type="text" id="password" name="password">
                    <label for="phone">Phone Number</label>
                    <input type="text" id="phone" name="phone">
                </form>

                <a href="#resetpw" >Forgot password?</a><br/>

                <button class="register">REGISTER</button>

                <p>Already Registered? <a href="#login">Register here</a></p>
            </section> -->

        </div>
        <!-- ========================================================================================= -->
        <!-- Script to Send back Data to the Server -->
        <script>
            const form = document.getElementById('reg-form');
                event.preventDefault();
                const username = document.getElementById('username').value;
                const password = document.getElementById('password').value;
                const email = document.getElementById('email').value;

                const result = await fetch('/register', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    })
                }).then(res => res.json());
                console.log(result);
                if (result.status === 'ok') {
                    //ALl OK.
                    alert(result.data);
                    alert(result.error);
                }
            }
        </script>
        <!-- ========================================================================================= -->

        <!-- Compiled and minified JavaScript -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>

</html>