abmp-npm 10.0.46 → 10.0.48
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { ADDRESS_STATUS_TYPES } = require('../../public/consts');
|
|
1
2
|
const { findMemberById, getMemberBySlug } = require('../members-data-methods');
|
|
2
3
|
const { isValidArray, generateGeoHash } = require('../utils');
|
|
3
4
|
|
|
@@ -82,7 +83,21 @@ async function generateUpdatedMemberData({ inputMemberData, currentPageNumber })
|
|
|
82
83
|
|
|
83
84
|
// Only add address data for new members
|
|
84
85
|
if (!existingDbMember && isValidArray(inputMemberData.addresses)) {
|
|
85
|
-
|
|
86
|
+
const normalizedAddresses = inputMemberData.addresses.map((address, index) => {
|
|
87
|
+
const key = address?.key || `address_${index}`;
|
|
88
|
+
const rawStatus = address?.addressStatus;
|
|
89
|
+
const resolvedStatus =
|
|
90
|
+
index === 0 && rawStatus === ADDRESS_STATUS_TYPES.DONT_SHOW
|
|
91
|
+
? ADDRESS_STATUS_TYPES.STATE_CITY_ZIP
|
|
92
|
+
: rawStatus || ADDRESS_STATUS_TYPES.STATE_CITY_ZIP;
|
|
93
|
+
return {
|
|
94
|
+
...address,
|
|
95
|
+
key,
|
|
96
|
+
addressStatus: resolvedStatus,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
updatedMemberData.addresses = normalizedAddresses;
|
|
100
|
+
updatedMemberData.addressDisplayOption = [{ key: normalizedAddresses[0].key, isMain: true }];
|
|
86
101
|
}
|
|
87
102
|
|
|
88
103
|
return { ...updatedMemberData, isNewToDb: !existingDbMember };
|
package/package.json
CHANGED
package/pages/LoadingPage.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
const { location: wixLocationFrontend } = require('@wix/site-location');
|
|
2
|
+
const { local } = require('@wix/site-storage');
|
|
1
3
|
const { window: wixWindow, rendering } = require('@wix/site-window');
|
|
2
4
|
|
|
3
|
-
const { LIGHTBOX_NAMES } = require('../public/consts');
|
|
5
|
+
const { LIGHTBOX_NAMES, PAGES_PATHS } = require('../public/consts');
|
|
4
6
|
const { checkAndLogin } = require('../public/sso-auth-methods');
|
|
5
7
|
|
|
6
8
|
async function loadingPageOnReady(authenticateSSOToken) {
|
|
@@ -8,9 +10,16 @@ async function loadingPageOnReady(authenticateSSOToken) {
|
|
|
8
10
|
//This calls needs to triggered on client side, otherwise PAC API will return 401 error
|
|
9
11
|
if (renderingEnv === 'browser') {
|
|
10
12
|
//Need to pass authenticateSSOToken to checkAndLogin so it will run as a web method not a public one.
|
|
11
|
-
await checkAndLogin(authenticateSSOToken).catch(error => {
|
|
12
|
-
wixWindow.openLightbox(LIGHTBOX_NAMES.LOGIN_ERROR_ALERT);
|
|
13
|
+
await checkAndLogin(authenticateSSOToken).catch(async error => {
|
|
13
14
|
console.error(`Something went wrong while logging in: ${error}`);
|
|
15
|
+
// If we already have a session (memberId), redirect to form instead of showing error.
|
|
16
|
+
const storedMemberId = await local.getItem('memberId');
|
|
17
|
+
if (storedMemberId) {
|
|
18
|
+
const redirectTo = `${PAGES_PATHS.MEMBERS_FORM}?token=${encodeURIComponent(storedMemberId)}`;
|
|
19
|
+
await wixLocationFrontend.to(`/${redirectTo}`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
wixWindow.openLightbox(LIGHTBOX_NAMES.LOGIN_ERROR_ALERT);
|
|
14
23
|
});
|
|
15
24
|
}
|
|
16
25
|
}
|
package/pages/personalDetails.js
CHANGED
|
@@ -1556,23 +1556,9 @@ async function personalDetailsOnReady({
|
|
|
1556
1556
|
_$w('#mainAddressCheckbox').checked = false;
|
|
1557
1557
|
checkbox.checked = true;
|
|
1558
1558
|
|
|
1559
|
-
// Primary address cannot be hidden: update model and repeater data so UI and save stay in sync
|
|
1560
1559
|
if (clickedItemData.address.addressStatus === ADDRESS_STATUS_TYPES.DONT_SHOW) {
|
|
1561
1560
|
updateAddressStatus(clickedItemData._id, ADDRESS_STATUS_TYPES.STATE_CITY_ZIP);
|
|
1562
1561
|
$item('#addressStatusOptions').value = ADDRESS_STATUS_TYPES.STATE_CITY_ZIP;
|
|
1563
|
-
const currentData = _$w('#addressesList').data || [];
|
|
1564
|
-
const dataWithStatusFixed = currentData.map(item =>
|
|
1565
|
-
item._id === clickedItemData._id
|
|
1566
|
-
? {
|
|
1567
|
-
...item,
|
|
1568
|
-
address: {
|
|
1569
|
-
...item.address,
|
|
1570
|
-
addressStatus: ADDRESS_STATUS_TYPES.STATE_CITY_ZIP,
|
|
1571
|
-
},
|
|
1572
|
-
}
|
|
1573
|
-
: item
|
|
1574
|
-
);
|
|
1575
|
-
_$w('#addressesList').data = dataWithStatusFixed;
|
|
1576
1562
|
}
|
|
1577
1563
|
|
|
1578
1564
|
updateMainAddressSelection(clickedItemData._id);
|
|
@@ -1581,7 +1567,7 @@ async function personalDetailsOnReady({
|
|
|
1581
1567
|
});
|
|
1582
1568
|
|
|
1583
1569
|
_$w('#addressStatusOptions').onChange(event => {
|
|
1584
|
-
const data = _$w('#addressesList').data
|
|
1570
|
+
const data = _$w('#addressesList').data;
|
|
1585
1571
|
const clickedItemData = data.find(item => item._id === event.context.itemId);
|
|
1586
1572
|
const newStatus = event.target.value;
|
|
1587
1573
|
const $item = _$w.at(event.context);
|
|
@@ -1593,15 +1579,6 @@ async function personalDetailsOnReady({
|
|
|
1593
1579
|
}
|
|
1594
1580
|
|
|
1595
1581
|
updateAddressStatus(clickedItemData._id, newStatus);
|
|
1596
|
-
|
|
1597
|
-
// Keep repeater data in sync (required for new addresses not yet in itemMemberObj.addresses)
|
|
1598
|
-
const updatedData = data.map(item =>
|
|
1599
|
-
item._id === clickedItemData._id
|
|
1600
|
-
? { ...item, address: { ...item.address, addressStatus: newStatus } }
|
|
1601
|
-
: item
|
|
1602
|
-
);
|
|
1603
|
-
_$w('#addressesList').data = updatedData;
|
|
1604
|
-
|
|
1605
1582
|
checkFormChanges(FORM_SECTION_HANDLER_MAP.CONTACT_BOOKING);
|
|
1606
1583
|
});
|
|
1607
1584
|
|