@openeventkit/event-site 2.0.104 → 2.0.105
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/gatsby-node.js +5 -3
- package/package.json +50 -5
- package/src/__mocks__/fileMock.js +1 -0
- package/src/actions/fetch-entities-actions.js +3 -0
- package/src/cms/config/collections/configurationsCollection/siteSettings/index.js +21 -0
- package/src/cms/config/collections/configurationsCollection/siteSettings/typeDefs.js +6 -0
- package/src/components/AuthComponent.js +5 -2
- package/src/components/RegistrationLiteComponent.js +3 -0
- package/src/content/site-settings/index.json +5 -0
- package/src/utils/__test__/dataNormalization.test.js +163 -0
- package/src/utils/dataNormalization.js +30 -6
- package/src/utils/useSiteSettings.js +9 -0
package/gatsby-node.js
CHANGED
|
@@ -87,7 +87,8 @@ const SSR_getEvents = async (baseUrl, summitId, accessToken) => {
|
|
|
87
87
|
access_token: accessToken,
|
|
88
88
|
per_page: 50,
|
|
89
89
|
page: 1,
|
|
90
|
-
expand: "slides,
|
|
90
|
+
expand: "slides,links,videos,media_uploads,type,track,track.subtracks,track.allowed_access_levels,location,location.venue,location.floor,speakers,moderator,sponsors,current_attendance,groups,rsvp_template,tags",
|
|
91
|
+
relations: "speakers.badge_features,speakers.affiliations,speakers.languages,speakers.other_presentation_links,speakers.areas_of_expertise,speakers.travel_preferences,speakers.organizational_roles,speakers.all_presentations,speakers.all_moderated_presentations",
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
return await axios.get(endpoint, { params }).then(async ({data}) => {
|
|
@@ -155,6 +156,7 @@ const SSR_getSpeakers = async (baseUrl, summitId, accessToken, filter = null) =>
|
|
|
155
156
|
access_token: accessToken,
|
|
156
157
|
per_page: 30,
|
|
157
158
|
page: 1,
|
|
159
|
+
relations: 'badge_features,affiliations,languages,other_presentation_links,areas_of_expertise,travel_preferences,organizational_roles,all_presentations,all_moderated_presentations',
|
|
158
160
|
};
|
|
159
161
|
|
|
160
162
|
const endpoint = `${baseUrl}/api/v1/summits/${summitId}/speakers/on-schedule`;
|
|
@@ -180,7 +182,7 @@ const SSR_getSpeakers = async (baseUrl, summitId, accessToken, filter = null) =>
|
|
|
180
182
|
const SSR_getSummit = async (baseUrl, summitId) => {
|
|
181
183
|
|
|
182
184
|
const params = {
|
|
183
|
-
expand: "event_types,tracks,
|
|
185
|
+
expand: "event_types,tracks,tracks.subtracks,track_groups,presentation_levels,locations.rooms,locations.floors,order_extra_questions.values,schedule_settings,schedule_settings.filters,schedule_settings.pre_filters",
|
|
184
186
|
t: Date.now()
|
|
185
187
|
};
|
|
186
188
|
|
|
@@ -201,7 +203,7 @@ const SSR_getVoteablePresentations = async (baseUrl, summitId, accessToken) => {
|
|
|
201
203
|
per_page: 50,
|
|
202
204
|
page: 1,
|
|
203
205
|
filter: "published==1",
|
|
204
|
-
expand: "slides,
|
|
206
|
+
expand: "slides,links,videos,media_uploads,type,track,track.allowed_access_levels,location,location.venue,location.floor,speakers,moderator,sponsors,current_attendance,groups,rsvp_template,tags",
|
|
205
207
|
};
|
|
206
208
|
|
|
207
209
|
return await axios.get(endpoint,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openeventkit/event-site",
|
|
3
3
|
"description": "Event Site",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.105",
|
|
5
5
|
"author": "Tipit LLC",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@mui/base": "^5.0.0-alpha.114",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"core-js": "^2.6.11",
|
|
37
37
|
"cross-env": "^7.0.3",
|
|
38
38
|
"crypto-js": "^4.1.1",
|
|
39
|
-
"data-guardian": "^1.1.2",
|
|
40
39
|
"disqus-react": "1.0.10",
|
|
41
40
|
"dotenv": "^8.2.0",
|
|
42
41
|
"dropzone": "^5.7.2",
|
|
@@ -79,7 +78,7 @@
|
|
|
79
78
|
"moment-timezone": "^0.5.31",
|
|
80
79
|
"netlify-cms-app": "^2.15.72",
|
|
81
80
|
"netlify-cms-lib-widgets": "^1.8.0",
|
|
82
|
-
"openstack-uicore-foundation": "4.1.
|
|
81
|
+
"openstack-uicore-foundation": "4.1.76",
|
|
83
82
|
"path-browserify": "^1.0.1",
|
|
84
83
|
"prop-types": "^15.6.0",
|
|
85
84
|
"react": "^18.2.0",
|
|
@@ -123,7 +122,7 @@
|
|
|
123
122
|
"stream-browserify": "^3.0.0",
|
|
124
123
|
"stream-chat": "^2.7.2",
|
|
125
124
|
"stream-chat-react": "3.1.7",
|
|
126
|
-
"summit-registration-lite": "5.0.
|
|
125
|
+
"summit-registration-lite": "5.0.26",
|
|
127
126
|
"superagent": "8.0.9",
|
|
128
127
|
"sweetalert2": "^9.17.0",
|
|
129
128
|
"upcoming-events-widget": "3.0.5",
|
|
@@ -150,12 +149,58 @@
|
|
|
150
149
|
"build": "NODE_ENV=production NODE_OPTIONS=--max-old-space-size=10240 cross-env node --trace-warnings node_modules/.bin/gatsby build --log-pages",
|
|
151
150
|
"develop": "NODE_OPTIONS=--max-old-space-size=8192 npm run gatsby-clean && node --trace-warnings node_modules/.bin/gatsby develop --S -H 0.0.0.0",
|
|
152
151
|
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write \"{gatsby-*.js,src/**/*.js}\"",
|
|
153
|
-
"test": "
|
|
152
|
+
"test": "jest",
|
|
154
153
|
"update-libs": "yarn upgrade live-event-widget openstack-uicore-foundation schedule-lite simple-chat-widget speakers-widget attendee-to-attendee-widget"
|
|
155
154
|
},
|
|
156
155
|
"devDependencies": {
|
|
156
|
+
"@testing-library/dom": "^10.0.0",
|
|
157
|
+
"@testing-library/jest-dom": "^6.4.2",
|
|
158
|
+
"@testing-library/react": "^15.0.2",
|
|
159
|
+
"@testing-library/user-event": "^14.5.2",
|
|
160
|
+
"babel-jest": "^29.7.0",
|
|
157
161
|
"devcert": "1.1.0",
|
|
158
162
|
"gatsby-plugin-webpack-speed-measure": "^0.1.1",
|
|
163
|
+
"identity-obj-proxy": "^3.0.0",
|
|
164
|
+
"jest": "^28.1.0",
|
|
165
|
+
"jest-environment-jsdom": "^28.1.0",
|
|
166
|
+
"jest-transform-stub": "^2.0.0",
|
|
167
|
+
"js-yaml": "^4.1.0",
|
|
168
|
+
"js-yaml-loader": "^1.2.2",
|
|
159
169
|
"prettier": "^2.0.5"
|
|
170
|
+
},
|
|
171
|
+
"jest": {
|
|
172
|
+
"collectCoverageFrom": [
|
|
173
|
+
"src/**/*.{js,jsx,mjs}"
|
|
174
|
+
],
|
|
175
|
+
"moduleNameMapper": {
|
|
176
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
|
|
177
|
+
"\\.(css|scss)$": "identity-obj-proxy"
|
|
178
|
+
},
|
|
179
|
+
"testMatch": [
|
|
180
|
+
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
|
|
181
|
+
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
|
|
182
|
+
],
|
|
183
|
+
"transform": {
|
|
184
|
+
"\\.[jt]sx?$": "babel-jest",
|
|
185
|
+
".+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$": "jest-transform-stub"
|
|
186
|
+
},
|
|
187
|
+
"moduleDirectories": [
|
|
188
|
+
"node_modules",
|
|
189
|
+
"src"
|
|
190
|
+
],
|
|
191
|
+
"moduleFileExtensions": [
|
|
192
|
+
"web.js",
|
|
193
|
+
"js",
|
|
194
|
+
"json",
|
|
195
|
+
"web.jsx",
|
|
196
|
+
"jsx",
|
|
197
|
+
"node",
|
|
198
|
+
"mjs"
|
|
199
|
+
],
|
|
200
|
+
"globals": {
|
|
201
|
+
"window": {},
|
|
202
|
+
"console": {}
|
|
203
|
+
},
|
|
204
|
+
"testEnvironment": "jsdom"
|
|
160
205
|
}
|
|
161
206
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
|
@@ -16,6 +16,8 @@ export const fetchEventById = async (summitId, eventId, accessToken = null) => {
|
|
|
16
16
|
|
|
17
17
|
apiUrl.addQuery('expand', 'slides, links, videos, media_uploads, type, track, track.allowed_access_levels, location, location.venue, location.floor, speakers, moderator, sponsors, current_attendance, groups, rsvp_template, tags');
|
|
18
18
|
apiUrl.addQuery('evict_cache', 1);
|
|
19
|
+
apiUrl.addQuery('relations', "speakers.badge_features,speakers.affiliations,speakers.languages,speakers.other_presentation_links,speakers.areas_of_expertise,speakers.travel_preferences,speakers.organizational_roles,speakers.all_presentations,speakers.all_moderated_presentations");
|
|
20
|
+
|
|
19
21
|
return fetch(apiUrl.toString(), {
|
|
20
22
|
method: 'GET'
|
|
21
23
|
}).then(async (response) => {
|
|
@@ -73,6 +75,7 @@ export const fetchSpeakerById = async(summitId, speakerId, accessToken = null) =
|
|
|
73
75
|
apiUrl.addQuery('access_token', accessToken);
|
|
74
76
|
}
|
|
75
77
|
|
|
78
|
+
apiUrl.addQuery('relations', 'badge_features,affiliations,languages,other_presentation_links,areas_of_expertise,travel_preferences,organizational_roles,all_presentations,all_moderated_presentations');
|
|
76
79
|
apiUrl.addQuery('evict_cache', 1);
|
|
77
80
|
|
|
78
81
|
return fetch(apiUrl.toString(), {
|
|
@@ -176,6 +176,27 @@ const siteSettings = {
|
|
|
176
176
|
}),
|
|
177
177
|
]
|
|
178
178
|
}),
|
|
179
|
+
objectField({
|
|
180
|
+
label: "IDP Logo",
|
|
181
|
+
name: "idpLogo",
|
|
182
|
+
fields: [
|
|
183
|
+
imageField({
|
|
184
|
+
label: "Logo Dark",
|
|
185
|
+
name: "idpLogoDark",
|
|
186
|
+
required: false
|
|
187
|
+
}),
|
|
188
|
+
imageField({
|
|
189
|
+
label: "Logo Light",
|
|
190
|
+
name: "idpLogoLight",
|
|
191
|
+
required: false
|
|
192
|
+
}),
|
|
193
|
+
stringField({
|
|
194
|
+
label: "Logo Alt",
|
|
195
|
+
name: "idpLogoAlt",
|
|
196
|
+
required: false
|
|
197
|
+
}),
|
|
198
|
+
]
|
|
199
|
+
}),
|
|
179
200
|
listField({
|
|
180
201
|
label: "Identity Provider Buttons",
|
|
181
202
|
name: "identityProviderButtons",
|
|
@@ -21,6 +21,11 @@ module.exports = `
|
|
|
21
21
|
schedule: Schedule
|
|
22
22
|
chat: Chat
|
|
23
23
|
}
|
|
24
|
+
type IdpLogo {
|
|
25
|
+
idpLogoDark: File @fileByRelativePath
|
|
26
|
+
idpLogoLight: File @fileByRelativePath
|
|
27
|
+
idpLogoAlt: String
|
|
28
|
+
}
|
|
24
29
|
type IdentityProviderButton {
|
|
25
30
|
buttonColor: String
|
|
26
31
|
buttonBorderColor: String
|
|
@@ -33,6 +38,7 @@ module.exports = `
|
|
|
33
38
|
siteMetadata: SiteMetadata
|
|
34
39
|
favicon: Favicon
|
|
35
40
|
widgets: Widgets
|
|
41
|
+
idpLogo: IdpLogo
|
|
36
42
|
identityProviderButtons: [IdentityProviderButton]
|
|
37
43
|
}
|
|
38
44
|
`;
|
|
@@ -143,7 +143,7 @@ const AuthComponent = ({
|
|
|
143
143
|
allowsOtpAuth: allowsOtpAuth,
|
|
144
144
|
initialEmailValue: initialEmailValue,
|
|
145
145
|
title: 'Sign in using the email associated with your account:',
|
|
146
|
-
summitData: summit
|
|
146
|
+
summitData: summit,
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
const passwordlessLoginProps = {
|
|
@@ -158,6 +158,9 @@ const AuthComponent = ({
|
|
|
158
158
|
codeError: otpError,
|
|
159
159
|
goToLogin: () => setOtpLogin(false),
|
|
160
160
|
getLoginCode: (email) => sendCode(email),
|
|
161
|
+
idpLogoLight: siteSettings?.idpLogo?.idpLogoLight?.publicURL,
|
|
162
|
+
idpLogoDark: siteSettings?.idpLogo?.idpLogoDark?.publicURL,
|
|
163
|
+
idpLogoAlt: siteSettings?.idpLogo?.idpLogoAlt
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
const { loginButton } = marketingPageSettings.hero.buttons;
|
|
@@ -242,4 +245,4 @@ AuthComponent.defaultProps = {
|
|
|
242
245
|
AuthComponent.propTypes = {
|
|
243
246
|
location: PropTypes.object.isRequired,
|
|
244
247
|
ignoreAutoOpen: PropTypes.bool,
|
|
245
|
-
}
|
|
248
|
+
}
|
|
@@ -195,6 +195,9 @@ const RegistrationLiteComponent = ({
|
|
|
195
195
|
noAllowedTicketsMessage: noAllowedTicketsMessage,
|
|
196
196
|
showCompanyInput: showCompanyInput,
|
|
197
197
|
showCompanyInputDefaultOptions: showCompanyInputDefaultOptions,
|
|
198
|
+
idpLogoLight: siteSettings?.idpLogo?.idpLogoLight?.publicURL,
|
|
199
|
+
idpLogoDark: siteSettings?.idpLogo?.idpLogoDark?.publicURL,
|
|
200
|
+
idpLogoAlt: siteSettings?.idpLogo?.idpLogoAlt
|
|
198
201
|
};
|
|
199
202
|
|
|
200
203
|
const { registerButton } = marketingPageSettings.hero.buttons;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { normalizeData } from "../dataNormalization";
|
|
6
|
+
|
|
7
|
+
const testOrder = {
|
|
8
|
+
"id": 43545,
|
|
9
|
+
"created": 1713391444,
|
|
10
|
+
"last_edited": 1713391444,
|
|
11
|
+
"number": "ORDER_2023OCPGLOBALSUMMIT2023_662047548D72D773046574",
|
|
12
|
+
"status": "Paid",
|
|
13
|
+
"payment_method": "Online",
|
|
14
|
+
"owner_first_name": "Sebastian",
|
|
15
|
+
"owner_last_name": "Marcet",
|
|
16
|
+
"owner_email": "test@gmail.com",
|
|
17
|
+
"owner_company": "Tipit",
|
|
18
|
+
"owner_company_id": 3496,
|
|
19
|
+
"owner_id": 26391,
|
|
20
|
+
"summit_id": 50,
|
|
21
|
+
"currency": "USD",
|
|
22
|
+
"currency_symbol": "$",
|
|
23
|
+
"extra_questions": [],
|
|
24
|
+
"tickets": [{
|
|
25
|
+
"id": 50175,
|
|
26
|
+
"created": 1713391444,
|
|
27
|
+
"last_edited": 1713409486,
|
|
28
|
+
"number": "TICKET_2023OCPGLOBALSUMMIT2023_6620475493A78111038846",
|
|
29
|
+
"status": "Paid",
|
|
30
|
+
"external_order_id": null,
|
|
31
|
+
"external_attendee_id": null,
|
|
32
|
+
"bought_date": 1713391485,
|
|
33
|
+
"order_id": 43545,
|
|
34
|
+
"promo_code_id": 0,
|
|
35
|
+
"raw_cost": 900,
|
|
36
|
+
"net_selling_cost": 900,
|
|
37
|
+
"raw_cost_in_cents": 90000,
|
|
38
|
+
"final_amount": 900,
|
|
39
|
+
"final_amount_in_cents": 90000,
|
|
40
|
+
"discount": 0,
|
|
41
|
+
"discount_rate": 0,
|
|
42
|
+
"discount_in_cents": 0,
|
|
43
|
+
"refunded_amount": 0,
|
|
44
|
+
"refunded_amount_in_cents": 0,
|
|
45
|
+
"total_refunded_amount": 0,
|
|
46
|
+
"total_refunded_amount_in_cents": 0,
|
|
47
|
+
"currency": "USD",
|
|
48
|
+
"currency_symbol": "$",
|
|
49
|
+
"taxes_amount": 0,
|
|
50
|
+
"taxes_amount_in_cents": 0,
|
|
51
|
+
"is_active": true,
|
|
52
|
+
"qr_code": "TICKET_2023OCPGLOBALSUMMIT2023|TICKET_2023OCPGLOBALSUMMIT2023_6620475493A78111038846|smarcet@gmail.com",
|
|
53
|
+
"owner": {
|
|
54
|
+
"id": 28608,
|
|
55
|
+
"created": 1685574339,
|
|
56
|
+
"last_edited": 1713409445,
|
|
57
|
+
"summit_hall_checked_in": false,
|
|
58
|
+
"summit_hall_checked_in_date": null,
|
|
59
|
+
"summit_virtual_checked_in_date": null,
|
|
60
|
+
"shared_contact_info": false,
|
|
61
|
+
"member_id": 26391,
|
|
62
|
+
"summit_id": 50,
|
|
63
|
+
"first_name": "Sebastian",
|
|
64
|
+
"last_name": "Marcet",
|
|
65
|
+
"email": "test@gmail.com",
|
|
66
|
+
"company": "Tipit",
|
|
67
|
+
"company_id": 3496,
|
|
68
|
+
"disclaimer_accepted_date": null,
|
|
69
|
+
"disclaimer_accepted": false,
|
|
70
|
+
"status": "Incomplete",
|
|
71
|
+
"tickets": [50175],
|
|
72
|
+
"presentation_votes": [],
|
|
73
|
+
"votes_count": 0,
|
|
74
|
+
"ticket_types": [{"type_id": 109, "qty": 1, "type_name": "Standard Ticket"}],
|
|
75
|
+
"allowed_access_levels": [149],
|
|
76
|
+
"allowed_features": [],
|
|
77
|
+
"tags": [],
|
|
78
|
+
"extra_questions": []
|
|
79
|
+
},
|
|
80
|
+
"badge": {
|
|
81
|
+
"id": 50183,
|
|
82
|
+
"created": 1713391444,
|
|
83
|
+
"last_edited": 1713391444,
|
|
84
|
+
"print_date": null,
|
|
85
|
+
"qr_code": null,
|
|
86
|
+
"is_void": false,
|
|
87
|
+
"ticket_id": 50175,
|
|
88
|
+
"printed_times": 0,
|
|
89
|
+
"features": [],
|
|
90
|
+
"print_excerpt": [],
|
|
91
|
+
"type": {
|
|
92
|
+
"id": 112,
|
|
93
|
+
"created": 1685036153,
|
|
94
|
+
"last_edited": 1685036153,
|
|
95
|
+
"name": "General Attendee",
|
|
96
|
+
"description": "This is for all in-person general attendees. This Badge Type can have various Badge Features (icons/titles). Badge Features may be dictated by promo codes or can be added manually by Admins. The badge needs a QR code for LR. This badge needs T-Shirt Size Indicator from extra question answer (dots/dashes) on the design.",
|
|
97
|
+
"template_content": "",
|
|
98
|
+
"is_default": true,
|
|
99
|
+
"summit_id": 50,
|
|
100
|
+
"badge_features": [],
|
|
101
|
+
"allowed_view_types": [49],
|
|
102
|
+
"access_levels": [{
|
|
103
|
+
"id": 149,
|
|
104
|
+
"created": 1683216137,
|
|
105
|
+
"last_edited": 1683216137,
|
|
106
|
+
"name": "IN_PERSON",
|
|
107
|
+
"description": "Allows in person show access.",
|
|
108
|
+
"template_content": "",
|
|
109
|
+
"is_default": true,
|
|
110
|
+
"summit_id": 50
|
|
111
|
+
}]
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"ticket_type": {
|
|
115
|
+
"id": 109,
|
|
116
|
+
"created": 1685036568,
|
|
117
|
+
"last_edited": 1713391444,
|
|
118
|
+
"name": "Standard Ticket",
|
|
119
|
+
"description": "This is for general admission. Needs QR Code on Badge. Symposium included (first come, first served until capacity is met). Early bird pricing ended 7/31/23. In-Person Ticket: Standard, is on sale 8/1/23- 10/15/23",
|
|
120
|
+
"external_id": null,
|
|
121
|
+
"summit_id": 50,
|
|
122
|
+
"cost": 900,
|
|
123
|
+
"currency": "USD",
|
|
124
|
+
"currency_symbol": "$",
|
|
125
|
+
"quantity_2_sell": 10000,
|
|
126
|
+
"max_quantity_per_order": 100,
|
|
127
|
+
"sales_start_date": 1690873200,
|
|
128
|
+
"sales_end_date": 1722581940,
|
|
129
|
+
"badge_type_id": 112,
|
|
130
|
+
"quantity_sold": 3289,
|
|
131
|
+
"audience": "All",
|
|
132
|
+
"applied_taxes": [],
|
|
133
|
+
"sub_type": "Regular"
|
|
134
|
+
},
|
|
135
|
+
"applied_taxes": [],
|
|
136
|
+
"refund_requests": []
|
|
137
|
+
}]
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const testArrayOrderData = [testOrder];
|
|
141
|
+
|
|
142
|
+
describe("data normalization", () => {
|
|
143
|
+
test("remove email from order data", () => {
|
|
144
|
+
expect(testOrder.hasOwnProperty("owner_email")).toBeTruthy();
|
|
145
|
+
expect(testOrder.tickets[0].owner.hasOwnProperty("email") ).toBeTruthy();
|
|
146
|
+
const data = normalizeData(testOrder);
|
|
147
|
+
expect(data.hasOwnProperty("owner_email")).toBeFalsy();
|
|
148
|
+
expect(data.tickets[0].owner.hasOwnProperty("email") ).toBeFalsy();
|
|
149
|
+
});
|
|
150
|
+
test("remove qr from order data", () => {
|
|
151
|
+
expect(testOrder.tickets[0].hasOwnProperty("qr_code") ).toBeTruthy();
|
|
152
|
+
const data = normalizeData(testOrder);
|
|
153
|
+
expect(data.tickets[0].hasOwnProperty("qr_code") ).toBeFalsy();
|
|
154
|
+
});
|
|
155
|
+
test("remove qr from array of orders", () => {
|
|
156
|
+
expect(Array.isArray(testArrayOrderData)).toBeTruthy();
|
|
157
|
+
expect(testArrayOrderData[0].tickets[0].hasOwnProperty("qr_code") ).toBeTruthy();
|
|
158
|
+
const data = normalizeData(testArrayOrderData);
|
|
159
|
+
expect(Array.isArray(data)).toBeTruthy();
|
|
160
|
+
expect(data[0].tickets[0].hasOwnProperty("qr_code") ).toBeFalsy();
|
|
161
|
+
});
|
|
162
|
+
})
|
|
163
|
+
|
|
@@ -1,12 +1,36 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _ from "lodash";
|
|
2
2
|
|
|
3
3
|
const FIRST_NAME_KEY = "first_name";
|
|
4
4
|
const LAST_NAME_KEY = "last_name";
|
|
5
|
+
const EMAIL_KEY = "email";
|
|
6
|
+
const OWNER_FIRST_NAME_KEY = `owner_${FIRST_NAME_KEY}`;
|
|
7
|
+
const OWNER_LAST_NAME_KEY = `owner_${LAST_NAME_KEY}`;
|
|
8
|
+
const OWNER_EMAIL_KEY = `owner_${EMAIL_KEY}`;
|
|
9
|
+
const QR_CODE_KEY = "qr_code";
|
|
5
10
|
|
|
6
|
-
const excludeKeys = [
|
|
11
|
+
const excludeKeys = [
|
|
12
|
+
FIRST_NAME_KEY,
|
|
13
|
+
LAST_NAME_KEY,
|
|
14
|
+
EMAIL_KEY,
|
|
15
|
+
OWNER_FIRST_NAME_KEY,
|
|
16
|
+
OWNER_LAST_NAME_KEY,
|
|
17
|
+
OWNER_EMAIL_KEY,
|
|
18
|
+
QR_CODE_KEY,
|
|
19
|
+
];
|
|
7
20
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
};
|
|
21
|
+
const deepOmit = (obj, keysToOmit) => {
|
|
22
|
+
let keysToOmitIndex = _.keyBy(Array.isArray(keysToOmit) ? keysToOmit : [keysToOmit] ); // create an index object of the keys that should be omitted
|
|
11
23
|
|
|
12
|
-
|
|
24
|
+
const omitFromObject = (obj) => { // the inner function which will be called recursively
|
|
25
|
+
return _.transform(obj, function(result, value, key) { // transform to a new object
|
|
26
|
+
if (key in keysToOmitIndex) { // if the key is in the index skip it
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
result[key] = _.isObject(value) ? omitFromObject(value) : value; // if the key is an object run it through the inner function - omitFromObject
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return omitFromObject(obj); // return the inner function result
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const normalizeData = (data) => deepOmit(data, excludeKeys);
|