<!DOCTYPE html>
<html
  lang="en"
  class="light-style layout-menu-fixed"
  dir="ltr"
  data-theme="theme-default"
  data-assets-path="<?= url('/assets/') ?>"
  data-template="vertical-menu-template-free"
>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
    />

    <title>MaidMatching - Admin Login</title>

    <meta name="description" content="" />

    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="<?= url('/assets/img/favicon/favicon.png') ?>" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link
      href="https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap"
      rel="stylesheet"
    />

    <!-- Icons. Uncomment required icon fonts -->
    <link rel="stylesheet" href="<?= url('/assets/vendor/fonts/boxicons.css') ?>" />

    <!-- Core CSS -->
    <link rel="stylesheet" href="<?= url('/assets/vendor/css/core.css') ?>" class="template-customizer-core-css" />
    <link rel="stylesheet" href="<?= url('/assets/vendor/css/theme-default.css') ?>" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="<?= url('/assets/css/demo.css') ?>" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="<?= url('/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css') ?>" />

    <link rel="stylesheet" href="<?= url('/assets/vendor/libs/apex-charts/apex-charts.css') ?>" />

    <!-- Page CSS -->
    <link rel="stylesheet" href="<?= url('/assets/vendor/css/pages/page-auth.css' )?>" />
    <!-- Helpers -->
    <script src="<?= url('/assets/vendor/js/helpers.js') ?>"></script>

    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="<?= url('/assets/js/config.js') ?>"></script>
  </head>

  <body>
    <!-- Layout wrapper -->

    <div class="container-xxl">
        <div class="authentication-wrapper authentication-basic container-p-y">
          <div class="authentication-inner">
            <!-- Register -->
            <div class="card">
              <div class="card-body">
                <!-- Logo -->
                <div class="app-brand justify-content-center">
                  <a href="" class="app-brand-link gap-2">
                    <span class="app-brand-logo demo">
                      <img src="<?= url('/assets/img/favicon/icon.png') ?>" alt="icon" width="35" height="35">
                    </span>
                    <span class="app-brand-text demo text-body fw-bolder" style="text-transform: none !important;">MaidMatching</span>
                  </a>
                </div>
                <!-- /Logo -->
                <h4 class="mb-2">Welcome admin! 👋</h4>
                <p class="mb-4">Please sign-in to your account</p>

                <form id="formAuthentication" class="mb-3" action="index.html" method="POST">
                  <div class="mb-3">
                    <label for="email" class="form-label">Email</label>
                    <input
                      type="text"
                      class="form-control"
                      id="email"
                      name="email"
                      placeholder="Enter your email"
                      autofocus
                    />
                  </div>
                  <div class="mb-3 form-password-toggle">
                    <div class="d-flex justify-content-between">
                      <label class="form-label" for="password">Password</label>
                      <a href="">
                        {{-- <small>Forgot Password?</small> --}}
                      </a>
                    </div>
                    <div class="input-group input-group-merge">
                      <input
                        type="password"
                        id="password"
                        class="form-control"
                        name="password"
                        placeholder="&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;&#xb7;"
                        aria-describedby="password"
                      />
                      <span class="input-group-text cursor-pointer"><i class="bx bx-hide"></i></span>
                    </div>
                  </div>
                  {{-- <div class="mb-3">
                    <div class="form-check">
                      <input class="form-check-input" type="checkbox" id="remember-me" />
                      <label class="form-check-label" for="remember-me"> Remember Me </label>
                    </div>
                  </div> --}}
                  <div class="mb-3">
                    <button class="btn btn-primary btn-login d-grid w-100" type="button">Sign in</button>
                  </div>
                </form>
              </div>
            </div>
            <!-- /Register -->
          </div>
        </div>
      </div>


    <script>
        function get_api_url() {
            return "<?php echo url('api/') ?>";
        }
    </script>
    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="<?= url('/assets/vendor/libs/jquery/jquery.js') ?>"></script>
    <script src="<?= url('/assets/vendor/libs/popper/popper.js') ?>"></script>
    <script src="<?= url('/assets/vendor/js/bootstrap.js') ?>"></script>
    <script src="<?= url('/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>

    <script src="<?= url('/assets/vendor/js/menu.js') ?>"></script>
    <!-- endbuild -->

    <!-- Vendors JS -->
    <script src="<?= url('/assets/vendor/libs/apex-charts/apexcharts.js') ?>"></script>

    <!-- Main JS -->
    <script src="<?= url('/assets/js/main.js') ?>"></script>

    <!-- Page JS -->
    <script src="<?= url('/assets/js/dashboards-analytics.js') ?>"></script>

    <!-- Place this tag in your head or just before your close body tag. -->
    <script src="<?= url('/assets/js/jquery-cookie.min.js') ?>"></script>
    <script src="<?= url('assets/plugin/sweetalert2/sweetalert2.all.min.js') ?>"></script>
    <script src="<?= url('assets/js/dashboard-main.js') ?>"></script>

    <script>
        $(document).on('click', '.btn-login', function (e) {
            e.preventDefault()

            data = {
                email: $("input#email").val(),
                password: $("input#password").val()
            }

            callApi("POST", "{{ route('api.login') }}", data, function (req) {
                pesan = req.message;
                if (req.error == true) {
                    Swal.fire(
                        'Gagal!',
                        pesan,
                        'error'
                    )
                } else {
                    Swal.fire(
                        'Berhasil!',
                        pesan,
                        'success'
                    )
                    cookie.set('mm_token', req.data.token);
                    window.location.href = "<?php echo url('dashboard') ?>"
                }
            })
        })

    </script>
  </body>
</html>
