<template>
  <layout-header></layout-header>
  <layout-sidebar></layout-sidebar>
  <div class="page-wrapper">
    <div class="content">
      <!-- Page Header -->
      <div class="d-md-flex d-block align-items-center justify-content-between mb-3">
        <breadcrumb-index :title="title" :text="text" :text1="text1" :text2="text2" />
        <div class="d-flex my-xl-auto right-content align-items-center flex-wrap">
          <div class="pe-1 mb-2">
            <a
              href="javascript:void(0);"
              class="btn btn-outline-light bg-white btn-icon me-1"
              data-bs-toggle="tooltip"
              data-bs-placement="top"
              aria-label="Refresh"
              data-bs-original-title="Refresh"
            >
              <i class="ti ti-refresh"></i>
            </a>
          </div>
          <div class="pe-1 mb-2">
            <button
              type="button"
              class="btn btn-outline-light bg-white btn-icon me-1"
              data-bs-toggle="tooltip"
              data-bs-placement="top"
              aria-label="Print"
              data-bs-original-title="Print"
            >
              <i class="ti ti-printer"></i>
            </button>
          </div>
          <div class="dropdown me-2 mb-2">
            <a
              href="javascript:void(0);"
              class="dropdown-toggle btn btn-light fw-medium d-inline-flex align-items-center"
              data-bs-toggle="dropdown"
            >
              <i class="ti ti-file-export me-2"></i>Export
            </a>
            <ul class="dropdown-menu dropdown-menu-end p-3">
              <li>
                <a href="javascript:void(0);" class="dropdown-item rounded-1"
                  ><i class="ti ti-file-type-pdf me-1"></i>Export as PDF</a
                >
              </li>
              <li>
                <a href="javascript:void(0);" class="dropdown-item rounded-1"
                  ><i class="ti ti-file-type-xls me-1"></i>Export as Excel
                </a>
              </li>
            </ul>
          </div>
        </div>
      </div>

      <div class="card">
        <approve-request-filter></approve-request-filter>
        <div class="card-body p-0 py-3">
          <!-- Student List -->
          <div class="custom-datatable-filter table-responsive">
            <div class="row">
              <div class="col-sm-12 col-md-6">
                <div class="dataTables_length" id="DataTables_Table_0_length">
                  <label
                    >Row Per Page
                    <select
                      name="DataTables_Table_0_length"
                      aria-controls="DataTables_Table_0"
                      class="form-select form-select-sm"
                    >
                      <option value="10">10</option>
                      <option value="25">25</option>
                      <option value="50">50</option>
                      <option value="100">100</option>
                    </select>
                    Entries</label
                  >
                </div>
              </div>
              <div class="col-sm-12 col-md-6">
                <div id="DataTables_Table_0_filter" class="dataTables_filter text-end">
                  <label>
                    <input
                      type="search"
                      class="form-control form-control-sm"
                      placeholder="Search"
                      aria-controls="DataTables_Table_0"
                  /></label>
                </div>
              </div>
            </div>

            <a-table
              class="table datatable thead-light"
              :columns="columns"
              :data-source="data"
              :row-selection="rowSelection"
            >
              <template #bodyCell="{ column, record }">
                <template v-if="column.key === 'Status'">
                  <span
                    :class="record.StatusClass"
                    class="d-inline-flex align-items-center"
                    ><i class="ti ti-circle-filled fs-5 me-1"></i
                    >{{ record.Status }}</span
                  >
                </template>
                <template v-if="column.key === 'action'">
                  <div class="d-flex align-items-center">
                    <div class="dropdown">
                      <a
                        href="javascript:void(0);"
                        class="btn btn-white btn-icon btn-sm d-flex align-items-center justify-content-center rounded-circle p-0"
                        data-bs-toggle="dropdown"
                        aria-expanded="false"
                      >
                        <i class="ti ti-dots-vertical fs-14"></i>
                      </a>
                      <ul class="dropdown-menu dropdown-menu-right p-3">
                        <li>
                          <a
                            class="dropdown-item rounded-1"
                            href="javascript:void(0);"
                            data-bs-toggle="modal"
                            data-bs-target="#leave_request"
                            ><i class="ti ti-menu me-2"></i>Leave Request</a
                          >
                        </li>

                        <li>
                          <a
                            class="dropdown-item rounded-1"
                            href="javascript:void(0);"
                            data-bs-toggle="modal"
                            data-bs-target="#delete-modal"
                            ><i class="ti ti-trash-x me-2"></i>Delete</a
                          >
                        </li>
                      </ul>
                    </div>
                  </div>
                </template>
              </template>
            </a-table>
          </div>
          <!-- /Student List -->
        </div>
      </div>
    </div>
  </div>
  <approve-request-modal></approve-request-modal>
</template>
<script>
const columns = [
  {
    sorter: false,
  },
  {
    title: "Submitted By",
    dataIndex: "SubmittedBy",
    sorter: {
      compare: (a, b) => {
        a = a.SubmittedBy.toLowerCase();
        b = b.SubmittedBy.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "Leave Type",
    dataIndex: "LeaveType",
    sorter: {
      compare: (a, b) => {
        a = a.LeaveType.toLowerCase();
        b = b.LeaveType.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "Role",
    dataIndex: "Role",
    sorter: {
      compare: (a, b) => {
        a = a.Role.toLowerCase();
        b = b.Role.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "Leave Date",
    dataIndex: "LeaveDate",
    sorter: {
      compare: (a, b) => {
        a = a.LeaveDate.toLowerCase();
        b = b.LeaveDate.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "No of Days",
    dataIndex: "NoofDays",
    sorter: {
      compare: (a, b) => {
        a = a.NoofDays.toLowerCase();
        b = b.NoofDays.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "Applied On",
    dataIndex: "AppliedOn",
    sorter: {
      compare: (a, b) => {
        a = a.AppliedOn.toLowerCase();
        b = b.AppliedOn.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "Authority",
    dataIndex: "Authority",
    sorter: {
      compare: (a, b) => {
        a = a.Authority.toLowerCase();
        b = b.Authority.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "Status",
    dataIndex: "Status",
    key: "Status",
    sorter: {
      compare: (a, b) => {
        a = a.Status.toLowerCase();
        b = b.Status.toLowerCase();
        return a > b ? -1 : b > a ? 1 : 0;
      },
    },
  },
  {
    title: "Action",
    key: "action",
    sorter: true,
  },
];
const data = [
  {
    key: "1",
    SubmittedBy: "James Deckar (9004)",
    LeaveType: "Medical Leave",
    Role: "Student",
    LeaveDate: "05 May 2024 - 07 may 2024",
    NoofDays: "5",
    AppliedOn: "05 May 2024",
    Authority: "Jacquelin",
    Status: "Approved",
    StatusClass: "badge badge-soft-success",
  },
  {
    key: "2",
    SubmittedBy: "Richard (2145)",
    LeaveType: "Casual Leave",
    Role: "Teacher",
    LeaveDate: "07 May 2024 - 07 may 2024",
    NoofDays: "1",
    AppliedOn: "07 May 2024",
    Authority: "Elizabeth",
    Status: "Approved",
    StatusClass: "badge badge-soft-success",
  },
  {
    key: "3",
    SubmittedBy: "Susan (4147)",
    LeaveType: "Maternity Leave",
    Role: "Admin",
    LeaveDate: "08 May 2024 - 19 may 2024",
    NoofDays: "10",
    AppliedOn: "02 May 2024",
    Authority: "Teresa",
    Status: "Approved",
    StatusClass: "badge badge-soft-success",
  },
  {
    key: "4",
    SubmittedBy: "Lisa (2145)",
    LeaveType: "Sick Leave",
    Role: "Librarian",
    LeaveDate: "05 May 2024 - 07 may 2024",
    NoofDays: "1",
    AppliedOn: "04 May 2024",
    Authority: "Edward",
    Status: "Approved",
    StatusClass: "badge badge-soft-success",
  },
  {
    key: "5",
    SubmittedBy: "Janet (1457)",
    LeaveType: "Paternity Leave",
    Role: "Driver",
    LeaveDate: "07 May 2024 - 07 may 2024",
    NoofDays: "1",
    AppliedOn: "06 May 2024",
    Authority: "Daniel",
    Status: "Disapproved",
    StatusClass: "badge badge-soft-danger",
  },
  {
    key: "6",
    SubmittedBy: "Ryan (9784)",
    LeaveType: "Special Leave",
    Role: "Student",
    LeaveDate: "08 May 2024 - 19 may 2024",
    NoofDays: "1",
    AppliedOn: "12 May 2024",
    Authority: "Hellana",
    Status: "Pending",
    StatusClass: "badge badge-soft-pending",
  },
  {
    key: "7",
    SubmittedBy: "Gifford (7457)",
    LeaveType: "Medical Leave",
    Role: "Student",
    LeaveDate: "07 May 2024 - 07 may 2024",
    NoofDays: "1",
    AppliedOn: "04 May 2024",
    Authority: "Erickson",
    Status: "Pending",
    StatusClass: "badge badge-soft-pending",
  },
  {
    key: "8",
    SubmittedBy: "Julie (4655)",
    LeaveType: "Casual Leave",
    Role: "Student",
    LeaveDate: "05 May 2024 - 07 may 2024",
    NoofDays: "1",
    AppliedOn: "04 May 2024",
    Authority: "Raul",
    Status: "Approved",
    StatusClass: "badge badge-soft-success",
  },
  {
    key: "9",
    SubmittedBy: "Joann (4178)",
    LeaveType: "Medical Leave",
    Role: "Student",
    LeaveDate: "08 May 2024 - 19 may 2024",
    NoofDays: "1",
    AppliedOn: "04 May 2024",
    Authority: "Aaron",
    Status: "Pending",
    StatusClass: "badge badge-soft-pending",
  },
  {
    key: "10",
    SubmittedBy: "Kathleen (5898)",
    LeaveType: "Casual Leave",
    Role: "Student",
    LeaveDate: "07 May 2024 - 07 may 2024",
    NoofDays: "1",
    AppliedOn: "04 May 2024",
    Authority: "Morgan",
    Status: "Pending",
    StatusClass: "badge badge-soft-pending",
  },
];
const rowSelection = {
  onChange: () => {},
  onSelect: () => {},
  onSelectAll: () => {},
};
export default {
  data() {
    return {
      title: "Approved Leave Request",
      text: "Dashboard",
      text1: "HRM",
      text2: "Approved Leave Request",
      data,
      columns,
      rowSelection,
    };
  },
};
</script>
