<!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 - @yield('title')</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') ?>" />

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <!-- 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') ?>" />

    <link rel="stylesheet" href="<?= url('/assets/plugin/DataTables/datatables.min.css') ?>">

    <script src="<?= url('/assets/vendor/js/helpers.js') ?>"></script>
    {{-- <script src="<?= url('/assets/js/config.js') ?>"></script> --}}
    <!-- Page CSS -->
  </head>

  <body>
    <!-- Layout wrapper -->
    <div class="layout-wrapper layout-content-navbar">
      <div class="layout-container">
        <!-- Menu -->

        <aside id="layout-menu" class="layout-menu menu-vertical menu bg-menu-theme">
          <div class="app-brand demo">
            <a href="" class="app-brand-link">
              <span class="app-brand-logo demo">
                <img src="<?= url('/assets/img/favicon/icon.png') ?>" alt="icon" width="48" height="48">
              </span>
              <span class="app-brand-text demo menu-text fw-bolder ms-2">Dashboard</span>
            </a>

            <a href="javascript:void(0);" class="layout-menu-toggle menu-link text-large ms-auto d-block d-xl-none">
              <i class="bx bx-chevron-left bx-sm align-middle"></i>
            </a>
          </div>

          <div class="menu-inner-shadow"></div>

          <ul class="menu-inner py-1">
            <!-- Dashboard -->
            <li class="menu-item <?php echo (empty(request()->segment(2)) || request()->segment(2) == 'index')?'active':'' ?>">
              <a href="{{ route('dashboard.index') }}" class="menu-link">
                <i class="menu-icon tf-icons bx bx-home-circle"></i>
                <div data-i18n="Dashboard">Dashboard</div>
              </a>
            </li>

            <li class="menu-header small text-uppercase">
                <span class="menu-header-text">Data</span>
            </li>

            <li class="menu-item <?php echo (request()->segment(2) == 'job')?'active':'' ?>">
                <a href="{{ route('dashboard.job') }}" class="menu-link">
                  <i class="menu-icon tf-icons bx bx-box"></i>
                  <div data-i18n="Job">Jobs</div>
                </a>
            </li>

            <li class="menu-item">
                <a href="javascript:void(0);" class="menu-link menu-toggle">
                    <i class="menu-icon tf-icons bx bx-user"></i>
                    <div data-i18n="Users">Users</div>
                </a>
                <ul class="menu-sub">
                    <li class="menu-item <?php echo (request()->segment(2) == 'maids')?'active':'' ?>">
                    <a href="{{ route('dashboard.maids') }}" class="menu-link">
                        <div data-i18n="Maid">Maid</div>
                    </a>
                    </li>
                    <li class="menu-item <?php echo (request()->segment(2) == 'owners')?'active':'' ?>">
                    <a href="{{ route('dashboard.owners') }}" class="menu-link">
                        <div data-i18n="Owner">Owner</div>
                    </a>
                    </li>
                    <li class="menu-item <?php echo (request()->segment(2) == 'admins')?'active':'' ?>">
                      <a href="{{ route('dashboard.admins') }}" class="menu-link">
                          <div data-i18n="Admin">Admin</div>
                      </a>
                      </li>
                </ul>
            </li>

            <li class="menu-header small text-uppercase">
              <span class="menu-header-text">Setting</span>
            </li>

            <li class="menu-item <?php echo (request()->segment(2) == 'skill')?'active':'' ?>">
                <a href="{{ route('dashboard.skill') }}" class="menu-link">
                  <i class="menu-icon tf-icons bx bx-detail"></i>
                  <div data-i18n="Skill">Skill</div>
                </a>
            </li>

            <li class="menu-item <?php echo (request()->segment(2) == 'account')?'active':'' ?>">
                <a href="{{ route('dashboard.account') }}" class="menu-link">
                  <i class="menu-icon tf-icons bx bx-user-circle"></i>
                  <div data-i18n="Account">Account</div>
                </a>
            </li>
          </ul>
        </aside>
        <!-- / Menu -->

        <!-- Layout container -->
        <div class="layout-page">
          <!-- Navbar -->

          <nav
            class="layout-navbar container-xxl navbar navbar-expand-xl navbar-detached align-items-center bg-navbar-theme"
            id="layout-navbar"
          >
            <div class="layout-menu-toggle navbar-nav align-items-xl-center me-3 me-xl-0 d-xl-none">
              <a class="nav-item nav-link px-0 me-xl-4" href="javascript:void(0)">
                <i class="bx bx-menu bx-sm"></i>
              </a>
            </div>

            <div class="navbar-nav-right d-flex align-items-center" id="navbar-collapse">
                <!-- Search -->
                <div class="navbar-nav align-items-center">

                </div>
                <!-- /Search -->

                <ul class="navbar-nav flex-row align-items-center ms-auto">
                  <!-- User -->
                  <li class="nav-item navbar-dropdown dropdown-user dropdown">
                    <a class="nav-link dropdown-toggle hide-arrow" href="javascript:void(0);" data-bs-toggle="dropdown">
                      <div class="avatar avatar-online">
                        <img src="../assets/img/avatars/1.png" alt class="w-px-40 h-auto rounded-circle" />
                      </div>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end">
                      <li>
                        <a class="dropdown-item" href="#">
                          <div class="d-flex">
                            <div class="flex-shrink-0 me-3">
                              <div class="avatar avatar-online">
                                <img src="../assets/img/avatars/1.png" alt class="w-px-40 h-auto rounded-circle" />
                              </div>
                            </div>
                            <div class="flex-grow-1">
                              <span class="fw-semibold d-block">{{ $user->name }}</span>
                              <small class="text-muted">Admin</small>
                            </div>
                          </div>
                        </a>
                      </li>
                      <li>
                        <div class="dropdown-divider"></div>
                      </li>
                      <li>
                        <a class="dropdown-item btn-logout" href="javascript:void(0);">
                          <i class="bx bx-power-off me-2"></i>
                          <span class="align-middle">Log Out</span>
                        </a>
                      </li>
                    </ul>
                  </li>
                  <!--/ User -->
                </ul>
              </div>

          </nav>

          <!-- / Navbar -->

          <!-- Content wrapper -->
          <div class="content-wrapper">
            <!-- Content -->


            {{-- ISI KONTEN --}}
            @yield('content')

            <!-- / Content -->

            <!-- Footer -->
            <footer class="content-footer footer bg-footer-theme">
              <div class="container-xxl d-flex flex-wrap justify-content-between py-2 flex-md-row flex-column">
                <div class="mb-2 mb-md-0">
                  ©
                  <script>
                    document.write(new Date().getFullYear());
                  </script>
                  <b>MaidMatching</b> All Rights Reserved
                </div>
              </div>
            </footer>
            <!-- / Footer -->

            <div class="content-backdrop fade"></div>
          </div>
          <!-- Content wrapper -->
        </div>
        <!-- / Layout page -->
      </div>

      <!-- Overlay -->
      <div class="layout-overlay layout-menu-toggle"></div>
    </div>
    <!-- / Layout wrapper -->


    <!-- 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>
    <!-- Core JS -->
    <!-- build:js assets/vendor/js/core.js -->
    <script src="<?= url('/assets/js/jquery-3.6.1.min.js') ?>"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
    <script src="<?= url('/assets/vendor/bootstrap/js/bootstrap.min.js') ?>"></script>
    <script src="<?= url('/assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js') ?>"></script>
    <script src="<?= url('/assets/vendor/js/bootstrap.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/DataTables/datatables.min.js') ?>"></script>
    <script src="<?= url('assets/plugin/sweetalert2/sweetalert2.all.min.js') ?>"></script>
    <script src="<?= url('assets/plugin/select2/js/select2.min.js') ?>"></script>
    <script src="<?= url('assets/plugin/fancy-file-uploader/jquery.ui.widget.js') ?>"></script>
    <script src="<?= url('assets/plugin/fancy-file-uploader/jquery.fileupload.js') ?>"></script>
    <script src="<?= url('assets/plugin/fancy-file-uploader/jquery.iframe-transport.js') ?>"></script>
    <script src="<?= url('assets/plugin/fancy-file-uploader/jquery.fancy-fileupload.js') ?>"></script>

    <script>
        function getAuthorization() {
            return "Bearer "+cookie.get("mm_token");
        }
    </script>
    <script src="<?= url('assets/js/dashboard-main.js') ?>"></script>
    <script>

        var getUploadedFile = {};
        // Function For Upload File
        function upload(name, maxFiles = 1) {
            getUploadedFile[name] = [];

            $(`#${name}`).FancyFileUpload({
            params : {
                action : 'fileuploader'
            },
            edit: false,
            maxfilesize : 10000000,
            added: function (e, data) {
                if (data.ff_info.errors.length > 0) {
                Swal.fire(
                    'Gagal Ditambahkan!',
                    'Error: '+data.ff_info.errors,
                    'error'
                    )
                    $(this).remove()
                    delete data.ff_info
                    return;
                }

                if ($(`.upload--${name}`).find('.ff_fileupload_queued').length > maxFiles) {
                    Swal.fire(
                        'Gagal Ditambahkan!',
                        `Maksimal upload hanya ${maxFiles} file`,
                        'error'
                        )
                    $(this).remove()
                    delete data.ff_info
                    return;
                }

                $(`.upload--${name}`).find('.btn--upload-file').removeClass('d-none');
                $(`.upload--${name}`).find('.ff_fileupload_remove_file').attr('data-doc', name);

                if (maxFiles === 1) {
                    getUploadedFile[name] = data.files[0];
                } else {
                    for (var i = 0; i < maxFiles; i++) {
                        if (($(`.upload--${name}`).find('.ff_fileupload_queued').length-1) == i) {
                            getUploadedFile[name][i] = data.files[0];
                        }
                    }
                }

                $(this).find('.ff_fileupload_start_upload').remove()
            }
            });
        }


        $(document).on('click', '.btn-logout', function(e) {
            e.preventDefault();

            Swal.fire({
            title: 'Logout?',
            text: `Anda ingin melakukan logout!`,
            icon: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'Ya, logout!'
            }).then((result) => {
            if (result.isConfirmed) {

                callApi("POST", "{{ route('api.logout') }}", {}, function (req) {
                    pesan = req.message;
                    if (req.error == true) {
                        Swal.fire(
                            'Gagal melakukan logout!',
                            pesan,
                            'error'
                        )
                    } else {
                        cookie.remove('mm_token')
                        window.location.href = "{{ route('login') }}"
                    }
                })

            }
            })
        });
    </script>
    @stack('script')
  </body>
</html>
