[8bcd64c] | 1 | $(document).ready(function() {
|
---|
| 2 |
|
---|
| 3 | var business = {};
|
---|
| 4 |
|
---|
| 5 | $.ajax({
|
---|
| 6 | url: "http://localhost:8080/api/business/me"
|
---|
| 7 | }).then(function (data) {
|
---|
| 8 | business = data;
|
---|
| 9 | console.log(business);
|
---|
| 10 | var $header = $("#header");
|
---|
| 11 |
|
---|
| 12 | // header
|
---|
| 13 | $header.text($header.text() + " " + business["owner"]['firstName'] + " " + business['owner']['lastName']);
|
---|
| 14 |
|
---|
| 15 | // business info
|
---|
| 16 | if(business['businessStatus'] == 'NEW') {
|
---|
| 17 | $('#new_business_warning').removeAttr("hidden");
|
---|
| 18 | }
|
---|
| 19 | $('#business_status').val(business['businessStatus']);
|
---|
| 20 | $('#business_type').val(business['businessType']['text']);
|
---|
| 21 |
|
---|
| 22 | // owner info
|
---|
| 23 | $('#firstName').val(business['owner']['firstName']);
|
---|
| 24 | $('#lastName').val(business['owner']['lastName']);
|
---|
| 25 | $('#email').val(business['owner']['email']);
|
---|
| 26 | $('#username').val(business['owner']['username']);
|
---|
| 27 |
|
---|
| 28 | // services info
|
---|
| 29 | var $el = $("#predefined_services_admin_panel");
|
---|
| 30 | $el.empty();
|
---|
| 31 | $.each(business['services'], function (index, obj) {
|
---|
| 32 | $el.append(
|
---|
| 33 | '<div class=\"form-outline mb-4\">' +
|
---|
| 34 | ' <div class="row">' +
|
---|
| 35 | ' <div class="col-md-6">\n' +
|
---|
| 36 | ' <input class="form-check-input" type="checkbox" checked value=\"' + obj.id + '\" id=\"' + obj.id + '\">\n' +
|
---|
| 37 | ' <label class="form-check-label" for=\"' + obj.id + '\">\n' +
|
---|
| 38 | obj['serviceType'].name +
|
---|
| 39 | ' </label>\n' +
|
---|
| 40 | ' </div>' +
|
---|
| 41 | ' <div class=\"form-outline col-md-2 d-grid\">' +
|
---|
| 42 | ' <input type=\"text\" id=\"' + obj.id + obj['serviceType'].name.replace(/\s/g, "") + "duration" + '\" class=\"form-control\" placeholder="time" value=\"' + obj.duration + '" />' +
|
---|
| 43 | ' </div>' +
|
---|
| 44 | ' <div class=\"form-outline col-md-2 d-grid\">' +
|
---|
| 45 | ' <input type=\"text\" id=\"' + obj.id + obj['serviceType'].name.replace(/\s/g, "") + "price" + '\" class=\"form-control\" placeholder="price" value=\"' + obj.price + '" />' +
|
---|
| 46 | ' </div>' +
|
---|
| 47 | ' </div>' +
|
---|
| 48 | '</div>');
|
---|
| 49 | });
|
---|
| 50 | });
|
---|
| 51 |
|
---|
| 52 | $("#add_service").click(function () {
|
---|
| 53 | var input_service = $("#input_service").val();
|
---|
| 54 | // clear the input
|
---|
| 55 | $("#input_service").val('');
|
---|
| 56 |
|
---|
| 57 | $("#predefined_services_admin_panel").append(
|
---|
| 58 | '<div class="form-outline mb-4">' +
|
---|
| 59 | ' <div class="row">' +
|
---|
| 60 | ' <div class="col-md-6">\n' +
|
---|
| 61 | ' <input class="form-check-input" type="checkbox" checked value="' + -1 + '" id="' + -1 + '">\n' +
|
---|
| 62 | ' <label class="form-check-label" for="' + -1 + '">\n' +
|
---|
| 63 | input_service +
|
---|
| 64 | ' </label>\n' +
|
---|
| 65 | ' </div>' +
|
---|
| 66 | ' <div class="form-outline col-md-2 d-grid">' +
|
---|
| 67 | ' <input type="text" id="' + -1 + input_service.replace(/\s/g, "") + "duration" + '" class="form-control" placeholder="time" />' +
|
---|
| 68 | ' </div>' +
|
---|
| 69 | ' <div class="form-outline col-md-2 d-grid">' +
|
---|
| 70 | ' <input type="text" id="' + -1 + input_service.replace(/\s/g, "") + "price"+ '" class="form-control" placeholder="price" />' +
|
---|
| 71 | ' </div>' +
|
---|
| 72 | ' </div>' +
|
---|
| 73 | '</div>');
|
---|
| 74 | event.preventDefault();
|
---|
| 75 | });
|
---|
| 76 | }); |
---|