Ignore:
Timestamp:
01/04/24 09:07:47 (6 months ago)
Author:
gjoko kostadinov <gjokokostadinov@…>
Branches:
master
Children:
e8999eb
Parents:
1413ee2
Message:

Fix bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/resources/static/js/business_admin.js

    r1413ee2 r53765dd  
    11$(document).ready(function() {
    22    var business = {};
    3 
    4     getBusinessInfo().then(function (data) {
    5         business = data;
    6     });
     3    var serviceTypeList = {};
     4
     5    getServiceTypes().then(function (serviceTypes) {
     6        serviceTypeList = serviceTypes;
     7        getBusinessInfo(serviceTypes).then(function (data) {
     8            business = data;
     9        });
     10    });
     11
     12
    713
    814    getAppointments();
     
    7177
    7278        updateServices(servicesObj).then(function (response) {
    73             getBusinessInfo().then(function (data) {
     79            getBusinessInfo(serviceTypeList).then(function (data) {
    7480                business = data;
    7581            });
     
    7884        if (servicesForDelete.length > 0) {
    7985            deleteServices(servicesForDelete).then(function (response) {
    80                 getBusinessInfo().then(function (data) {
     86                getBusinessInfo(serviceTypeList).then(function (data) {
    8187                    business = data;
    8288                });
     
    101107
    102108        updateBusinessInfo(businesses).then(function() {
    103             getBusinessInfo().then(function (found) {
     109            getBusinessInfo(serviceTypeList).then(function (found) {
    104110                business = found;
    105111            });
     
    205211}
    206212
    207 function getBusinessInfo() {
     213function getServiceTypes() {
     214    return $.ajax({
     215        url: "http://localhost:8080/api/nomenclature/serviceTypes/me"
     216    }).then(function (serviceTypes) {
     217        return serviceTypes;
     218    });
     219}
     220
     221function getBusinessInfo(serviceTypeList) {
    208222    return $.ajax({
    209223        url: "http://localhost:8080/api/business/me"
     
    231245        var $el = $("#predefined_services_admin_panel");
    232246        $el.empty();
     247        const existingServiceTypeIds = business['services'].map(service => service['serviceType']['id']);
     248        const missingAddedServiceTypes = serviceTypeList.filter(serviceType => existingServiceTypeIds.indexOf(serviceType['id']) === -1);
     249        //console.log(missingAddedServiceTypes);
    233250
    234251        $.each(business['services'], function (index, obj) {
Note: See TracChangeset for help on using the changeset viewer.