@capillarytech/creatives-library 8.0.312 → 8.0.313

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.312",
4
+ "version": "8.0.313",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -388,93 +388,6 @@ const CommonTestAndPreview = (props) => {
388
388
  return resolvedText;
389
389
  };
390
390
 
391
- /**
392
- * Common handler for saving test customers (both new and existing)
393
- */
394
- const handleSaveTestCustomer = async (validationErrors = {},setIsLoading) => {
395
- // Check for validation errors before saving (for new customers)
396
- if (customerModal[1] === CUSTOMER_MODAL_NEW && (validationErrors.email || validationErrors.mobile)) {
397
- return;
398
- }
399
-
400
- if (typeof setIsLoading === 'function') {
401
- setIsLoading(true);
402
- }
403
-
404
- try {
405
- let payload;
406
-
407
- if (customerModal[1] === CUSTOMER_MODAL_EXISTING) {
408
- // For existing customers, use customerId
409
- payload = {
410
- customerId: customerData.customerId
411
- };
412
- } else {
413
- // For new customers, use customer object
414
- payload = {
415
- customer: {
416
- firstName: customerData.name || "",
417
- mobile: customerData.mobile || "",
418
- email: customerData.email || ""
419
- }
420
- };
421
- }
422
-
423
- const response = await createTestCustomer(payload);
424
-
425
-
426
- // Handle success: add to test customers list and selection (existing and new)
427
- if (response && response.success) {
428
- CapNotification.success({
429
- message: formatMessage(messages.newTestCustomerAddedSuccess),
430
- });
431
- // API may return customerId in response.response (e.g. { response: { customerId: 438845651 } })
432
- const res = response?.response || response;
433
- const addedId = customerModal[1] === CUSTOMER_MODAL_EXISTING
434
- ? customerData?.customerId
435
- : res?.customerId;
436
- if (addedId) {
437
- actions.addTestCustomer({
438
- userId: addedId,
439
- customerId: addedId,
440
- name: customerData?.name?.trim() || '',
441
- email: customerData?.email || '',
442
- mobile: customerData?.mobile || '',
443
- });
444
- setSelectedTestEntities((prev) => [...prev, addedId]);
445
- }
446
- handleCloseCustomerModal();
447
- } else {
448
- // Show error notification for unsuccessful response
449
- CapNotification.error({
450
- message: formatMessage(messages.errorTitle),
451
- description: response?.message || formatMessage(messages.failedToAddTestCustomer),
452
- });
453
- }
454
- } catch (error) {
455
- if (customerModal[1] === CUSTOMER_MODAL_EXISTING) {
456
- // Show error notification for caught exceptions (existing customers only)
457
- CapNotification.error({
458
- message: formatMessage(messages.errorTitle),
459
- description: error?.message || formatMessage(messages.errorAddingTestCustomer),
460
- });
461
- }
462
- } finally {
463
- setIsLoading(false);
464
- }
465
- };
466
-
467
- const handleCloseCustomerModal = () => {
468
- setCustomerModal([false, ""]);
469
- setSearchValue('');
470
- setCustomerData({
471
- name: '',
472
- email: '',
473
- mobile: '',
474
- customerId: '',
475
- });
476
- };
477
-
478
391
  /**
479
392
  * Prepare payload for preview API based on channel
480
393
  */
@@ -2599,107 +2512,6 @@ const CommonTestAndPreview = (props) => {
2599
2512
  setSelectedTestEntities(value);
2600
2513
  };
2601
2514
 
2602
- /**
2603
- * Map API customerDetails item to our customerData shape
2604
- */
2605
- const mapCustomerDetailsToCustomerData = (detail, identifierValue) => {
2606
- const firstName = detail.firstName || '';
2607
- const lastName = detail.lastName || '';
2608
- const name = [firstName, lastName].filter(Boolean).join(' ').trim() || '';
2609
- const getIdentifierValue = (type) => {
2610
- const fromIdentifiers = detail.identifiers?.find((i) => i.type === type)?.value;
2611
- if (fromIdentifiers) return fromIdentifiers;
2612
- const fromCommChannels = detail.commChannels?.find((c) => c.type === type)?.value;
2613
- return fromCommChannels || (channel === CHANNELS.EMAIL && type === IDENTIFIER_TYPE_EMAIL ? identifierValue : channel === CHANNELS.SMS && type === IDENTIFIER_TYPE_MOBILE ? identifierValue : '');
2614
- };
2615
- return {
2616
- name,
2617
- email: channel === CHANNELS.EMAIL ? (getIdentifierValue(IDENTIFIER_TYPE_EMAIL) || identifierValue) : (getIdentifierValue(IDENTIFIER_TYPE_EMAIL) || ''),
2618
- mobile: channel === CHANNELS.SMS ? (getIdentifierValue(IDENTIFIER_TYPE_MOBILE) || getIdentifierValue(IDENTIFIER_TYPE_PHONE) || identifierValue) : (getIdentifierValue(IDENTIFIER_TYPE_MOBILE) || getIdentifierValue(IDENTIFIER_TYPE_PHONE) || ''),
2619
- customerId: detail.userId != null ? String(detail.userId) : '',
2620
- };
2621
- };
2622
-
2623
- const handleAddTestCustomer = async () => {
2624
- const identifierType = channel === CHANNELS.EMAIL ? IDENTIFIER_TYPE_EMAIL : IDENTIFIER_TYPE_MOBILE;
2625
- const searchValueToCheck = searchValue || '';
2626
-
2627
- // Check if this customer is already in the test customers list
2628
- const existingTestCustomer = testCustomers?.find(customer => {
2629
- if (channel === CHANNELS.EMAIL) {
2630
- return customer.email === searchValueToCheck;
2631
- } else if (channel === CHANNELS.SMS) {
2632
- return customer.mobile === searchValueToCheck;
2633
- }
2634
- return false;
2635
- });
2636
-
2637
- if (existingTestCustomer) {
2638
- const entityId = existingTestCustomer.userId ?? existingTestCustomer.customerId;
2639
- if (entityId != null) {
2640
- const id = String(entityId);
2641
- setSelectedTestEntities((prev) =>
2642
- prev.includes(id) ? prev : [...prev, id]
2643
- );
2644
- }
2645
- setSearchValue('');
2646
- CapNotification.success({
2647
- message: formatMessage(messages.customerAlreadyInTestList),
2648
- });
2649
- return;
2650
- }
2651
-
2652
- setIsCustomerDataLoading(true);
2653
-
2654
- try {
2655
- const response = await getMembersLookup(identifierType, searchValueToCheck);
2656
- const success = response?.success && !response?.status?.isError;
2657
- const res = response?.response || {};
2658
- const exists = res.exists || false;
2659
- const details = res.customerDetails || [];
2660
-
2661
- if (!success) {
2662
- const errorMessage = response?.message || response?.status?.message || formatMessage(messages.memberLookupError);
2663
- CapNotification.error({ title: formatMessage(messages.errorTitle), message: errorMessage });
2664
- return;
2665
- }
2666
-
2667
- if (exists && details.length > 0) {
2668
- const mapped = mapCustomerDetailsToCustomerData(details[0], searchValueToCheck);
2669
- const customerIdFromLookup = mapped.customerId;
2670
- const alreadyInTestListByCustomerId = customerIdFromLookup && testCustomers?.some(
2671
- (c) => String(c?.customerId) === customerIdFromLookup || String(c?.userId) === customerIdFromLookup
2672
- );
2673
- if (alreadyInTestListByCustomerId) {
2674
- setSelectedTestEntities((prev) =>
2675
- prev.includes(customerIdFromLookup) ? prev : [...prev, customerIdFromLookup]
2676
- );
2677
- setSearchValue('');
2678
- CapNotification.success({
2679
- message: formatMessage(messages.customerAlreadyInTestList),
2680
- });
2681
- return;
2682
- }
2683
- setCustomerData(mapped);
2684
- setCustomerModal([true, CUSTOMER_MODAL_EXISTING]);
2685
- } else {
2686
- setCustomerData({
2687
- name: '',
2688
- email: channel === CHANNELS.EMAIL ? searchValueToCheck : '',
2689
- mobile: channel === CHANNELS.SMS ? searchValueToCheck : '',
2690
- customerId: '',
2691
- });
2692
- setCustomerModal([true, CUSTOMER_MODAL_NEW]);
2693
- }
2694
- } catch {
2695
- CapNotification.error({
2696
- message: formatMessage(messages.memberLookupError),
2697
- });
2698
- } finally {
2699
- setIsCustomerDataLoading(false);
2700
- }
2701
- };
2702
-
2703
2515
  /**
2704
2516
  * Handle send test message
2705
2517
  */
@@ -212,8 +212,8 @@ export const ErrorInfoNote = (props) => {
212
212
  Array.isArray(rawStandardWarnings) ? rawStandardWarnings : [],
213
213
  ), [rawStandardErrors, rawLiquidErrors, rawStandardWarnings]);
214
214
 
215
- const errorsCount = errorIssues.length;
216
- const warningsCount = warningIssues.length;
215
+ const errorsCount = errorIssues?.length;
216
+ const warningsCount = warningIssues?.length;
217
217
  const totalCount = errorsCount + warningsCount;
218
218
  const hasLiquidErrors = Array.isArray(rawLiquidErrors) && rawLiquidErrors.length > 0;
219
219
 
@@ -5778,7 +5778,7 @@ FREE GIFTS-
5778
5778
  </CapRow>
5779
5779
  <Edit__SMSTraiFooter>
5780
5780
  <div
5781
- className="Edit__SMSTraiFooter-jwsec7-0 fbjRJS"
5781
+ className="Edit__SMSTraiFooter-jwsec7-0 cskOAw"
5782
5782
  >
5783
5783
  <CapButton
5784
5784
  className="create-msg create-dlt-msg"
@@ -16756,7 +16756,7 @@ FREE GIFTS-
16756
16756
  </CapRow>
16757
16757
  <Edit__SMSTraiFooter>
16758
16758
  <div
16759
- className="Edit__SMSTraiFooter-jwsec7-0 fbjRJS"
16759
+ className="Edit__SMSTraiFooter-jwsec7-0 cskOAw"
16760
16760
  >
16761
16761
  <CapButton
16762
16762
  className="create-msg create-dlt-msg"
@@ -27824,7 +27824,7 @@ FREE GIFTS-
27824
27824
  </CapRow>
27825
27825
  <Edit__SMSTraiFooter>
27826
27826
  <div
27827
- className="Edit__SMSTraiFooter-jwsec7-0 fbjRJS"
27827
+ className="Edit__SMSTraiFooter-jwsec7-0 cskOAw"
27828
27828
  >
27829
27829
  <CapButton
27830
27830
  className="create-msg create-dlt-msg"