abmp-npm 1.8.37 → 1.8.38
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/backend/routers-methods.js +26 -38
- package/package.json +1 -1
- package/public/consts.js +14 -0
- package/public/index.js +1 -0
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const {
|
|
2
|
+
DEFAULT_SEO_DESCRIPTION,
|
|
3
|
+
ADDRESS_STATUS_TYPES,
|
|
4
|
+
ABMP_LOGO_URL,
|
|
5
|
+
SITE_ASSOCIATION,
|
|
6
|
+
MEMBERSHIPS_TYPES,
|
|
7
|
+
formatAddress,
|
|
8
|
+
getMainAddress,
|
|
9
|
+
generateId,
|
|
10
|
+
} = require('../public');
|
|
2
11
|
|
|
3
12
|
const { getMemberBySlug } = require('./members-data-methods');
|
|
4
13
|
const { formatDateToMonthYear } = require('./utils');
|
|
@@ -41,17 +50,15 @@ function stripHtmlTags(html) {
|
|
|
41
50
|
* Check if member has student membership
|
|
42
51
|
* @param {Object} member - Member object
|
|
43
52
|
* @param {boolean} checkAssociation - Whether to check for specific association
|
|
44
|
-
* @param {string} siteAssociation - Site association to check for
|
|
45
|
-
* @param {string} studentType - Student membership type
|
|
46
53
|
* @returns {boolean} True if member has student membership
|
|
47
54
|
*/
|
|
48
|
-
function hasStudentMembership(member, checkAssociation
|
|
55
|
+
function hasStudentMembership(member, checkAssociation) {
|
|
49
56
|
const memberships = member?.memberships;
|
|
50
57
|
if (!Array.isArray(memberships)) return false;
|
|
51
58
|
|
|
52
59
|
return memberships.some(membership => {
|
|
53
|
-
const isStudent = membership.membertype ===
|
|
54
|
-
const hasCorrectAssociation = !checkAssociation || membership.association ===
|
|
60
|
+
const isStudent = membership.membertype === MEMBERSHIPS_TYPES.STUDENT;
|
|
61
|
+
const hasCorrectAssociation = !checkAssociation || membership.association === SITE_ASSOCIATION;
|
|
55
62
|
return isStudent && hasCorrectAssociation;
|
|
56
63
|
});
|
|
57
64
|
}
|
|
@@ -59,12 +66,10 @@ function hasStudentMembership(member, checkAssociation, siteAssociation, student
|
|
|
59
66
|
/**
|
|
60
67
|
* Check if member should have student badge
|
|
61
68
|
* @param {Object} member - Member object
|
|
62
|
-
* @param {string} siteAssociation - Site association
|
|
63
|
-
* @param {string} studentType - Student membership type
|
|
64
69
|
* @returns {boolean} True if should have badge
|
|
65
70
|
*/
|
|
66
|
-
function shouldHaveStudentBadge(member
|
|
67
|
-
return hasStudentMembership(member, true
|
|
71
|
+
function shouldHaveStudentBadge(member) {
|
|
72
|
+
return hasStudentMembership(member, true);
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
/**
|
|
@@ -73,13 +78,7 @@ function shouldHaveStudentBadge(member, siteAssociation, studentType) {
|
|
|
73
78
|
* @param {Array} addressDisplayOption - Display options
|
|
74
79
|
* @returns {Array} Processed addresses
|
|
75
80
|
*/
|
|
76
|
-
function getAddressesByStatus(
|
|
77
|
-
addresses = [],
|
|
78
|
-
addressDisplayOption = [],
|
|
79
|
-
formatAddress,
|
|
80
|
-
getMainAddress,
|
|
81
|
-
generateId
|
|
82
|
-
) {
|
|
81
|
+
function getAddressesByStatus(addresses = [], addressDisplayOption = []) {
|
|
83
82
|
const visible = addresses.filter(addr => addr.addressStatus !== ADDRESS_STATUS_TYPES.DONT_SHOW);
|
|
84
83
|
if (visible.length < 2) {
|
|
85
84
|
return [];
|
|
@@ -99,32 +98,22 @@ function getAddressesByStatus(
|
|
|
99
98
|
/**
|
|
100
99
|
* Get member profile data formatted for display
|
|
101
100
|
* @param {Object} member - Member object
|
|
102
|
-
* @param {Object} utils - Utility functions (formatAddress, getMainAddress, generateId)
|
|
103
|
-
* @param {Object} constants - Constants (siteAssociation, studentType, pacStaffType)
|
|
104
101
|
* @returns {Object} Formatted profile data
|
|
105
102
|
*/
|
|
106
|
-
function getMemberProfileData(member
|
|
103
|
+
function getMemberProfileData(member) {
|
|
107
104
|
if (!member) {
|
|
108
105
|
throw new Error('member is required');
|
|
109
106
|
}
|
|
110
|
-
const { formatAddress, getMainAddress, generateId } = utils;
|
|
111
|
-
const { siteAssociation, studentType, pacStaffType } = constants;
|
|
112
107
|
|
|
113
108
|
const addresses = member.addresses || [];
|
|
114
109
|
const licenceNo = member.licenses
|
|
115
110
|
?.map(val => val.license)
|
|
116
111
|
.filter(Boolean)
|
|
117
112
|
.join(', ');
|
|
118
|
-
const processedAddresses = getAddressesByStatus(
|
|
119
|
-
member.addresses,
|
|
120
|
-
member.addressDisplayOption,
|
|
121
|
-
formatAddress,
|
|
122
|
-
getMainAddress,
|
|
123
|
-
generateId
|
|
124
|
-
);
|
|
113
|
+
const processedAddresses = getAddressesByStatus(member.addresses, member.addressDisplayOption);
|
|
125
114
|
|
|
126
115
|
const memberships = member.memberships || [];
|
|
127
|
-
const abmp = memberships.find(m => m.association ===
|
|
116
|
+
const abmp = memberships.find(m => m.association === SITE_ASSOCIATION);
|
|
128
117
|
|
|
129
118
|
const areasOfPractices =
|
|
130
119
|
member.areasOfPractices
|
|
@@ -145,7 +134,7 @@ function getMemberProfileData(member, utils, constants) {
|
|
|
145
134
|
licenceNo,
|
|
146
135
|
processedAddresses,
|
|
147
136
|
memberSince: (member.showABMP && abmp && formatDateToMonthYear(abmp?.membersince)) || '',
|
|
148
|
-
shouldHaveStudentBadge: shouldHaveStudentBadge(member
|
|
137
|
+
shouldHaveStudentBadge: shouldHaveStudentBadge(member),
|
|
149
138
|
logoImage: member.logoImage,
|
|
150
139
|
fullName: member.fullName,
|
|
151
140
|
profileImage: member.profileImage,
|
|
@@ -162,7 +151,9 @@ function getMemberProfileData(member, utils, constants) {
|
|
|
162
151
|
url: member.url,
|
|
163
152
|
city: mainAddress?.city || '',
|
|
164
153
|
state: mainAddress?.state || '',
|
|
165
|
-
isPrivateMember: member.memberships.some(
|
|
154
|
+
isPrivateMember: member.memberships.some(
|
|
155
|
+
membership => membership.membertype === MEMBERSHIPS_TYPES.PAC_STAFF
|
|
156
|
+
),
|
|
166
157
|
};
|
|
167
158
|
}
|
|
168
159
|
|
|
@@ -170,13 +161,10 @@ function getMemberProfileData(member, utils, constants) {
|
|
|
170
161
|
* Profile router handler
|
|
171
162
|
* @param {Object} request - Router request object
|
|
172
163
|
* @param {Object} dependencies - Dependencies (ok, notFound, redirect, sendStatus)
|
|
173
|
-
* @param {Object} utils - Utility functions
|
|
174
|
-
* @param {Object} constants - Constants
|
|
175
164
|
* @returns {Promise} Router response
|
|
176
165
|
*/
|
|
177
|
-
async function profileRouter(request, dependencies
|
|
166
|
+
async function profileRouter(request, dependencies) {
|
|
178
167
|
const { ok, notFound, redirect, sendStatus } = dependencies;
|
|
179
|
-
const { abmpLogoUrl } = constants;
|
|
180
168
|
|
|
181
169
|
const slug = request.path[0];
|
|
182
170
|
if (!slug) {
|
|
@@ -193,10 +181,10 @@ async function profileRouter(request, dependencies, utils, constants) {
|
|
|
193
181
|
return notFound();
|
|
194
182
|
}
|
|
195
183
|
|
|
196
|
-
const profileData = getMemberProfileData(member
|
|
184
|
+
const profileData = getMemberProfileData(member);
|
|
197
185
|
|
|
198
186
|
if (profileData && profileData.showWixUrl) {
|
|
199
|
-
const ogImage = profileData.profileImage || profileData.logoImage ||
|
|
187
|
+
const ogImage = profileData.profileImage || profileData.logoImage || ABMP_LOGO_URL;
|
|
200
188
|
const seoTitle = generateSEOTitle(profileData.fullName, profileData.areasOfPractices);
|
|
201
189
|
// Use stripped HTML from aboutService rich text content
|
|
202
190
|
let description = stripHtmlTags(profileData.aboutService) || DEFAULT_SEO_DESCRIPTION;
|
package/package.json
CHANGED
package/public/consts.js
CHANGED
|
@@ -94,6 +94,17 @@ const DEFAULT_BUSINESS_NAME_TEXT = 'Business name not provided';
|
|
|
94
94
|
|
|
95
95
|
const DEFAULT_PROFILE_IMAGE =
|
|
96
96
|
'https://static.wixstatic.com/media/1d7134_e052e9b1d0a543d0980650e16dd6d374~mv2.jpg';
|
|
97
|
+
|
|
98
|
+
const ABMP_LOGO_URL =
|
|
99
|
+
'https://static.wixstatic.com/media/3eb9c9_b7447dc19d1b48cc99348a828cf77278~mv2.png';
|
|
100
|
+
|
|
101
|
+
const SITE_ASSOCIATION = 'ABMP';
|
|
102
|
+
|
|
103
|
+
const MEMBERSHIPS_TYPES = {
|
|
104
|
+
STUDENT: 'Student',
|
|
105
|
+
PAC_STAFF: 'PAC STAFF',
|
|
106
|
+
};
|
|
107
|
+
|
|
97
108
|
module.exports = {
|
|
98
109
|
REGEX,
|
|
99
110
|
COLLECTIONS,
|
|
@@ -107,4 +118,7 @@ module.exports = {
|
|
|
107
118
|
FREE_WEBSITE_TEXT_STATES,
|
|
108
119
|
DEFAULT_BUSINESS_NAME_TEXT,
|
|
109
120
|
DEFAULT_PROFILE_IMAGE,
|
|
121
|
+
ABMP_LOGO_URL,
|
|
122
|
+
SITE_ASSOCIATION,
|
|
123
|
+
MEMBERSHIPS_TYPES,
|
|
110
124
|
};
|