
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Log in</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Font Awesome -->
    <link rel="stylesheet" href="<?= base_url(); ?>assets/plugins/fontawesome-free/css/all.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="<?= base_url(); ?>assets/dist/css/adminlte.min.css">
    <!-- Google Font: Source Sans Pro -->
    <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>

<body class="hold-transition login-page">
    <div class="login-box">



        <div class="row">
            <?php $successMessage = $this->session->flashdata('successmessage');
            $warningmessage = $this->session->flashdata('warningmessage');
            if (isset($successMessage)) {
                echo '<div id="alertmessage" class="col-md-12">
          <div class="alert alert-success alert-dismissible">
                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                   ' . output($successMessage) . '
                  </div>
          </div>';
            }
            if (isset($warningmessage)) {
                echo '<div id="alertmessage" class="col-md-12">
          <div class="alert alert-warning alert-dismissible">
                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                   ' . output($warningmessage) . '
                  </div>
          </div>';
            }
            ?>
        </div>
        <!-- /.login-logo -->
        <div class="card">
            <div class="card-body login-card-body">
                <h2 class="login-box-msg">NearFeast Portal</h2>


                <form action="<?= base_url() . 'login/login_process'; ?>" method="post">
                    <div class="input-group mb-3">
                        <input type="email" name="email" required class="form-control" placeholder="Email">
                        <div class="input-group-append">
                            <div class="input-group-text">
                                <span class="fas fa-envelope"></span>
                            </div>
                        </div>
                    </div>
                    <div class="input-group mb-3">
                        <input type="password" name="password" class="form-control" placeholder="Password">
                        <div class="input-group-append">
                            <div class="input-group-text">
                                <span class="fas fa-lock"></span>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-8">
                            <div class="icheck-primary">

                            </div>
                        </div>
                        <!-- /.col -->
                        <div class="col-4">
                            <button type="submit" class="btn btn-primary btn-block">Sign In</button>
                        </div>
                        <!-- /.col -->
                    </div>
                </form>
                <div class="fb-login-button" data-width="" data-size="large" data-button-type="continue_with" data-layout="default" data-auto-logout-link="false" data-use-continue-as="false"></div>

<!-- Google Sign-In Button -->
<div id="google-signin-button"></div>

<!-- Apple Sign In Button -->
<div id="apple-signin-button"></div>


            </div>
            <!-- /.login-card-body -->
        </div>
    </div>
    <!-- /.login-box -->

    <!-- jQuery -->
    <script src="<?= base_url(); ?>assets/plugins/jquery/jquery.min.js"></script>
    <!-- Bootstrap 4 -->
    <script src="<?= base_url(); ?>assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="https://connect.facebook.net/en_US/sdk.js"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>
<script>
    //https://nearfeast-2227f.firebaseapp.com/__/auth/handler 
    
    //Initialize Facebook SDK
window.fbAsyncInit = function() {
    FB.init({
        appId      : '1299727658089645',
        cookie     : true,
        xfbml      : true,
        version    : 'v12.0'
    });
};

// Load Facebook SDK asynchronously
(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "https://connect.facebook.net/en_US/sdk.js";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));

// Initialize Google Sign-In
function onGoogleSignIn(googleUser) {
    // Handle Google Sign-In response
    var id_token = googleUser.getAuthResponse().id_token;
    // Send id_token to your server for verification and user creation
}

// Render Google Sign-In button
gapi.load('auth2', function() {
    gapi.auth2.init({
        client_id: '1018931869120-o7ulr3tkc2rl64bctm6badmdsv3hi80c.apps.googleusercontent.com'
    }).then(function () {
        gapi.signin2.render('google-signin-button', {
            'scope': 'profile email',
            'width': 200,
            'height': 40,
            'longtitle': true,
            'theme': 'dark',
            'onsuccess': onGoogleSignIn
        });
    });
});

// Initialize Apple Sign In
AppleID.auth.init({
    clientId : 'your-apple-client-id',
    scope : 'name email',
    redirectURI: 'your-redirect-uri',
});

// Render Apple Sign In button
var appleSignInButton = document.getElementById('apple-signin-button');
appleSignInButton.addEventListener('click', function() {
    var request = AppleID.auth.signIn();
    request.catch(function(error) {
        console.error("Error with Apple Sign In: ", error);
    });
});

    </script>
</body>

</html>