Subversion Repositories SmartDukaan

Rev

Rev 31170 | Rev 35502 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31170 Rev 35501
Line 62... Line 62...
62
function loadPartnerPriceCircular(domId) {
62
function loadPartnerPriceCircular(domId) {
63
	doGetAjaxRequestHandler(context + "/partnerPriceCircular",
63
	doGetAjaxRequestHandler(context + "/partnerPriceCircular",
64
		function (response) {
64
		function (response) {
65
			$('#' + domId).html(response);
65
			$('#' + domId).html(response);
66
		});
66
		});
-
 
67
}
-
 
68
 
-
 
69
$(document).on('click', ".today-offer", function () {
-
 
70
    let fofoId = $(this).data('fofoid');
-
 
71
    loadTodayOfferVM("main-content", fofoId);
-
 
72
});
-
 
73
 
-
 
74
// Main function called to load the shell
-
 
75
function loadTodayOfferVM(domId, fofoId) {
-
 
76
    doGetAjaxRequestHandler(context + `/todayOffer?fofoId=${fofoId}`, function (response) {
-
 
77
        // Load the brand tabs
-
 
78
        $('#' + domId).html(response);
-
 
79
 
-
 
80
        // AUTO-LOAD Samsung immediately after tabs are ready
-
 
81
        loadBrandOffers("Motorola", fofoId);
-
 
82
    });
-
 
83
}
-
 
84
 
-
 
85
 
-
 
86
// Click listener for tabs
-
 
87
$(document).on('click', ".brand-tab", function () {
-
 
88
    let fofoId = $(this).data('fofoid');
-
 
89
    let brand = $(this).data("brand");
-
 
90
    loadBrandOffers(brand, fofoId);
-
 
91
});
-
 
92
 
-
 
93
 
-
 
94
// Function to handle the actual data loading
-
 
95
function loadBrandOffers(brandName, fofoId) {
-
 
96
 
-
 
97
 
-
 
98
    // 1. Show the loader immediately
-
 
99
    const loaderHtml = `
-
 
100
        <center><div class="loader-wrapper">
-
 
101
            <i class="fa fa-spinner fa-spin fa-4x"></i>
-
 
102
            <span class="loader-text">Loading offers for ${brandName}...</span>
-
 
103
        </div></center>`;
-
 
104
 
-
 
105
    $('.today-offer-container').html(loaderHtml);
-
 
106
 
-
 
107
    // 2. Prepare the URL
-
 
108
    let todayOfferUrl = `${context}/todayOfferList?brand=${brandName}&fofoId=${fofoId}`;
-
 
109
    if (typeof partnerId == "number") {
-
 
110
        todayOfferUrl = `${todayOfferUrl}&fofoId=${partnerId}`;
-
 
111
    }
-
 
112
 
-
 
113
    // 3. Hit the API
-
 
114
    doGetAjaxRequestHandler(todayOfferUrl, function (response) {
-
 
115
        // Success: The loader is replaced by the actual table response
-
 
116
        $('.today-offer-container').html(response);
-
 
117
 
-
 
118
        // Update Active Tab UI
-
 
119
        $(".brand-tabs li").removeClass("active");
-
 
120
        $(`.brand-tab[data-brand='${brandName}']`).closest('li').addClass("active");
-
 
121
    });
-
 
122
}
-
 
123
 
-
 
124
 
-
 
125
$(document).on('click', '.today-offer-view', function () {
-
 
126
    let offerId = $(this).data("offerid");
-
 
127
    doGetAjaxRequestHandler(`${context}/getOfferMargins?offerId=${offerId}`, function (data) {
-
 
128
        $('#todayOfferDescription .modal-content').html(data);
-
 
129
        $("#todayOfferDescription").modal('show');
-
 
130
    });
-
 
131
});
-
 
132
 
-
 
133
 
-
 
134
$(document).on('click', '.today-fofo-offer', function () {
-
 
135
    let fofoId = $(this).data("fofoid");
-
 
136
    doGetAjaxRequestHandler(`${context}/todayFofoOffer?fofoId=${fofoId}`, function (data) {
-
 
137
        $(".today-fofo-offer-view").show();
-
 
138
        $(".fofo-summry-view").hide();
-
 
139
        $('.today-fofo-offer-view').html(data);
-
 
140
        // AUTO-LOAD Samsung immediately after tabs are ready
-
 
141
        loadFofoBrandOffers("Motorola", fofoId);
-
 
142
    });
-
 
143
});
-
 
144
 
-
 
145
 
-
 
146
$(document).on('click', ".fofo-brand-tab", function () {
-
 
147
    let fofoId = $(this).data('fofoid');
-
 
148
    let brand = $(this).data("brand");
-
 
149
    loadFofoBrandOffers(brand, fofoId);
-
 
150
});
-
 
151
 
-
 
152
 
-
 
153
// Function to handle the actual data loading
-
 
154
function loadFofoBrandOffers(brandName, fofoId) {
-
 
155
 
-
 
156
 
-
 
157
    // 1. Show the loader immediately
-
 
158
    const loaderHtml = `
-
 
159
        <center><div class="loader-wrapper">
-
 
160
            <i class="fa fa-spinner fa-spin fa-4x"></i>
-
 
161
            <span class="loader-text">Loading offers for ${brandName}...</span>
-
 
162
        </div></center>`;
-
 
163
 
-
 
164
    $('.today-fofo-offer-container').html(loaderHtml);
-
 
165
 
-
 
166
    // 2. Prepare the URL
-
 
167
    let todayOfferUrl = `${context}/todayOfferList?brand=${brandName}&fofoId=${fofoId}`;
-
 
168
    if (typeof partnerId == "number") {
-
 
169
        todayOfferUrl = `${todayOfferUrl}&fofoId=${partnerId}`;
-
 
170
    }
-
 
171
 
-
 
172
    // 3. Hit the API
-
 
173
    doGetAjaxRequestHandler(todayOfferUrl, function (response) {
-
 
174
        // Success: The loader is replaced by the actual table response
-
 
175
        $('.today-fofo-offer-container').html(response);
-
 
176
 
-
 
177
        // Update Active Tab UI
-
 
178
        $(".brand-tabs li").removeClass("active");
-
 
179
        $(`.brand-tab[data-brand='${brandName}']`).closest('li').addClass("active");
-
 
180
    });
67
}
181
}
68
182