abmp-npm 10.3.12 → 10.3.14

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abmp-npm",
3
- "version": "10.3.12",
3
+ "version": "10.3.14",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "check-cycles": "madge --circular .",
@@ -975,31 +975,18 @@ async function personalDetailsOnReady({
975
975
  });
976
976
  }
977
977
 
978
- async function handleItemDelete(event, getTextSelector, arrayRef, matchField, renderFn) {
979
- const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
980
-
981
- if (result && result.toDelete) {
982
- const $clickedItem = _$w.at(event.context);
983
- const textToRemove = $clickedItem(getTextSelector).text;
984
-
985
- arrayRef.splice(
986
- 0,
987
- arrayRef.length,
988
- ...arrayRef.filter(item =>
989
- typeof item === 'string' ? item !== textToRemove : item[matchField] !== textToRemove
990
- )
991
- );
992
-
993
- renderFn();
994
- checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
995
- }
996
- }
997
-
998
978
  async function setInterestData() {
999
979
  const interestsData = await getInterestAll();
1000
980
 
1001
- _$w('#removeServiceButton').onClick(event => {
1002
- handleItemDelete(event, '#serviceNameText', selectedServices, 'label', renderServices);
981
+ _$w('#removeServiceButton').onClick(async event => {
982
+ const itemId = event.context.itemId;
983
+ const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
984
+
985
+ if (result && result.toDelete) {
986
+ selectedServices = selectedServices.filter(service => service._id !== itemId);
987
+ renderServices();
988
+ checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
989
+ }
1003
990
  });
1004
991
 
1005
992
  if (Array.isArray(interestsData) && interestsData.length > 0) {
@@ -1077,9 +1064,6 @@ async function personalDetailsOnReady({
1077
1064
  }
1078
1065
 
1079
1066
  function renderServices() {
1080
- // Pass a fresh array copy so the Wix repeater detects the change and
1081
- // re-renders. Assigning the same array reference (mutated in place by
1082
- // add/delete) is treated as a no-op, leaving stale chips on screen.
1083
1067
  setupRepeater('#servicesRepeater', [...selectedServices]);
1084
1068
  }
1085
1069
 
@@ -1342,14 +1326,21 @@ async function personalDetailsOnReady({
1342
1326
  const addTestimonialButton = _$w('#addTestimonialButton');
1343
1327
 
1344
1328
  addTestimonialButton.onClick(handleAddTestimonial);
1345
- _$w('#deleteTestimonialButton').onClick(event => {
1346
- handleItemDelete(
1347
- event,
1348
- '#testimonialText',
1349
- itemMemberObj.testimonial,
1350
- null,
1351
- renderTestimonials
1352
- );
1329
+ _$w('#deleteTestimonialButton').onClick(async event => {
1330
+ const data = _$w('#testimonialRepeater').data || [];
1331
+ const clickedIndex = data.findIndex(item => item._id === event.context.itemId);
1332
+ const result = await wixWindow.openLightbox(LIGHTBOX_NAMES.DELETE_CONFIRM);
1333
+
1334
+ if (
1335
+ result &&
1336
+ result.toDelete &&
1337
+ clickedIndex > 0 &&
1338
+ Array.isArray(itemMemberObj.testimonial)
1339
+ ) {
1340
+ itemMemberObj.testimonial.splice(clickedIndex - 1, 1);
1341
+ renderTestimonials();
1342
+ checkFormChanges(FORM_SECTION_HANDLER_MAP.BUSINESS_SERVICES);
1343
+ }
1353
1344
  });
1354
1345
 
1355
1346
  renderTestimonials();