@posiwise/admin-module 0.0.162 → 0.0.164

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.
@@ -1191,51 +1191,32 @@ class DomainConfigBuildComponent extends AppBaseComponent {
1191
1191
  });
1192
1192
  this.shardUrl = res?.config?.shard_url;
1193
1193
  const fixedData = { ...this.data };
1194
- if (!fixedData.header || typeof fixedData.header !== 'object' || !Array.isArray(fixedData.header.sub_headings)) {
1195
- fixedData.header = { ...fixedData.header, sub_headings: [] };
1196
- }
1197
- if (!fixedData.testimonials || typeof fixedData.testimonials !== 'object' || !Array.isArray(fixedData.testimonials.items)) {
1198
- fixedData.testimonials = { ...fixedData.testimonials, items: [] };
1199
- }
1200
- if (!fixedData.book_demo || typeof fixedData.book_demo !== 'object' || !Array.isArray(fixedData.book_demo.items)) {
1201
- fixedData.book_demo = { ...fixedData.book_demo, items: [] };
1202
- }
1203
- if (!fixedData.partners || typeof fixedData.partners !== 'object' || !Array.isArray(fixedData.partners.items)) {
1204
- fixedData.partners = { ...fixedData.partners, items: [] };
1205
- }
1206
- if (!fixedData.videos || typeof fixedData.videos !== 'object' || !Array.isArray(fixedData.videos.items)) {
1207
- fixedData.videos = { ...fixedData.videos, items: [] };
1208
- }
1209
- if (!fixedData.integrations || typeof fixedData.integrations !== 'object' || !Array.isArray(fixedData.integrations.items)) {
1210
- fixedData.integrations = { ...fixedData.integrations, items: [] };
1211
- }
1212
- if (!fixedData.usps || typeof fixedData.usps !== 'object' || !Array.isArray(fixedData.usps.items)) {
1213
- fixedData.usps = { ...fixedData.usps, items: [] };
1214
- }
1215
- if (!fixedData.ctas || typeof fixedData.ctas !== 'object' || !Array.isArray(fixedData.ctas.items)) {
1216
- fixedData.ctas = { ...fixedData.ctas, items: [] };
1217
- }
1218
- if (!fixedData.ab_tests || !Array.isArray(fixedData.ab_tests)) {
1219
- fixedData.ab_tests = [];
1220
- }
1221
- if (!fixedData.guides || typeof fixedData.guides !== 'object' || !Array.isArray(fixedData.guides.items)) {
1222
- fixedData.guides = { ...fixedData.guides, items: [] };
1223
- }
1224
- if (!fixedData.navbar || typeof fixedData.navbar !== 'object' || !Array.isArray(fixedData.navbar.items)) {
1225
- fixedData.navbar = { ...fixedData.navbar, items: [] };
1226
- }
1227
- if (!fixedData.footer_links || typeof fixedData.footer_links !== 'object' || !Array.isArray(fixedData.footer_links.items)) {
1228
- fixedData.footer_links = { ...fixedData.footer_links, items: [] };
1229
- }
1230
- if (!fixedData.contact_us || typeof fixedData.contact_us !== 'object') {
1231
- fixedData.contact_us = { ...fixedData.contact_us };
1232
- }
1233
- if (!fixedData.contact_us.questions || !Array.isArray(fixedData.contact_us.questions)) {
1234
- fixedData.contact_us.questions = [];
1235
- }
1236
- if (!fixedData.contact_us.hubspot || !Array.isArray(fixedData.contact_us.hubspot)) {
1237
- fixedData.contact_us.hubspot = [];
1238
- }
1194
+ const ensureArrayField = (obj, key) => {
1195
+ if (!obj || typeof obj !== 'object' || !Array.isArray(obj[key])) {
1196
+ obj = { ...obj, [key]: [] };
1197
+ }
1198
+ return obj;
1199
+ };
1200
+ const keysWithItems = [
1201
+ 'testimonials',
1202
+ 'book_demo',
1203
+ 'partners',
1204
+ 'videos',
1205
+ 'integrations',
1206
+ 'usps',
1207
+ 'ctas',
1208
+ 'guides',
1209
+ 'navbar',
1210
+ 'footer_links'
1211
+ ];
1212
+ keysWithItems.forEach((key) => {
1213
+ fixedData[key] = ensureArrayField(fixedData[key], 'items');
1214
+ });
1215
+ fixedData.ab_tests = Array.isArray(fixedData.ab_tests) ? fixedData.ab_tests : [];
1216
+ fixedData.header = ensureArrayField(fixedData.header, 'sub_headings');
1217
+ fixedData.contact_us = typeof fixedData.contact_us === 'object' && fixedData.contact_us !== null ? { ...fixedData.contact_us } : {};
1218
+ fixedData.contact_us.questions = Array.isArray(fixedData.contact_us.questions) ? fixedData.contact_us.questions : [];
1219
+ fixedData.contact_us.hubspot = Array.isArray(fixedData.contact_us.hubspot) ? fixedData.contact_us.hubspot : [];
1239
1220
  this.form.patchValue(fixedData);
1240
1221
  this.form.patchValue({
1241
1222
  cs_product_id: this.productsList.find(x => x.id === this.data?.cs_product_id),
@@ -1279,14 +1260,16 @@ class DomainConfigBuildComponent extends AppBaseComponent {
1279
1260
  }
1280
1261
  const abTestsArray = this.abTests;
1281
1262
  abTestsArray.clear();
1282
- (res.config?.ab_tests ?? []).forEach(test => {
1283
- abTestsArray.push(this.fb.group({
1284
- description: [test?.description ?? ''],
1285
- experiment_name: [test?.experiment_name ?? ''],
1286
- db_shard: [test?.db_shard ?? ''],
1287
- microservice_name: [test?.microservice_name ?? '']
1288
- }));
1289
- });
1263
+ if (Array.isArray(res.config?.ab_tests)) {
1264
+ (res.config?.ab_tests ?? []).forEach(test => {
1265
+ abTestsArray.push(this.fb.group({
1266
+ description: [test?.description ?? ''],
1267
+ experiment_name: [test?.experiment_name ?? ''],
1268
+ db_shard: [test?.db_shard ?? ''],
1269
+ microservice_name: [test?.microservice_name ?? '']
1270
+ }));
1271
+ });
1272
+ }
1290
1273
  })
1291
1274
  .add(() => {
1292
1275
  this.isLoading = false;