@mseva/upyog-ui-module-ads 1.0.94 → 1.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -156,7 +156,7 @@ function getMinDateForType(scheduleType) {
156
156
  if (scheduleType === "Monthly" || scheduleType === "Weekly" || scheduleType === "FortNight") {
157
157
  return new Date(year, month, 1).toISOString().split("T")[0];
158
158
  }
159
- if (type === "Yearly") {
159
+ if (scheduleType === "Yearly") {
160
160
  if (month < 3) {
161
161
  return new Date(year - 1, 3, 1).toISOString().split("T")[0];
162
162
  } else {
@@ -165,6 +165,86 @@ function getMinDateForType(scheduleType) {
165
165
  }
166
166
  return today.toISOString().split("T")[0];
167
167
  }
168
+ const getCurrentEpoch = () => Date.now();
169
+ const groupKeyForCart = c => `${c.location || "NA"}|${c.advertisementId || "NA"}|${c.addType || "NA"}|${c.faceArea || "NA"}|${c.advertisementName || "NA"}|${c.poleNo || "NA"}`;
170
+ const transformBookingResponseToBookingData = (apiResponse = {}) => {
171
+ const resp = apiResponse || {};
172
+ const apps = Array.isArray(resp.bookingApplication) ? resp.bookingApplication : [];
173
+ const transformedApps = apps.map(app => {
174
+ const out = {};
175
+ const copyFields = ["bookingNo", "paymentDate", "draftId", "applicationDate", "tenantId", "receiptNo", "permissionLetterFilestoreId", "paymentReceiptFilestoreId", "advertisementId", "bookingId", "bookingStatus", "auditDetails", "businessService", "workflow"];
176
+ copyFields.forEach(k => {
177
+ if (Object.prototype.hasOwnProperty.call(app, k)) out[k] = app[k];
178
+ });
179
+ out.applicantDetail = app.applicantDetail || null;
180
+ out.address = app.address || null;
181
+ out.owners = app.owners || [];
182
+ out.documents = app.documents || [];
183
+ const cart = Array.isArray(app.cartDetails) ? app.cartDetails : [];
184
+ const groups = cart.reduce((acc, item) => {
185
+ const key = groupKeyForCart(item);
186
+ if (!acc[key]) acc[key] = [];
187
+ acc[key].push(item);
188
+ return acc;
189
+ }, {});
190
+ const groupedCartDetails = Object.keys(groups).map(key => {
191
+ var _sorted$, _sorted;
192
+ const items = groups[key];
193
+ const sorted = items.slice().sort((a, b) => new Date(a.bookingDate) - new Date(b.bookingDate));
194
+ const startDate = ((_sorted$ = sorted[0]) === null || _sorted$ === void 0 ? void 0 : _sorted$.bookingDate) || null;
195
+ const endDate = ((_sorted = sorted[sorted.length - 1]) === null || _sorted === void 0 ? void 0 : _sorted.bookingDate) || null;
196
+ const numberOfDays = sorted.length;
197
+ const first = sorted[0] || {};
198
+ const amounts = sorted.map(s => typeof s.amount === "number" ? s.amount : null);
199
+ const hasAmounts = amounts.every(a => a !== null);
200
+ let amount = undefined;
201
+ let amountForDaysChosen = undefined;
202
+ if (hasAmounts) {
203
+ const total = amounts.reduce((acc, v) => acc + v, 0);
204
+ amountForDaysChosen = total;
205
+ amount = sorted.length ? Math.round(total / sorted.length * 100) / 100 : 0;
206
+ } else if (typeof first.amount === "number") {
207
+ amount = first.amount;
208
+ }
209
+ return {
210
+ location: first.location,
211
+ advertisementId: first.advertisementId || first.advertisementId === 0 ? `${first.advertisementId}` : undefined,
212
+ startDate,
213
+ endDate,
214
+ numberOfDays,
215
+ addType: first.addType,
216
+ faceArea: first.faceArea,
217
+ nightLight: first.nightLight,
218
+ status: first.status,
219
+ advertisementName: first.advertisementName,
220
+ poleNo: first.poleNo,
221
+ amount,
222
+ amountForDaysChosen
223
+ };
224
+ });
225
+ out.cartDetails = groupedCartDetails;
226
+ return out;
227
+ });
228
+ const totalCount = transformedApps.reduce((acc, app) => {
229
+ const sum = Array.isArray(app.cartDetails) ? app.cartDetails.reduce((s, cd) => s + (cd.numberOfDays || 0), 0) : 0;
230
+ return acc + sum;
231
+ }, 0);
232
+ const bookingData = [{
233
+ count: totalCount,
234
+ currentTime: getCurrentEpoch(),
235
+ bookingApplication: transformedApps
236
+ }];
237
+ return {
238
+ bookingData
239
+ };
240
+ };
241
+ const areSlotsEqual = (a = [], b = []) => {
242
+ if ((a === null || a === void 0 ? void 0 : a.length) !== (b === null || b === void 0 ? void 0 : b.length)) return false;
243
+ const key = s => s === null || s === void 0 ? void 0 : s.bookingDate;
244
+ const aKeys = a === null || a === void 0 ? void 0 : a.map(key).sort();
245
+ const bKeys = b === null || b === void 0 ? void 0 : b.map(key).sort();
246
+ return (JSON === null || JSON === void 0 ? void 0 : JSON.stringify(aKeys)) === (JSON === null || JSON === void 0 ? void 0 : JSON.stringify(bKeys));
247
+ };
168
248
  function transformAdsData(adsData) {
169
249
  var _Object$values;
170
250
  const grouped = {};
@@ -18482,10 +18562,6 @@ const InboxLinks = ({
18482
18562
  text: t("ES_TITLE_NEW_ADD_BOOKING"),
18483
18563
  link: "/digit-ui/employee/ads/bookad",
18484
18564
  roles: []
18485
- }, {
18486
- text: t("ADS_MY_APPLICATIONS"),
18487
- link: `/digit-ui/employee/ads/my-applications`,
18488
- roles: []
18489
18565
  }];
18490
18566
  const [links, setLinks] = useState([]);
18491
18567
  const {
@@ -21918,181 +21994,181 @@ const getAcknowledgement = async (application, t) => {
21918
21994
  });
21919
21995
  const qrDataURL = await browser.toDataURL(window.location.href);
21920
21996
  const content = `
21921
- <html>
21922
- <head>
21923
- <title>Advertisement and Hoarding Booking Acknowledgement</title>
21924
- <style>
21925
- @page { margin: 0.5in; }
21926
- body {
21927
- font-family: 'Arial', sans-serif;
21928
- margin: 0;
21929
- padding: 20px;
21930
- font-size: 14px;
21931
- line-height: 1.6;
21932
- }
21933
- .acknowledgement-container {
21934
- max-width: 800px;
21935
- margin: 0 auto;
21936
- border: 2px solid #333;
21937
- padding: 30px;
21938
- background: white;
21939
- }
21940
- .header {
21941
- display: flex;
21942
- justify-content: space-between;
21943
- align-items: center;
21944
- text-align: center;
21945
- margin-bottom: 30px;
21946
- border-bottom: 2px solid #333;
21947
- padding-bottom: 20px;
21948
- position: relative;
21949
- }
21950
- .header-left,
21951
- .header-right {
21952
- flex: 0 0 auto;
21953
- }
21997
+ <html>
21998
+ <head>
21999
+ <title>${t("ADS_ACKNOWLEDGMENT_FORM")}</title>
22000
+ <style>
22001
+ @page { margin: 0.5in; }
22002
+ body {
22003
+ font-family: 'Arial', sans-serif;
22004
+ margin: 0;
22005
+ padding: 20px;
22006
+ font-size: 14px;
22007
+ line-height: 1.6;
22008
+ }
22009
+ .acknowledgement-container {
22010
+ max-width: 800px;
22011
+ margin: 0 auto;
22012
+ border: 2px solid #333;
22013
+ padding: 30px;
22014
+ background: white;
22015
+ }
22016
+ .header {
22017
+ display: flex;
22018
+ justify-content: space-between;
22019
+ align-items: center;
22020
+ text-align: center;
22021
+ margin-bottom: 30px;
22022
+ border-bottom: 2px solid #333;
22023
+ padding-bottom: 20px;
22024
+ position: relative;
22025
+ }
22026
+ .header-left,
22027
+ .header-right {
22028
+ flex: 0 0 auto;
22029
+ }
22030
+ .header-center {
22031
+ text-align: center;
22032
+ flex: 1;
22033
+ }
22034
+ .title {
22035
+ font-size: 20px;
22036
+ font-weight: bold;
22037
+ margin: 10px 0;
22038
+ color: #333;
22039
+ }
22040
+ .subtitle {
22041
+ font-size: 16px;
22042
+ margin: 5px 0;
22043
+ color: #666;
22044
+ }
22045
+ .acknowledgement-text {
22046
+ margin: 20px 0;
22047
+ text-align: justify;
22048
+ font-size: 15px;
22049
+ }
22050
+ .details-table {
22051
+ width: 100%;
22052
+ border-collapse: collapse;
22053
+ margin: 20px 0;
22054
+ }
22055
+ .details-table th,
22056
+ .details-table td {
22057
+ padding: 12px;
22058
+ text-align: left;
22059
+ border: 1px solid #ddd;
22060
+ }
22061
+ .details-table th {
22062
+ background: #f5f5f5;
22063
+ font-weight: bold;
22064
+ width: 40%;
22065
+ }
22066
+ .footer {
22067
+ margin-top: 30px;
22068
+ text-align: center;
22069
+ font-size: 12px;
22070
+ color: #666;
22071
+ }
22072
+ @media print {
22073
+ body { background: white !important; }
22074
+ }
22075
+ </style>
22076
+ </head>
22077
+ <body>
22078
+ <div class="acknowledgement-container">
22079
+ <div class="header">
22080
+ <div class="header-left">
22081
+ <img src="https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.amritsar/logo.png"
22082
+ style="width: 120px; height: 120px;" />
22083
+ </div>
22084
+ <div class="header-center">
22085
+ <div class="title">Advertisement and Hoarding Booking Acknowledgement</div>
22086
+ <div class="subtitle">Municipal Corporation</div>
22087
+ </div>
22088
+ <div class="header-right">
22089
+ <img src="${qrDataURL}" style="width: 120px; height: 120px;" />
22090
+ </div>
22091
+ </div>
21954
22092
 
21955
- .header-center {
21956
- text-align: center;
21957
- flex: 1;
21958
- }
21959
- .title {
21960
- font-size: 20px;
21961
- font-weight: bold;
21962
- margin: 10px 0;
21963
- color: #333;
21964
- }
21965
- .subtitle {
21966
- font-size: 16px;
21967
- margin: 5px 0;
21968
- color: #666;
21969
- }
21970
- .acknowledgement-text {
21971
- margin: 20px 0;
21972
- text-align: justify;
21973
- font-size: 15px;
21974
- }
21975
- .details-table {
21976
- width: 100%;
21977
- border-collapse: collapse;
21978
- margin: 20px 0;
21979
- }
21980
- .details-table th,
21981
- .details-table td {
21982
- padding: 12px;
21983
- text-align: left;
21984
- border: 1px solid #ddd;
21985
- }
21986
- .details-table th {
21987
- background: #f5f5f5;
21988
- font-weight: bold;
21989
- width: 40%;
21990
- }
21991
- .footer {
21992
- margin-top: 30px;
21993
- text-align: center;
21994
- font-size: 12px;
21995
- color: #666;
21996
- }
21997
- @media print {
21998
- body { background: white !important; }
21999
- }
22000
- </style>
22001
- </head>
22002
- <body>
22003
- <div class="acknowledgement-container">
22004
- <div class="header">
22005
- <div class="header-left">
22006
- <img src="https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.amritsar/logo.png"
22007
- style="width: 120px; height: 120px;" />
22008
- </div>
22009
- <div class="header-center">
22010
- <div class="title">Advertisement and Hoarding Booking Acknowledgement</div>
22011
- <div class="subtitle">Municipal Corporation</div>
22012
- </div>
22013
- <div class="header-right">
22014
- <img src="${qrDataURL}" style="width: 120px; height: 120px;" />
22015
- </div>
22016
- </div>
22093
+ <div class="acknowledgement-text">
22094
+ ${t("ADV_ACK_TEXT_2")}
22095
+ </div>
22017
22096
 
22097
+ <h3>${t("ADS_APPLICANT_DETAILS")}</h3>
22098
+ <table class="details-table">
22099
+ <tr>
22100
+ <th>${t("WS_COMMON_TABLE_COL_APP_NO_LABEL")}</th>
22101
+ <td>${(application === null || application === void 0 ? void 0 : application.bookingNo) || "Not Available"}</td>
22102
+ </tr>
22103
+ <tr>
22104
+ <th>${t("BPA_BASIC_DETAILS_APPLICATION_DATE_LABEL")}</th>
22105
+ <td>${application !== null && application !== void 0 && application.applicationDate ? new Date(application === null || application === void 0 ? void 0 : application.applicationDate).toLocaleDateString("en-GB") : "N/A"}</td>
22106
+ </tr>
22107
+ <tr>
22108
+ <th>${t("BPA_BASIC_DETAILS_APPLICATION_NAME_LABEL")}</th>
22109
+ <td>${(application === null || application === void 0 ? void 0 : (_application$applican = application.applicantDetail) === null || _application$applican === void 0 ? void 0 : _application$applican.applicantName) || "Not Specified"}</td>
22110
+ </tr>
22111
+ <tr>
22112
+ <th>${t("PDF_STATIC_LABEL_WS_CONSOLIDATED_CONCERNED_PLUMBER_CONTACT")}</th>
22113
+ <td>${(application === null || application === void 0 ? void 0 : (_application$applican2 = application.applicantDetail) === null || _application$applican2 === void 0 ? void 0 : _application$applican2.applicantMobileNo) || "Not Specified"}</td>
22114
+ </tr>
22115
+ <tr>
22116
+ <th>${t("ADS_ALTERNATE_NUMBER")}</th>
22117
+ <td>${(application === null || application === void 0 ? void 0 : (_application$applican3 = application.applicantDetail) === null || _application$applican3 === void 0 ? void 0 : _application$applican3.applicantAlternateMobileNo) || "Not Specified"}</td>
22118
+ </tr>
22119
+ <tr>
22120
+ <th>${t("PDF_STATIC_LABEL_WS_CONSOLIDATED_ACKNOWELDGMENT_EMAIL")}</th>
22121
+ <td>${(application === null || application === void 0 ? void 0 : (_application$applican4 = application.applicantDetail) === null || _application$applican4 === void 0 ? void 0 : _application$applican4.applicantEmailId) || "Not Specified"}</td>
22122
+ </tr>
22123
+ <tr>
22124
+ <th>${t("TL_HOME_SEARCH_RESULTS_APP_STATUS_LABEL")}</th>
22125
+ <td style="color: #28a745; font-weight: bold;">${t(application === null || application === void 0 ? void 0 : application.bookingStatus) || "SUBMITTED"}</td>
22126
+ </tr>
22127
+ </table>
22018
22128
 
22019
-
22020
-
22021
- <div class="acknowledgement-text">
22022
- This is to acknowledge that we have received your application for Advertisement and Hoarding Booking.
22023
- Your application has been processed and the details are as follows:
22024
- </div>
22025
- <h3>Applicant Details</h3>
22026
- <table class="details-table">
22027
- <tr>
22028
- <th>Application Number</th>
22029
- <td>${(application === null || application === void 0 ? void 0 : application.bookingNo) || "Not Available"}</td>
22030
- </tr>
22031
- <tr>
22032
- <th>Application Date</th>
22033
- <td>${application !== null && application !== void 0 && application.applicationDate ? new Date(application === null || application === void 0 ? void 0 : application.applicationDate).toLocaleDateString("en-GB") : "N/A"}</td>
22034
- </tr>
22035
- <tr>
22036
- <th>Applicant Name</th>
22037
- <td>${(application === null || application === void 0 ? void 0 : (_application$applican = application.applicantDetail) === null || _application$applican === void 0 ? void 0 : _application$applican.applicantName) || "Not Specified"}</td>
22038
- </tr>
22039
- <tr>
22040
- <th>Contact Number</th>
22041
- <td>${(application === null || application === void 0 ? void 0 : (_application$applican2 = application.applicantDetail) === null || _application$applican2 === void 0 ? void 0 : _application$applican2.applicantMobileNo) || "Not Specified"}</td>
22042
- </tr>
22043
- <tr>
22044
- <th>Alternate Contact Number</th>
22045
- <td>${(application === null || application === void 0 ? void 0 : (_application$applican3 = application.applicantDetail) === null || _application$applican3 === void 0 ? void 0 : _application$applican3.applicantAlternateMobileNo) || "Not Specified"}</td>
22046
- </tr>
22047
- <tr>
22048
- <th>Email</th>
22049
- <td>${(application === null || application === void 0 ? void 0 : (_application$applican4 = application.applicantDetail) === null || _application$applican4 === void 0 ? void 0 : _application$applican4.applicantEmailId) || "Not Specified"}</td>
22050
- </tr>
22051
- <tr>
22052
- <th>Application Status</th>
22053
- <td style="color: #28a745; font-weight: bold;">${t(application === null || application === void 0 ? void 0 : application.bookingStatus) || "SUBMITTED"}</td>
22054
- </tr>
22055
- </table>
22056
- ${(application === null || application === void 0 ? void 0 : (_application$cartDeta = application.cartDetails) === null || _application$cartDeta === void 0 ? void 0 : _application$cartDeta.length) > 0 ? `
22057
- <h3>Advertisement Details</h3>
22058
- <table class="details-table">
22129
+ ${(application === null || application === void 0 ? void 0 : (_application$cartDeta = application.cartDetails) === null || _application$cartDeta === void 0 ? void 0 : _application$cartDeta.length) > 0 ? `
22130
+ <h3>${t("ADVERTISEMENT_DETAILS")}</h3>
22131
+ <table class="details-table">
22132
+ <tr>
22133
+ <th>${t("ADS_AD_TYPE")}</th>
22134
+ <th>${t("CS_ADDCOMPLAINT_LOCATION")}</th>
22135
+ <th>${t("ADS_FACE_AREA")}</th>
22136
+ <th>${t("CHB_BOOKING_DATE")}</th>
22137
+ <th>${t("ADS_FROM_TIME")}</th>
22138
+ <th>${t("ADS_TO_TIME")}</th>
22139
+ <th>${t("ADS_NIGHT_LIGHT")}</th>
22140
+ <th>${t("PT_OWNERSHIP_INFO_NAME")}</th>
22141
+ <th>${t("POLE_NO")}</th>
22142
+ </tr>
22143
+ ${application.cartDetails.map(item => `
22059
22144
  <tr>
22060
- <th>Advertisement Type</th>
22061
- <th>Location</th>
22062
- <th>Face Area</th>
22063
- <th>Booking Date</th>
22064
- <th>From Time</th>
22065
- <th>To Time</th>
22066
- <th>Night Light</th>
22145
+ <td>${t(item.addType) || "N/A"}</td>
22146
+ <td>${t(item.location) || "N/A"}</td>
22147
+ <td>${t(item.faceArea.replace(item.addType + "_", "")) || "N/A"}</td>
22148
+ <td>${item.bookingDate || "N/A"}</td>
22149
+ <td>${item.bookingFromTime || "N/A"}</td>
22150
+ <td>${item.bookingToTime || "N/A"}</td>
22151
+ <td>${item.nightLight ? "With Light" : "Without Light"}</td>
22152
+ <td>${item.advertisementName || "N/A"}</td>
22153
+ <td>${item.poleNo || "N/A"}</td>
22067
22154
  </tr>
22068
- ${application.cartDetails.map(item => `
22069
- <tr>
22070
- <td>${t(item.addType) || "N/A"}</td>
22071
- <td>${t(item.location) || "N/A"}</td>
22072
- <td>${t(item.faceArea.replace(item.addType + "_", "")) || "N/A"}</td>
22073
- <td>${item.bookingDate || "N/A"}</td>
22074
- <td>${item.bookingFromTime || "N/A"}</td>
22075
- <td>${item.bookingToTime || "N/A"}</td>
22076
- <td>${item.nightLight ? "With Light" : "Without Light"}</td>
22077
- </tr>
22078
- `).join("")}
22079
- </table>
22080
- ` : ""}
22081
- <div class="acknowledgement-text">
22082
- Please keep this acknowledgement for your records. You will be notified once your
22083
- application is processed and approved. For any queries, please contact the Municipal
22084
- Corporation office with your application number.
22085
- </div>
22086
-
22087
- <div class="footer">
22088
- <p>Generated on: ${currentDate}</p>
22089
- <p>Municipal Corporation</p>
22090
- <p>This is a computer-generated document and does not require a signature.</p>
22091
- </div>
22092
- </div>
22093
- </body>
22094
- </html>
22095
- `;
22155
+ `).join("")}
22156
+ </table>
22157
+ ` : ""}
22158
+
22159
+ <div class="acknowledgement-text">
22160
+ ${t("ADV_ACK_TEXT_1")}
22161
+ </div>
22162
+
22163
+ <div class="footer">
22164
+ <p>Generated on: ${currentDate}</p>
22165
+ <p>Municipal Corporation</p>
22166
+ <p>This is a computer-generated document and does not require a signature.</p>
22167
+ </div>
22168
+ </div>
22169
+ </body>
22170
+ </html>
22171
+ `;
22096
22172
  const printWindow = window.open("", "_blank");
22097
22173
  printWindow.document.write(content);
22098
22174
  printWindow.document.close();
@@ -22234,10 +22310,11 @@ const ADSApplicationDetails = () => {
22234
22310
  bookingNo: acknowledgementIds
22235
22311
  }
22236
22312
  });
22313
+ const new_data = transformBookingResponseToBookingData(adsData);
22314
+ const mutation = Digit.Hooks.ads.useADSCreateAPI(tenantId, false);
22237
22315
  useEffect(() => {
22238
22316
  refetch();
22239
22317
  }, [acknowledgementIds, refetch]);
22240
- const mutation = Digit.Hooks.ads.useADSCreateAPI(tenantId, false);
22241
22318
  const BookingApplication = get_1(adsData, "bookingApplication", []);
22242
22319
  const adsId = get_1(adsData, "bookingApplication[0].bookingNo", []);
22243
22320
  let ads_details = BookingApplication && BookingApplication.length > 0 && BookingApplication[0] || {};
@@ -22303,22 +22380,40 @@ const ADSApplicationDetails = () => {
22303
22380
  payments,
22304
22381
  ...params
22305
22382
  }) {
22306
- var _response;
22307
- let response = {
22308
- filestoreIds: [payments === null || payments === void 0 ? void 0 : payments.fileStoreId]
22309
- };
22310
- response = await Digit.PaymentService.generatePdf(tenantId, {
22383
+ let application = new_data;
22384
+ const response = await Digit.PaymentService.generatePdf(tenantId, {
22311
22385
  Payments: [{
22312
- ...payments
22386
+ ...payments,
22387
+ ...application
22313
22388
  }]
22314
- }, "petservice-receipt");
22389
+ }, "adv-bill");
22315
22390
  const fileStore = await Digit.PaymentService.printReciept(tenantId, {
22316
22391
  fileStoreIds: response.filestoreIds[0]
22317
22392
  });
22318
- window.open(fileStore[(_response = response) === null || _response === void 0 ? void 0 : _response.filestoreIds[0]], "_blank");
22393
+ window.open(fileStore[response === null || response === void 0 ? void 0 : response.filestoreIds[0]], "_blank");
22394
+ }
22395
+ async function getPermissionLetter({
22396
+ tenantId,
22397
+ payments,
22398
+ ...params
22399
+ }) {
22400
+ let application = new_data;
22401
+ let fileStoreId = application === null || application === void 0 ? void 0 : application.permissionLetterFilestoreId;
22402
+ if (!fileStoreId) {
22403
+ const response = await Digit.PaymentService.generatePdf(tenantId, {
22404
+ Payments: [{
22405
+ ...payments,
22406
+ ...application
22407
+ }]
22408
+ }, "adv-permissionletter");
22409
+ fileStoreId = response === null || response === void 0 ? void 0 : response.filestoreIds[0];
22410
+ }
22411
+ const fileStore = await Digit.PaymentService.printReciept(tenantId, {
22412
+ fileStoreIds: fileStoreId
22413
+ });
22414
+ window.open(fileStore[fileStoreId], "_blank");
22319
22415
  }
22320
22416
  const downloadAcknowledgement = async application => {
22321
- console.log("application my details", application);
22322
22417
  try {
22323
22418
  if (!application) {
22324
22419
  throw new Error("Booking Application data is missing");
@@ -22372,7 +22467,7 @@ const ADSApplicationDetails = () => {
22372
22467
  }))) || [];
22373
22468
  if (reciept_data && (reciept_data === null || reciept_data === void 0 ? void 0 : reciept_data.Payments.length) > 0 && !recieptDataLoading) {
22374
22469
  dowloadOptions.push({
22375
- label: t("PTR_FEE_RECIEPT"),
22470
+ label: t("CHB_FEE_RECEIPT"),
22376
22471
  onClick: () => {
22377
22472
  var _reciept_data$Payment;
22378
22473
  return getRecieptSearch({
@@ -22381,6 +22476,16 @@ const ADSApplicationDetails = () => {
22381
22476
  });
22382
22477
  }
22383
22478
  });
22479
+ dowloadOptions.push({
22480
+ label: t("CHB_PERMISSION_LETTER"),
22481
+ onClick: () => {
22482
+ var _reciept_data$Payment2;
22483
+ return getPermissionLetter({
22484
+ tenantId: reciept_data === null || reciept_data === void 0 ? void 0 : (_reciept_data$Payment2 = reciept_data.Payments[0]) === null || _reciept_data$Payment2 === void 0 ? void 0 : _reciept_data$Payment2.tenantId,
22485
+ payments: reciept_data === null || reciept_data === void 0 ? void 0 : reciept_data.Payments[0]
22486
+ });
22487
+ }
22488
+ });
22384
22489
  }
22385
22490
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
22386
22491
  className: "cardHeaderWithOptions",
@@ -22678,6 +22783,7 @@ const ApplicationDetails = () => {
22678
22783
  const normalizedAppObject = (applicationDetails === null || applicationDetails === void 0 ? void 0 : (_applicationDetails$b = applicationDetails.bookingApplication) === null || _applicationDetails$b === void 0 ? void 0 : _applicationDetails$b[0]) ?? [];
22679
22784
  const bookingObj = normalizedAppObject;
22680
22785
  const application = bookingObj || normalizedAppObject || appDetails || null;
22786
+ const new_data = transformBookingResponseToBookingData(applicationDetails);
22681
22787
  const menuRef = useRef();
22682
22788
  const [displayMenu, setDisplayMenu] = useState(false);
22683
22789
  const [selectedAction, setSelectedAction] = useState(null);
@@ -22759,10 +22865,8 @@ const ApplicationDetails = () => {
22759
22865
  } else {
22760
22866
  setAppDetails({});
22761
22867
  }
22762
- console.debug("bookingObj (normalized):", bookingObj, "isLoading:", isLoading);
22763
22868
  }, [isLoading, bookingObj]);
22764
22869
  const downloadAcknowledgement = async application => {
22765
- console.log("application my details", application);
22766
22870
  try {
22767
22871
  if (!application) {
22768
22872
  throw new Error("Booking Application data is missing");
@@ -22894,19 +22998,39 @@ const ApplicationDetails = () => {
22894
22998
  payments,
22895
22999
  ...params
22896
23000
  }) {
22897
- var _response;
22898
- let response = {
22899
- filestoreIds: [payments === null || payments === void 0 ? void 0 : payments.fileStoreId]
22900
- };
22901
- response = await Digit.PaymentService.generatePdf(tenantId, {
23001
+ let application = new_data;
23002
+ const response = await Digit.PaymentService.generatePdf(tenantId, {
22902
23003
  Payments: [{
22903
- ...payments
23004
+ ...payments,
23005
+ ...application
22904
23006
  }]
22905
- }, "adv-receipt");
23007
+ }, "adv-bill");
22906
23008
  const fileStore = await Digit.PaymentService.printReciept(tenantId, {
22907
23009
  fileStoreIds: response.filestoreIds[0]
22908
23010
  });
22909
- window.open(fileStore[(_response = response) === null || _response === void 0 ? void 0 : _response.filestoreIds[0]], "_blank");
23011
+ window.open(fileStore[response === null || response === void 0 ? void 0 : response.filestoreIds[0]], "_blank");
23012
+ }
23013
+ async function getPermissionLetter({
23014
+ tenantId,
23015
+ payments,
23016
+ ...params
23017
+ }) {
23018
+ let application = new_data;
23019
+ let fileStoreId = application === null || application === void 0 ? void 0 : application.permissionLetterFilestoreId;
23020
+ if (!fileStoreId) {
23021
+ const response = await Digit.PaymentService.generatePdf(tenantId, {
23022
+ Payments: [{
23023
+ ...payments,
23024
+ ...application
23025
+ }]
23026
+ }, "adv-permissionletter");
23027
+ fileStoreId = response === null || response === void 0 ? void 0 : response.filestoreIds[0];
23028
+ refetch();
23029
+ }
23030
+ const fileStore = await Digit.PaymentService.printReciept(tenantId, {
23031
+ fileStoreIds: fileStoreId
23032
+ });
23033
+ window.open(fileStore[fileStoreId], "_blank");
22910
23034
  }
22911
23035
  let downloadOptions = [];
22912
23036
  downloadOptions.push({
@@ -22915,7 +23039,7 @@ const ApplicationDetails = () => {
22915
23039
  });
22916
23040
  if (reciept_data && (reciept_data === null || reciept_data === void 0 ? void 0 : (_reciept_data$Payment = reciept_data.Payments) === null || _reciept_data$Payment === void 0 ? void 0 : _reciept_data$Payment.length) > 0 && recieptDataLoading === false) {
22917
23041
  downloadOptions.push({
22918
- label: t("PTR_FEE_RECEIPT"),
23042
+ label: t("CHB_FEE_RECEIPT"),
22919
23043
  onClick: () => {
22920
23044
  var _reciept_data$Payment2;
22921
23045
  return getRecieptSearch({
@@ -22924,6 +23048,16 @@ const ApplicationDetails = () => {
22924
23048
  });
22925
23049
  }
22926
23050
  });
23051
+ if (reciept_data && (reciept_data === null || reciept_data === void 0 ? void 0 : reciept_data.Payments.length) > 0 && !recieptDataLoading) downloadOptions.push({
23052
+ label: t("CHB_PERMISSION_LETTER"),
23053
+ onClick: () => {
23054
+ var _reciept_data$Payment3;
23055
+ return getPermissionLetter({
23056
+ tenantId: reciept_data === null || reciept_data === void 0 ? void 0 : (_reciept_data$Payment3 = reciept_data.Payments[0]) === null || _reciept_data$Payment3 === void 0 ? void 0 : _reciept_data$Payment3.tenantId,
23057
+ payments: reciept_data === null || reciept_data === void 0 ? void 0 : reciept_data.Payments[0]
23058
+ });
23059
+ }
23060
+ });
22927
23061
  }
22928
23062
  const cartData = transformAdsData(bookingObj === null || bookingObj === void 0 ? void 0 : bookingObj.cartDetails);
22929
23063
  const [expired, setExpired] = useState(false);
@@ -23971,7 +24105,8 @@ const AvailabilityModal = ({
23971
24105
  onSelectSlot,
23972
24106
  dateRange,
23973
24107
  t,
23974
- cartSlots
24108
+ cartSlots,
24109
+ onRemoveSlot
23975
24110
  }) => {
23976
24111
  var _cartSlots$find;
23977
24112
  const [selectedSlots, setSelectedSlots] = useState([]);
@@ -24025,22 +24160,40 @@ const AvailabilityModal = ({
24025
24160
  addType: ad === null || ad === void 0 ? void 0 : ad.adType,
24026
24161
  amount: ad === null || ad === void 0 ? void 0 : ad.amount,
24027
24162
  bookingDate: dateRange === null || dateRange === void 0 ? void 0 : dateRange.startDate,
24028
- nightLight: (ad === null || ad === void 0 ? void 0 : ad.light) === "With Light" ? true : false,
24163
+ nightLight: (ad === null || ad === void 0 ? void 0 : ad.light) === "With Light",
24029
24164
  bookingStartDate: dateRange === null || dateRange === void 0 ? void 0 : dateRange.startDate,
24030
24165
  bookingEndDate: dateRange === null || dateRange === void 0 ? void 0 : dateRange.endDate
24031
24166
  });
24032
- setSelectedSlots([]);
24033
- setSelectAll(false);
24034
- onClose();
24167
+ } else if ((existingForAd === null || existingForAd === void 0 ? void 0 : existingForAd.length) > 0) {
24168
+ onRemoveSlot(ad);
24035
24169
  }
24170
+ setSelectedSlots([]);
24171
+ setSelectAll(false);
24172
+ onClose();
24036
24173
  };
24174
+ useEffect(() => {
24175
+ if (allInCart) {
24176
+ setSelectAll(true);
24177
+ }
24178
+ }, [allInCart]);
24179
+ const hasChanges = !areSlotsEqual(selectedSlots, existingForAd);
24180
+ useEffect(() => {
24181
+ if ((existingForAd === null || existingForAd === void 0 ? void 0 : existingForAd.length) > 0) {
24182
+ setSelectAll(true);
24183
+ setSelectedSlots(existingForAd);
24184
+ } else {
24185
+ setSelectAll(false);
24186
+ setSelectedSlots([]);
24187
+ }
24188
+ }, [ad === null || ad === void 0 ? void 0 : ad.id]);
24037
24189
  const columns = [{
24038
24190
  Header: () => /*#__PURE__*/React.createElement("input", {
24039
24191
  type: "checkbox",
24040
- checked: allInCart || selectAll,
24192
+ checked: selectAll,
24193
+ disabled: allBooked,
24041
24194
  onChange: e => handleSelectAll(e.target.checked),
24042
24195
  style: {
24043
- cursor: "pointer",
24196
+ cursor: allBooked ? "not-allowed" : "pointer",
24044
24197
  width: "18px",
24045
24198
  height: "18px",
24046
24199
  accentColor: "#0b74de"
@@ -24051,7 +24204,7 @@ const AvailabilityModal = ({
24051
24204
  row
24052
24205
  }) => {
24053
24206
  const slot = row === null || row === void 0 ? void 0 : row.original;
24054
- const isChecked = allInCart || selectAll && (slot === null || slot === void 0 ? void 0 : slot.slotStaus) === "AVAILABLE";
24207
+ const isChecked = selectAll && (slot === null || slot === void 0 ? void 0 : slot.slotStaus) === "AVAILABLE";
24055
24208
  return /*#__PURE__*/React.createElement("input", {
24056
24209
  type: "checkbox",
24057
24210
  checked: isChecked,
@@ -24217,18 +24370,18 @@ const AvailabilityModal = ({
24217
24370
  }
24218
24371
  }, t ? t("Cancel") : "Cancel"), /*#__PURE__*/React.createElement("button", {
24219
24372
  onClick: handleAddToCart,
24220
- disabled: (selectedSlots === null || selectedSlots === void 0 ? void 0 : selectedSlots.length) === 0,
24373
+ disabled: !hasChanges,
24221
24374
  style: {
24222
24375
  padding: "10px 18px",
24223
24376
  borderRadius: "6px",
24224
24377
  border: "none",
24225
- background: (selectedSlots === null || selectedSlots === void 0 ? void 0 : selectedSlots.length) > 0 ? "#2947a3" : "#ccc",
24378
+ background: hasChanges ? "#2947a3" : "#ccc",
24226
24379
  color: "#fff",
24227
24380
  fontWeight: 600,
24228
- cursor: (selectedSlots === null || selectedSlots === void 0 ? void 0 : selectedSlots.length) > 0 ? "pointer" : "not-allowed",
24381
+ cursor: hasChanges ? "pointer" : "not-allowed",
24229
24382
  transition: "background 0.2s"
24230
24383
  }
24231
- }, "\uD83D\uDED2 ", (existingForAd === null || existingForAd === void 0 ? void 0 : existingForAd.length) > 0 ? t("ADS_UPDATE_CART") : t("ADS_ADD_TO_CART")))));
24384
+ }, "\uD83D\uDED2 ", (existingForAd === null || existingForAd === void 0 ? void 0 : existingForAd.length) > 0 ? t("COMMON_REMOVE_LABEL") : t("ADS_ADD_TO_CART")))));
24232
24385
  };
24233
24386
 
24234
24387
  const CartModal = ({
@@ -24615,7 +24768,7 @@ const AdCard = ({
24615
24768
  cursor: "pointer",
24616
24769
  fontSize: 14
24617
24770
  }
24618
- }, t("ADS_VIEW_AVAILABIITY"), "\uD83D\uDC41\uFE0F"), isAdded && /*#__PURE__*/React.createElement("button", {
24771
+ }, t("ADS_VIEW_AVAILABILITY"), "\uD83D\uDC41\uFE0F"), isAdded && /*#__PURE__*/React.createElement("button", {
24619
24772
  type: "button",
24620
24773
  onClick: openCart,
24621
24774
  style: {
@@ -24714,20 +24867,6 @@ const ADSCitizenSecond = ({
24714
24867
  });
24715
24868
  }
24716
24869
  };
24717
- const areCartSlotsEqual = (a = [], b = []) => {
24718
- if (a.length !== b.length) return false;
24719
- const sortByAd = arr => [...arr].sort((x, y) => String(x.ad.id).localeCompare(String(y.ad.id)));
24720
- const sortedA = sortByAd(a);
24721
- const sortedB = sortByAd(b);
24722
- return sortedA.every((item, idx) => {
24723
- const other = sortedB[idx];
24724
- if (String(item.ad.id) !== String(other.ad.id)) return false;
24725
- const slotsA = item.slots.map(s => s.bookingDate).sort();
24726
- const slotsB = other.slots.map(s => s.bookingDate).sort();
24727
- if (slotsA.length !== slotsB.length) return false;
24728
- return slotsA.every((date, i) => date === slotsB[i]);
24729
- });
24730
- };
24731
24870
  const onSubmit = async data => {
24732
24871
  var _currentStepData$ads;
24733
24872
  if ((cartSlots === null || cartSlots === void 0 ? void 0 : cartSlots.length) === 0) {
@@ -25028,7 +25167,8 @@ const ADSCitizenSecond = ({
25028
25167
  onSelectSlot: handleAddToCart,
25029
25168
  cartSlots: cartSlots,
25030
25169
  t: t,
25031
- dateRange: dateRange
25170
+ dateRange: dateRange,
25171
+ onRemoveSlot: handleRemoveFromCart
25032
25172
  }), showCart && /*#__PURE__*/React.createElement(CartModal, {
25033
25173
  cartSlots: cartSlots,
25034
25174
  onClose: () => setShowCart(false),