| @@ -1,19 +1,18 @@ | ||
| 1 | 1 | jQuery(document).ready(function ($) { |
| 2 | + const category = $("#timetics-filter-category"); | |
| 3 | + const staff = $("#timetics-filter-staff"); | |
| 4 | + const url = timetics.site_url + "/wp-json/timetics/v1/appointments/filter"; | |
| 5 | + const meetinContainer = $(".tt-meeting-list-wrapper"); | |
| 2 | 6 | |
| 3 | - const category = $('#timetics-filter-category'); | |
| 4 | - const staff = $('#timetics-filter-staff'); | |
| 5 | - const url = timetics.site_url + '/wp-json/timetics/v1/appointments/filter'; | |
| 6 | - const meetinContainer = $('.tt-meeting-list-wrapper'); | |
| 7 | - | |
| 8 | - $(category).on('change', function (e) { | |
| 7 | + $(category).on("change", function (e) { | |
| 9 | 8 | e.preventDefault(); |
| 10 | 9 | |
| 11 | 10 | $.ajax({ |
| 12 | 11 | url: url, |
| 13 | - method: 'GET', | |
| 12 | + method: "GET", | |
| 14 | 13 | data: { |
| 15 | - category: $(this).val() | |
| 14 | + category: $(this).val(), | |
| 16 | 15 | }, |
| 17 | 16 | success: function (res) { |
| 18 | 17 | if (Array.isArray(res.data.items)) { |
| 19 | 18 | const meetings_markup = prepare_items(res.data.items); |
| @@ -18,20 +17,20 @@ | ||
| 18 | 17 | if (Array.isArray(res.data.items)) { |
| 19 | 18 | const meetings_markup = prepare_items(res.data.items); |
| 20 | 19 | meetinContainer.html(meetings_markup); |
| 21 | 20 | } |
| 22 | - } | |
| 21 | + }, | |
| 23 | 22 | }); |
| 24 | 23 | }); |
| 25 | 24 | |
| 26 | - $(staff).on('change', function (e) { | |
| 25 | + $(staff).on("change", function (e) { | |
| 27 | 26 | e.preventDefault(); |
| 28 | 27 | |
| 29 | 28 | $.ajax({ |
| 30 | 29 | url: url, |
| 31 | - method: 'GET', | |
| 30 | + method: "GET", | |
| 32 | 31 | data: { |
| 33 | - staff_id: $(this).val() | |
| 32 | + staff_id: $(this).val(), | |
| 34 | 33 | }, |
| 35 | 34 | success: function (res) { |
| 36 | 35 | if (Array.isArray(res.data.items)) { |
| 37 | 36 | const meetings_markup = prepare_items(res.data.items); |
| @@ -36,9 +35,9 @@ | ||
| 36 | 35 | if (Array.isArray(res.data.items)) { |
| 37 | 36 | const meetings_markup = prepare_items(res.data.items); |
| 38 | 37 | meetinContainer.html(meetings_markup); |
| 39 | 38 | } |
| 40 | - } | |
| 39 | + }, | |
| 41 | 40 | }); |
| 42 | 41 | }); |
| 43 | 42 | |
| 44 | 43 | /** |
| @@ -46,16 +45,16 @@ | ||
| 46 | 45 | * |
| 47 | 46 | * @return string |
| 48 | 47 | */ |
| 49 | 48 | function prepare_items(items) { |
| 50 | - if ( items.length < 1 ) { | |
| 49 | + if (items.length < 1) { | |
| 51 | 50 | return `<p>No meetings found</p>`; |
| 52 | 51 | } |
| 53 | 52 | |
| 54 | - const meetings = items.map(item => { | |
| 55 | - const staffs = preapare_staff(item.staff); | |
| 56 | - return ` | |
| 57 | - <div class="ant-col-8 ant-col-xs-24 ant-col-md-8"> | |
| 53 | + const meetings = items | |
| 54 | + .map((item) => { | |
| 55 | + const staffs = preapare_staff(item.staff); | |
| 56 | + return ` | |
| 58 | 57 | <div class="tt-meeting-list-item"> |
| 59 | 58 | <!-- Staff --> |
| 60 | 59 | ${staffs} |
| 61 | 60 | <h3 class="tt-title"> |
| @@ -67,22 +66,22 @@ | ||
| 67 | 66 | <!-- meeting info --> |
| 68 | 67 | <ul class="meeting-info-list"> |
| 69 | 68 | <!-- meeting duration --> |
| 70 | 69 | <li> |
| 71 | - <svg fill="#3263F8" width="18" height="18" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"> | |
| 72 | - <path d="M256 512C114.6 512 0 397.4 0 256S114.6 0 256 0S512 114.6 512 256s-114.6 256-256 256zM232 120V256c0 8 4 15.5 10.7 20l96 64c11 7.4 25.9 4.4 33.3-6.7s4.4-25.9-6.7-33.3L280 243.2V120c0-13.3-10.7-24-24-24s-24 10.7-24 24z" /> | |
| 73 | - </svg> | |
| 70 | + <svg width="20" height="20" viewBox="0 0 20 20" fill="CurrentColor" xmlns="http://www.w3.org/2000/svg"> | |
| 71 | + <path fill-rule="evenodd" clip-rule="evenodd" d="M10 2C5.58172 2 2 5.58172 2 10C2 14.4183 5.58172 18 10 18C14.4183 18 18 14.4183 18 10C18 5.58172 14.4183 2 10 2ZM0 10C0 4.47715 4.47715 0 10 0C15.5228 0 20 4.47715 20 10C20 15.5228 15.5228 20 10 20C4.47715 20 0 15.5228 0 10ZM10 3.6C10.5523 3.6 11 4.04772 11 4.6V9.38197L14.0472 10.9056C14.5412 11.1526 14.7414 11.7532 14.4944 12.2472C14.2474 12.7412 13.6468 12.9414 13.1528 12.6944L9.55279 10.8944C9.214 10.725 9 10.3788 9 10V4.6C9 4.04772 9.44771 3.6 10 3.6Z"/> | |
| 72 | + </svg> | |
| 74 | 73 | ${item.duration} |
| 75 | 74 | </li> |
| 76 | 75 | <!-- meeting price --> |
| 77 | 76 | </ul> |
| 78 | 77 | <button class="ant-btn ant-btn-primary ant-btn-block" data-id="${item.id}"> |
| 79 | - Book Appointment | |
| 78 | + Book Now | |
| 80 | 79 | </button> |
| 81 | 80 | <div class="timetics-booking-modal"></div> |
| 82 | - </div> | |
| 83 | - </div>`; | |
| 84 | - }).join(''); | |
| 81 | + </div>`; | |
| 82 | + }) | |
| 83 | + .join(""); | |
| 85 | 84 | |
| 86 | 85 | return meetings; |
| 87 | 86 | } |
| 88 | 87 | |
| @@ -87,32 +86,40 @@ | ||
| 87 | 86 | } |
| 88 | 87 | |
| 89 | 88 | function preapare_staff(staffs) { |
| 90 | 89 | const totalStaff = staffs.length; |
| 91 | - let markup = ''; | |
| 90 | + let markup = ""; | |
| 92 | 91 | |
| 93 | - if ( totalStaff > 2 ) { | |
| 92 | + if (totalStaff > 2) { | |
| 94 | 93 | markup = `<ul class="tt-author tt-author-avatar-list"> |
| 95 | - ${staffs.map(staff => { | |
| 96 | - return ` | |
| 94 | + ${staffs | |
| 95 | + .map((staff) => { | |
| 96 | + return ` | |
| 97 | 97 | <li class="tt-single-host"> |
| 98 | - <img src="${staff.image}" alt="${staff.full_name}" /> | |
| 98 | + ${staff.image | |
| 99 | + ? `<img src="${staff.image}" alt="${staff.full_name}" />` | |
| 100 | + : "" | |
| 101 | + } | |
| 99 | 102 | <div class="tt-tooltip-text">${staff.full_name}</div> |
| 100 | 103 | </li> |
| 101 | - ` | |
| 102 | - }).join('') | |
| 103 | - } | |
| 104 | + `; | |
| 105 | + }) | |
| 106 | + .join("")} | |
| 104 | 107 | </ul>`; |
| 105 | 108 | } else { |
| 106 | 109 | markup = `<ul class="tt-author"> |
| 107 | - ${staffs.map(staff => { | |
| 108 | - return ` | |
| 110 | + ${staffs | |
| 111 | + .map((staff) => { | |
| 112 | + return ` | |
| 109 | 113 | <li> |
| 110 | - <img src="${staff.image}" alt="${staff.full_name}" /> | |
| 114 | + ${staff.image | |
| 115 | + ? `<img src="${staff.image}" alt="${staff.full_name}" />` | |
| 116 | + : "" | |
| 117 | + } | |
| 111 | 118 | <span>${staff.full_name}</span> |
| 112 | 119 | </li>`; |
| 113 | - }).join('') | |
| 114 | - } | |
| 120 | + }) | |
| 121 | + .join("")} | |
| 115 | 122 | </ul>`; |
| 116 | 123 | } |
| 117 | 124 | |
| 118 | 125 | return markup; |