@inspirer-dev/crm-dashboard 1.0.30 → 1.0.31

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.
@@ -2,56 +2,85 @@ import React, { forwardRef, useCallback, useEffect, useMemo, useState, useRef }
2
2
  import { ReactFlowProvider } from 'reactflow';
3
3
  import 'reactflow/dist/style.css';
4
4
  import { Box, Field, Flex, Typography, Badge } from '@strapi/design-system';
5
- import { useForm, useFetchClient } from '@strapi/strapi/admin';
5
+ import { useForm } from '@strapi/strapi/admin';
6
6
 
7
7
  import type { StepFlowBuilderProps, FlowStep, CampaignContext, EntrySegment } from './types';
8
8
  import { parseValue } from './utils';
9
9
  import { FlowCanvas } from './flow-canvas';
10
10
 
11
+ type RawSegmentValue =
12
+ | number
13
+ | { id?: number; documentId?: string; name?: string }
14
+ | null
15
+ | undefined;
16
+
17
+ const extractSegmentId = (value: RawSegmentValue): number | null => {
18
+ if (!value) return null;
19
+ if (typeof value === 'number') return value;
20
+ if (typeof value === 'object' && value.id) return value.id;
21
+ return null;
22
+ };
23
+
24
+ const extractSegmentName = (value: RawSegmentValue): string | null => {
25
+ if (!value) return null;
26
+ if (typeof value === 'object' && value.name) return value.name;
27
+ return null;
28
+ };
29
+
11
30
  const StepFlowBuilderInner = forwardRef<HTMLDivElement, StepFlowBuilderProps>(
12
31
  ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
13
32
  const [steps, setSteps] = useState<FlowStep[]>([]);
14
33
  const [populatedSegment, setPopulatedSegment] = useState<EntrySegment | null>(null);
15
34
  const isInitialMount = useRef(true);
16
35
  const syncTimeoutRef = useRef<NodeJS.Timeout | null>(null);
17
- const { get } = useFetchClient();
18
36
 
19
37
  const form = useForm('StepFlowBuilder', (state) => state);
20
38
 
21
39
  const rawEntrySegment = useMemo(() => {
22
40
  const values = form?.values as Record<string, unknown> | undefined;
23
- return values?.entrySegment as { id?: number; name?: string } | null | undefined;
41
+ return values?.entrySegment as RawSegmentValue;
24
42
  }, [form?.values]);
25
43
 
26
44
  useEffect(() => {
27
45
  const fetchSegmentName = async () => {
28
- if (!rawEntrySegment?.id) {
46
+ const segmentId = extractSegmentId(rawEntrySegment);
47
+ const segmentName = extractSegmentName(rawEntrySegment);
48
+
49
+ console.log('[StepFlowBuilder] rawEntrySegment:', rawEntrySegment);
50
+ console.log('[StepFlowBuilder] segmentId:', segmentId, 'segmentName:', segmentName);
51
+
52
+ if (!segmentId) {
29
53
  setPopulatedSegment(null);
30
54
  return;
31
55
  }
32
56
 
33
- if (rawEntrySegment.name) {
34
- setPopulatedSegment(rawEntrySegment as EntrySegment);
57
+ if (segmentName) {
58
+ setPopulatedSegment({ id: segmentId, name: segmentName });
35
59
  return;
36
60
  }
37
61
 
38
62
  try {
63
+ const { useFetchClient } = await import('@strapi/strapi/admin');
64
+ const { get } = useFetchClient();
65
+
39
66
  const response = await get(
40
- `/content-manager/collection-types/api::crm-segment.crm-segment/${rawEntrySegment.id}`
67
+ `/content-manager/collection-types/api::crm-segment.crm-segment/${segmentId}`
41
68
  );
69
+ console.log('[StepFlowBuilder] API response:', response);
42
70
  const data = response?.data as { name?: string } | undefined;
43
71
  if (data?.name) {
44
- setPopulatedSegment({ id: rawEntrySegment.id, name: data.name });
72
+ setPopulatedSegment({ id: segmentId, name: data.name });
45
73
  } else {
46
- setPopulatedSegment({ id: rawEntrySegment.id, name: `Segment #${rawEntrySegment.id}` });
74
+ setPopulatedSegment({ id: segmentId, name: `Segment #${segmentId}` });
47
75
  }
48
- } catch {
49
- setPopulatedSegment({ id: rawEntrySegment.id, name: `Segment #${rawEntrySegment.id}` });
76
+ } catch (err) {
77
+ console.warn('[StepFlowBuilder] Failed to fetch segment:', err);
78
+ setPopulatedSegment({ id: segmentId, name: `Segment #${segmentId}` });
50
79
  }
51
80
  };
52
81
 
53
82
  fetchSegmentName();
54
- }, [rawEntrySegment?.id, rawEntrySegment?.name, get]);
83
+ }, [rawEntrySegment]);
55
84
 
56
85
  const campaignContext = useMemo<CampaignContext>(() => {
57
86
  const values = form?.values as Record<string, unknown> | undefined;
@@ -68,13 +68,13 @@ var freeSelf = typeof self == "object" && self && self.Object === Object && self
68
68
  var root$c = freeGlobal || freeSelf || Function("return this")();
69
69
  var _root = root$c;
70
70
  var root$b = _root;
71
- var Symbol$6 = root$b.Symbol;
72
- var _Symbol = Symbol$6;
73
- var Symbol$5 = _Symbol;
71
+ var Symbol$7 = root$b.Symbol;
72
+ var _Symbol = Symbol$7;
73
+ var Symbol$6 = _Symbol;
74
74
  var objectProto$g = Object.prototype;
75
75
  var hasOwnProperty$d = objectProto$g.hasOwnProperty;
76
76
  var nativeObjectToString$1 = objectProto$g.toString;
77
- var symToStringTag$1 = Symbol$5 ? Symbol$5.toStringTag : void 0;
77
+ var symToStringTag$1 = Symbol$6 ? Symbol$6.toStringTag : void 0;
78
78
  function getRawTag$1(value) {
79
79
  var isOwn = hasOwnProperty$d.call(value, symToStringTag$1), tag = value[symToStringTag$1];
80
80
  try {
@@ -99,9 +99,9 @@ function objectToString$2(value) {
99
99
  return nativeObjectToString.call(value);
100
100
  }
101
101
  var _objectToString = objectToString$2;
102
- var Symbol$4 = _Symbol, getRawTag = _getRawTag, objectToString$1 = _objectToString;
102
+ var Symbol$5 = _Symbol, getRawTag = _getRawTag, objectToString$1 = _objectToString;
103
103
  var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
104
- var symToStringTag = Symbol$4 ? Symbol$4.toStringTag : void 0;
104
+ var symToStringTag = Symbol$5 ? Symbol$5.toStringTag : void 0;
105
105
  function baseGetTag$7(value) {
106
106
  if (value == null) {
107
107
  return value === void 0 ? undefinedTag : nullTag;
@@ -429,7 +429,7 @@ Stack$4.prototype.has = stackHas;
429
429
  Stack$4.prototype.set = stackSet;
430
430
  var _Stack = Stack$4;
431
431
  var getNative$4 = _getNative;
432
- var defineProperty$1 = function() {
432
+ var defineProperty$2 = function() {
433
433
  try {
434
434
  var func2 = getNative$4(Object, "defineProperty");
435
435
  func2({}, "", {});
@@ -437,11 +437,11 @@ var defineProperty$1 = function() {
437
437
  } catch (e2) {
438
438
  }
439
439
  }();
440
- var _defineProperty = defineProperty$1;
441
- var defineProperty = _defineProperty;
440
+ var _defineProperty = defineProperty$2;
441
+ var defineProperty$1 = _defineProperty;
442
442
  function baseAssignValue$5(object2, key, value) {
443
- if (key == "__proto__" && defineProperty) {
444
- defineProperty(object2, key, {
443
+ if (key == "__proto__" && defineProperty$1) {
444
+ defineProperty$1(object2, key, {
445
445
  "configurable": true,
446
446
  "enumerable": true,
447
447
  "value": value,
@@ -572,14 +572,14 @@ var baseIsArguments = _baseIsArguments, isObjectLike$9 = isObjectLike_1;
572
572
  var objectProto$a = Object.prototype;
573
573
  var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
574
574
  var propertyIsEnumerable$1 = objectProto$a.propertyIsEnumerable;
575
- var isArguments$3 = baseIsArguments(/* @__PURE__ */ function() {
575
+ var isArguments$4 = baseIsArguments(/* @__PURE__ */ function() {
576
576
  return arguments;
577
577
  }()) ? baseIsArguments : function(value) {
578
578
  return isObjectLike$9(value) && hasOwnProperty$9.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
579
579
  };
580
- var isArguments_1 = isArguments$3;
581
- var isArray$f = Array.isArray;
582
- var isArray_1 = isArray$f;
580
+ var isArguments_1 = isArguments$4;
581
+ var isArray$g = Array.isArray;
582
+ var isArray_1 = isArray$g;
583
583
  var MAX_SAFE_INTEGER$1 = 9007199254740991;
584
584
  function isLength$3(value) {
585
585
  return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
@@ -727,11 +727,11 @@ function isIndex$5(value, length) {
727
727
  return !!length && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
728
728
  }
729
729
  var _isIndex = isIndex$5;
730
- var baseTimes = _baseTimes, isArguments$2 = isArguments_1, isArray$e = isArray_1, isBuffer$4 = isBufferExports, isIndex$4 = _isIndex, isTypedArray$2 = isTypedArray_1;
730
+ var baseTimes = _baseTimes, isArguments$3 = isArguments_1, isArray$f = isArray_1, isBuffer$4 = isBufferExports, isIndex$4 = _isIndex, isTypedArray$2 = isTypedArray_1;
731
731
  var objectProto$7 = Object.prototype;
732
732
  var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
733
733
  function arrayLikeKeys$2(value, inherited) {
734
- var isArr = isArray$e(value), isArg = !isArr && isArguments$2(value), isBuff = !isArr && !isArg && isBuffer$4(value), isType = !isArr && !isArg && !isBuff && isTypedArray$2(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
734
+ var isArr = isArray$f(value), isArg = !isArr && isArguments$3(value), isBuff = !isArr && !isArg && isBuffer$4(value), isType = !isArr && !isArg && !isBuff && isTypedArray$2(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
735
735
  for (var key in value) {
736
736
  if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
737
737
  (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
@@ -780,7 +780,7 @@ function toPlainObject$1(value) {
780
780
  return copyObject$5(value, keysIn$4(value));
781
781
  }
782
782
  var toPlainObject_1 = toPlainObject$1;
783
- var assignMergeValue$1 = _assignMergeValue, cloneBuffer$1 = _cloneBufferExports, cloneTypedArray$1 = _cloneTypedArray, copyArray$3 = _copyArray, initCloneObject$1 = _initCloneObject, isArguments$1 = isArguments_1, isArray$d = isArray_1, isArrayLikeObject = isArrayLikeObject_1, isBuffer$3 = isBufferExports, isFunction$1 = isFunction_1, isObject$9 = isObject_1, isPlainObject$6 = isPlainObject_1, isTypedArray$1 = isTypedArray_1, safeGet$1 = _safeGet, toPlainObject = toPlainObject_1;
783
+ var assignMergeValue$1 = _assignMergeValue, cloneBuffer$1 = _cloneBufferExports, cloneTypedArray$1 = _cloneTypedArray, copyArray$3 = _copyArray, initCloneObject$1 = _initCloneObject, isArguments$2 = isArguments_1, isArray$e = isArray_1, isArrayLikeObject = isArrayLikeObject_1, isBuffer$3 = isBufferExports, isFunction$1 = isFunction_1, isObject$9 = isObject_1, isPlainObject$6 = isPlainObject_1, isTypedArray$1 = isTypedArray_1, safeGet$1 = _safeGet, toPlainObject = toPlainObject_1;
784
784
  function baseMergeDeep$1(object2, source, key, srcIndex, mergeFunc, customizer, stack) {
785
785
  var objValue = safeGet$1(object2, key), srcValue = safeGet$1(source, key), stacked = stack.get(srcValue);
786
786
  if (stacked) {
@@ -790,10 +790,10 @@ function baseMergeDeep$1(object2, source, key, srcIndex, mergeFunc, customizer,
790
790
  var newValue = customizer ? customizer(objValue, srcValue, key + "", object2, source, stack) : void 0;
791
791
  var isCommon = newValue === void 0;
792
792
  if (isCommon) {
793
- var isArr = isArray$d(srcValue), isBuff = !isArr && isBuffer$3(srcValue), isTyped = !isArr && !isBuff && isTypedArray$1(srcValue);
793
+ var isArr = isArray$e(srcValue), isBuff = !isArr && isBuffer$3(srcValue), isTyped = !isArr && !isBuff && isTypedArray$1(srcValue);
794
794
  newValue = srcValue;
795
795
  if (isArr || isBuff || isTyped) {
796
- if (isArray$d(objValue)) {
796
+ if (isArray$e(objValue)) {
797
797
  newValue = objValue;
798
798
  } else if (isArrayLikeObject(objValue)) {
799
799
  newValue = copyArray$3(objValue);
@@ -806,9 +806,9 @@ function baseMergeDeep$1(object2, source, key, srcIndex, mergeFunc, customizer,
806
806
  } else {
807
807
  newValue = [];
808
808
  }
809
- } else if (isPlainObject$6(srcValue) || isArguments$1(srcValue)) {
809
+ } else if (isPlainObject$6(srcValue) || isArguments$2(srcValue)) {
810
810
  newValue = objValue;
811
- if (isArguments$1(objValue)) {
811
+ if (isArguments$2(objValue)) {
812
812
  newValue = toPlainObject(objValue);
813
813
  } else if (!isObject$9(objValue) || isFunction$1(objValue)) {
814
814
  newValue = initCloneObject$1(srcValue);
@@ -844,11 +844,11 @@ function baseMerge$3(object2, source, srcIndex, customizer, stack) {
844
844
  }, keysIn$3);
845
845
  }
846
846
  var _baseMerge = baseMerge$3;
847
- function identity$3(value) {
847
+ function identity$4(value) {
848
848
  return value;
849
849
  }
850
- var identity_1 = identity$3;
851
- function apply$3(func2, thisArg, args) {
850
+ var identity_1 = identity$4;
851
+ function apply$4(func2, thisArg, args) {
852
852
  switch (args.length) {
853
853
  case 0:
854
854
  return func2.call(thisArg);
@@ -861,66 +861,45 @@ function apply$3(func2, thisArg, args) {
861
861
  }
862
862
  return func2.apply(thisArg, args);
863
863
  }
864
- var _apply = apply$3;
865
- var _overRest;
866
- var hasRequired_overRest;
867
- function require_overRest() {
868
- if (hasRequired_overRest) return _overRest;
869
- hasRequired_overRest = 1;
870
- var apply2 = _apply;
871
- var nativeMax2 = Math.max;
872
- function overRest2(func2, start, transform) {
873
- start = nativeMax2(start === void 0 ? func2.length - 1 : start, 0);
874
- return function() {
875
- var args = arguments, index2 = -1, length = nativeMax2(args.length - start, 0), array2 = Array(length);
876
- while (++index2 < length) {
877
- array2[index2] = args[start + index2];
878
- }
879
- index2 = -1;
880
- var otherArgs = Array(start + 1);
881
- while (++index2 < start) {
882
- otherArgs[index2] = args[index2];
883
- }
884
- otherArgs[start] = transform(array2);
885
- return apply2(func2, this, otherArgs);
886
- };
887
- }
888
- _overRest = overRest2;
889
- return _overRest;
864
+ var _apply = apply$4;
865
+ var apply$3 = _apply;
866
+ var nativeMax$3 = Math.max;
867
+ function overRest$2(func2, start, transform) {
868
+ start = nativeMax$3(start === void 0 ? func2.length - 1 : start, 0);
869
+ return function() {
870
+ var args = arguments, index2 = -1, length = nativeMax$3(args.length - start, 0), array2 = Array(length);
871
+ while (++index2 < length) {
872
+ array2[index2] = args[start + index2];
873
+ }
874
+ index2 = -1;
875
+ var otherArgs = Array(start + 1);
876
+ while (++index2 < start) {
877
+ otherArgs[index2] = args[index2];
878
+ }
879
+ otherArgs[start] = transform(array2);
880
+ return apply$3(func2, this, otherArgs);
881
+ };
890
882
  }
891
- var constant_1;
892
- var hasRequiredConstant;
893
- function requireConstant() {
894
- if (hasRequiredConstant) return constant_1;
895
- hasRequiredConstant = 1;
896
- function constant(value) {
897
- return function() {
898
- return value;
899
- };
900
- }
901
- constant_1 = constant;
902
- return constant_1;
903
- }
904
- var _baseSetToString;
905
- var hasRequired_baseSetToString;
906
- function require_baseSetToString() {
907
- if (hasRequired_baseSetToString) return _baseSetToString;
908
- hasRequired_baseSetToString = 1;
909
- var constant = requireConstant(), defineProperty2 = _defineProperty, identity2 = identity_1;
910
- var baseSetToString = !defineProperty2 ? identity2 : function(func2, string2) {
911
- return defineProperty2(func2, "toString", {
912
- "configurable": true,
913
- "enumerable": false,
914
- "value": constant(string2),
915
- "writable": true
916
- });
883
+ var _overRest = overRest$2;
884
+ function constant$1(value) {
885
+ return function() {
886
+ return value;
917
887
  };
918
- _baseSetToString = baseSetToString;
919
- return _baseSetToString;
920
888
  }
889
+ var constant_1 = constant$1;
890
+ var constant = constant_1, defineProperty = _defineProperty, identity$3 = identity_1;
891
+ var baseSetToString$1 = !defineProperty ? identity$3 : function(func2, string2) {
892
+ return defineProperty(func2, "toString", {
893
+ "configurable": true,
894
+ "enumerable": false,
895
+ "value": constant(string2),
896
+ "writable": true
897
+ });
898
+ };
899
+ var _baseSetToString = baseSetToString$1;
921
900
  var HOT_COUNT = 800, HOT_SPAN = 16;
922
901
  var nativeNow = Date.now;
923
- function shortOut$1(func2) {
902
+ function shortOut$2(func2) {
924
903
  var count = 0, lastCalled = 0;
925
904
  return function() {
926
905
  var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
@@ -935,20 +914,13 @@ function shortOut$1(func2) {
935
914
  return func2.apply(void 0, arguments);
936
915
  };
937
916
  }
938
- var _shortOut = shortOut$1;
939
- var _setToString;
940
- var hasRequired_setToString;
941
- function require_setToString() {
942
- if (hasRequired_setToString) return _setToString;
943
- hasRequired_setToString = 1;
944
- var baseSetToString = require_baseSetToString(), shortOut2 = _shortOut;
945
- var setToString2 = shortOut2(baseSetToString);
946
- _setToString = setToString2;
947
- return _setToString;
948
- }
949
- var identity$2 = identity_1, overRest = require_overRest(), setToString$1 = require_setToString();
917
+ var _shortOut = shortOut$2;
918
+ var baseSetToString = _baseSetToString, shortOut$1 = _shortOut;
919
+ var setToString$3 = shortOut$1(baseSetToString);
920
+ var _setToString = setToString$3;
921
+ var identity$2 = identity_1, overRest$1 = _overRest, setToString$2 = _setToString;
950
922
  function baseRest$2(func2, start) {
951
- return setToString$1(overRest(func2, start, identity$2), func2 + "");
923
+ return setToString$2(overRest$1(func2, start, identity$2), func2 + "");
952
924
  }
953
925
  var _baseRest = baseRest$2;
954
926
  var eq$1 = eq_1, isArrayLike$1 = isArrayLike_1, isIndex$3 = _isIndex, isObject$7 = isObject_1;
@@ -993,10 +965,10 @@ function isSymbol$6(value) {
993
965
  return typeof value == "symbol" || isObjectLike$5(value) && baseGetTag$2(value) == symbolTag$3;
994
966
  }
995
967
  var isSymbol_1 = isSymbol$6;
996
- var isArray$c = isArray_1, isSymbol$5 = isSymbol_1;
968
+ var isArray$d = isArray_1, isSymbol$5 = isSymbol_1;
997
969
  var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
998
970
  function isKey$3(value, object2) {
999
- if (isArray$c(value)) {
971
+ if (isArray$d(value)) {
1000
972
  return false;
1001
973
  }
1002
974
  var type2 = typeof value;
@@ -1061,13 +1033,13 @@ function arrayMap$3(array2, iteratee2) {
1061
1033
  return result;
1062
1034
  }
1063
1035
  var _arrayMap = arrayMap$3;
1064
- var Symbol$3 = _Symbol, arrayMap$2 = _arrayMap, isArray$b = isArray_1, isSymbol$4 = isSymbol_1;
1065
- var symbolProto$2 = Symbol$3 ? Symbol$3.prototype : void 0, symbolToString$1 = symbolProto$2 ? symbolProto$2.toString : void 0;
1036
+ var Symbol$4 = _Symbol, arrayMap$2 = _arrayMap, isArray$c = isArray_1, isSymbol$4 = isSymbol_1;
1037
+ var symbolProto$2 = Symbol$4 ? Symbol$4.prototype : void 0, symbolToString$1 = symbolProto$2 ? symbolProto$2.toString : void 0;
1066
1038
  function baseToString$1(value) {
1067
1039
  if (typeof value == "string") {
1068
1040
  return value;
1069
1041
  }
1070
- if (isArray$b(value)) {
1042
+ if (isArray$c(value)) {
1071
1043
  return arrayMap$2(value, baseToString$1) + "";
1072
1044
  }
1073
1045
  if (isSymbol$4(value)) {
@@ -1082,9 +1054,9 @@ function toString$7(value) {
1082
1054
  return value == null ? "" : baseToString(value);
1083
1055
  }
1084
1056
  var toString_1 = toString$7;
1085
- var isArray$a = isArray_1, isKey$2 = _isKey, stringToPath$2 = _stringToPath, toString$6 = toString_1;
1057
+ var isArray$b = isArray_1, isKey$2 = _isKey, stringToPath$2 = _stringToPath, toString$6 = toString_1;
1086
1058
  function castPath$6(value, object2) {
1087
- if (isArray$a(value)) {
1059
+ if (isArray$b(value)) {
1088
1060
  return value;
1089
1061
  }
1090
1062
  return isKey$2(value, object2) ? [value] : stringToPath$2(toString$6(value));
@@ -1150,7 +1122,7 @@ function baseHasIn$1(object2, key) {
1150
1122
  return object2 != null && key in Object(object2);
1151
1123
  }
1152
1124
  var _baseHasIn = baseHasIn$1;
1153
- var castPath$2 = _castPath, isArguments = isArguments_1, isArray$9 = isArray_1, isIndex$1 = _isIndex, isLength = isLength_1, toKey$4 = _toKey;
1125
+ var castPath$2 = _castPath, isArguments$1 = isArguments_1, isArray$a = isArray_1, isIndex$1 = _isIndex, isLength = isLength_1, toKey$4 = _toKey;
1154
1126
  function hasPath$2(object2, path, hasFunc) {
1155
1127
  path = castPath$2(path, object2);
1156
1128
  var index2 = -1, length = path.length, result = false;
@@ -1165,7 +1137,7 @@ function hasPath$2(object2, path, hasFunc) {
1165
1137
  return result;
1166
1138
  }
1167
1139
  length = object2 == null ? 0 : object2.length;
1168
- return !!length && isLength(length) && isIndex$1(key, length) && (isArray$9(object2) || isArguments(object2));
1140
+ return !!length && isLength(length) && isIndex$1(key, length) && (isArray$a(object2) || isArguments$1(object2));
1169
1141
  }
1170
1142
  var _hasPath = hasPath$2;
1171
1143
  var baseHasIn = _baseHasIn, hasPath$1 = _hasPath;
@@ -1180,80 +1152,52 @@ function basePick$1(object2, paths) {
1180
1152
  });
1181
1153
  }
1182
1154
  var _basePick = basePick$1;
1183
- function arrayPush$2(array2, values) {
1155
+ function arrayPush$3(array2, values) {
1184
1156
  var index2 = -1, length = values.length, offset = array2.length;
1185
1157
  while (++index2 < length) {
1186
1158
  array2[offset + index2] = values[index2];
1187
1159
  }
1188
1160
  return array2;
1189
1161
  }
1190
- var _arrayPush = arrayPush$2;
1191
- var _isFlattenable;
1192
- var hasRequired_isFlattenable;
1193
- function require_isFlattenable() {
1194
- if (hasRequired_isFlattenable) return _isFlattenable;
1195
- hasRequired_isFlattenable = 1;
1196
- var Symbol2 = _Symbol, isArguments2 = isArguments_1, isArray2 = isArray_1;
1197
- var spreadableSymbol = Symbol2 ? Symbol2.isConcatSpreadable : void 0;
1198
- function isFlattenable(value) {
1199
- return isArray2(value) || isArguments2(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
1200
- }
1201
- _isFlattenable = isFlattenable;
1202
- return _isFlattenable;
1203
- }
1204
- var _baseFlatten;
1205
- var hasRequired_baseFlatten;
1206
- function require_baseFlatten() {
1207
- if (hasRequired_baseFlatten) return _baseFlatten;
1208
- hasRequired_baseFlatten = 1;
1209
- var arrayPush2 = _arrayPush, isFlattenable = require_isFlattenable();
1210
- function baseFlatten(array2, depth, predicate, isStrict, result) {
1211
- var index2 = -1, length = array2.length;
1212
- predicate || (predicate = isFlattenable);
1213
- result || (result = []);
1214
- while (++index2 < length) {
1215
- var value = array2[index2];
1216
- if (depth > 0 && predicate(value)) {
1217
- if (depth > 1) {
1218
- baseFlatten(value, depth - 1, predicate, isStrict, result);
1219
- } else {
1220
- arrayPush2(result, value);
1221
- }
1222
- } else if (!isStrict) {
1223
- result[result.length] = value;
1162
+ var _arrayPush = arrayPush$3;
1163
+ var Symbol$3 = _Symbol, isArguments = isArguments_1, isArray$9 = isArray_1;
1164
+ var spreadableSymbol = Symbol$3 ? Symbol$3.isConcatSpreadable : void 0;
1165
+ function isFlattenable$1(value) {
1166
+ return isArray$9(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
1167
+ }
1168
+ var _isFlattenable = isFlattenable$1;
1169
+ var arrayPush$2 = _arrayPush, isFlattenable = _isFlattenable;
1170
+ function baseFlatten$1(array2, depth, predicate, isStrict, result) {
1171
+ var index2 = -1, length = array2.length;
1172
+ predicate || (predicate = isFlattenable);
1173
+ result || (result = []);
1174
+ while (++index2 < length) {
1175
+ var value = array2[index2];
1176
+ if (depth > 0 && predicate(value)) {
1177
+ if (depth > 1) {
1178
+ baseFlatten$1(value, depth - 1, predicate, isStrict, result);
1179
+ } else {
1180
+ arrayPush$2(result, value);
1224
1181
  }
1182
+ } else if (!isStrict) {
1183
+ result[result.length] = value;
1225
1184
  }
1226
- return result;
1227
1185
  }
1228
- _baseFlatten = baseFlatten;
1229
- return _baseFlatten;
1230
- }
1231
- var flatten_1;
1232
- var hasRequiredFlatten;
1233
- function requireFlatten() {
1234
- if (hasRequiredFlatten) return flatten_1;
1235
- hasRequiredFlatten = 1;
1236
- var baseFlatten = require_baseFlatten();
1237
- function flatten2(array2) {
1238
- var length = array2 == null ? 0 : array2.length;
1239
- return length ? baseFlatten(array2, 1) : [];
1240
- }
1241
- flatten_1 = flatten2;
1242
- return flatten_1;
1243
- }
1244
- var _flatRest;
1245
- var hasRequired_flatRest;
1246
- function require_flatRest() {
1247
- if (hasRequired_flatRest) return _flatRest;
1248
- hasRequired_flatRest = 1;
1249
- var flatten2 = requireFlatten(), overRest2 = require_overRest(), setToString2 = require_setToString();
1250
- function flatRest2(func2) {
1251
- return setToString2(overRest2(func2, void 0, flatten2), func2 + "");
1252
- }
1253
- _flatRest = flatRest2;
1254
- return _flatRest;
1255
- }
1256
- var basePick = _basePick, flatRest$2 = require_flatRest();
1186
+ return result;
1187
+ }
1188
+ var _baseFlatten = baseFlatten$1;
1189
+ var baseFlatten = _baseFlatten;
1190
+ function flatten$2(array2) {
1191
+ var length = array2 == null ? 0 : array2.length;
1192
+ return length ? baseFlatten(array2, 1) : [];
1193
+ }
1194
+ var flatten_1 = flatten$2;
1195
+ var flatten$1 = flatten_1, overRest = _overRest, setToString$1 = _setToString;
1196
+ function flatRest$3(func2) {
1197
+ return setToString$1(overRest(func2, void 0, flatten$1), func2 + "");
1198
+ }
1199
+ var _flatRest = flatRest$3;
1200
+ var basePick = _basePick, flatRest$2 = _flatRest;
1257
1201
  flatRest$2(function(object2, paths) {
1258
1202
  return object2 == null ? {} : basePick(object2, paths);
1259
1203
  });
@@ -10573,7 +10517,7 @@ function updateWrapDetails$1(details, bitmask) {
10573
10517
  return details.sort();
10574
10518
  }
10575
10519
  var _updateWrapDetails = updateWrapDetails$1;
10576
- var getWrapDetails = _getWrapDetails, insertWrapDetails = _insertWrapDetails, setToString = require_setToString(), updateWrapDetails = _updateWrapDetails;
10520
+ var getWrapDetails = _getWrapDetails, insertWrapDetails = _insertWrapDetails, setToString = _setToString, updateWrapDetails = _updateWrapDetails;
10577
10521
  function setWrapToString$2(wrapper, reference, bitmask) {
10578
10522
  var source = reference + "";
10579
10523
  return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
@@ -11594,7 +11538,7 @@ function iteratee(func2) {
11594
11538
  return baseIteratee$2(typeof func2 == "function" ? func2 : baseClone$2(func2, CLONE_DEEP_FLAG$1));
11595
11539
  }
11596
11540
  var iteratee_1 = iteratee;
11597
- var createWrap = _createWrap, flatRest$1 = require_flatRest();
11541
+ var createWrap = _createWrap, flatRest$1 = _flatRest;
11598
11542
  var WRAP_REARG_FLAG = 256;
11599
11543
  var rearg = flatRest$1(function(func2, indexes) {
11600
11544
  return createWrap(func2, WRAP_REARG_FLAG, void 0, void 0, void 0, indexes);
@@ -11634,7 +11578,7 @@ var hasRequired_createFlow;
11634
11578
  function require_createFlow() {
11635
11579
  if (hasRequired_createFlow) return _createFlow;
11636
11580
  hasRequired_createFlow = 1;
11637
- var LodashWrapper = require_LodashWrapper(), flatRest2 = require_flatRest(), getData2 = require_getData(), getFuncName = require_getFuncName(), isArray2 = isArray_1, isLaziable2 = require_isLaziable();
11581
+ var LodashWrapper = require_LodashWrapper(), flatRest2 = _flatRest, getData2 = require_getData(), getFuncName = require_getFuncName(), isArray2 = isArray_1, isLaziable2 = require_isLaziable();
11638
11582
  var FUNC_ERROR_TEXT2 = "Expected a function";
11639
11583
  var WRAP_CURRY_FLAG2 = 8, WRAP_PARTIAL_FLAG2 = 32, WRAP_ARY_FLAG2 = 128, WRAP_REARG_FLAG2 = 256;
11640
11584
  function createFlow(fromRight) {
@@ -16445,7 +16389,7 @@ function customOmitClone$1(value) {
16445
16389
  return isPlainObject(value) ? void 0 : value;
16446
16390
  }
16447
16391
  var _customOmitClone = customOmitClone$1;
16448
- var arrayMap = _arrayMap, baseClone = _baseClone, baseUnset = _baseUnset, castPath = _castPath, copyObject = _copyObject, customOmitClone = _customOmitClone, flatRest = require_flatRest(), getAllKeysIn = _getAllKeysIn;
16392
+ var arrayMap = _arrayMap, baseClone = _baseClone, baseUnset = _baseUnset, castPath = _castPath, copyObject = _copyObject, customOmitClone = _customOmitClone, flatRest = _flatRest, getAllKeysIn = _getAllKeysIn;
16449
16393
  var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
16450
16394
  flatRest(function(object2, paths) {
16451
16395
  var result = {};
@@ -1,4 +1,26 @@
1
1
  "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
2
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
25
  const jsxRuntime = require("react/jsx-runtime");
4
26
  const React = require("react");
@@ -7,13 +29,23 @@ require("reactflow/dist/style.css");
7
29
  const designSystem = require("@strapi/design-system");
8
30
  const admin = require("@strapi/strapi/admin");
9
31
  const FlowCanvas = require("./FlowCanvas-C83ErNYt.js");
32
+ const extractSegmentId = (value) => {
33
+ if (!value) return null;
34
+ if (typeof value === "number") return value;
35
+ if (typeof value === "object" && value.id) return value.id;
36
+ return null;
37
+ };
38
+ const extractSegmentName = (value) => {
39
+ if (!value) return null;
40
+ if (typeof value === "object" && value.name) return value.name;
41
+ return null;
42
+ };
10
43
  const StepFlowBuilderInner = React.forwardRef(
11
44
  ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
12
45
  const [steps, setSteps] = React.useState([]);
13
46
  const [populatedSegment, setPopulatedSegment] = React.useState(null);
14
47
  const isInitialMount = React.useRef(true);
15
48
  const syncTimeoutRef = React.useRef(null);
16
- const { get } = admin.useFetchClient();
17
49
  const form = admin.useForm("StepFlowBuilder", (state) => state);
18
50
  const rawEntrySegment = React.useMemo(() => {
19
51
  const values = form?.values;
@@ -21,30 +53,38 @@ const StepFlowBuilderInner = React.forwardRef(
21
53
  }, [form?.values]);
22
54
  React.useEffect(() => {
23
55
  const fetchSegmentName = async () => {
24
- if (!rawEntrySegment?.id) {
56
+ const segmentId = extractSegmentId(rawEntrySegment);
57
+ const segmentName = extractSegmentName(rawEntrySegment);
58
+ console.log("[StepFlowBuilder] rawEntrySegment:", rawEntrySegment);
59
+ console.log("[StepFlowBuilder] segmentId:", segmentId, "segmentName:", segmentName);
60
+ if (!segmentId) {
25
61
  setPopulatedSegment(null);
26
62
  return;
27
63
  }
28
- if (rawEntrySegment.name) {
29
- setPopulatedSegment(rawEntrySegment);
64
+ if (segmentName) {
65
+ setPopulatedSegment({ id: segmentId, name: segmentName });
30
66
  return;
31
67
  }
32
68
  try {
69
+ const { useFetchClient } = await import("@strapi/strapi/admin");
70
+ const { get } = useFetchClient();
33
71
  const response = await get(
34
- `/content-manager/collection-types/api::crm-segment.crm-segment/${rawEntrySegment.id}`
72
+ `/content-manager/collection-types/api::crm-segment.crm-segment/${segmentId}`
35
73
  );
74
+ console.log("[StepFlowBuilder] API response:", response);
36
75
  const data = response?.data;
37
76
  if (data?.name) {
38
- setPopulatedSegment({ id: rawEntrySegment.id, name: data.name });
77
+ setPopulatedSegment({ id: segmentId, name: data.name });
39
78
  } else {
40
- setPopulatedSegment({ id: rawEntrySegment.id, name: `Segment #${rawEntrySegment.id}` });
79
+ setPopulatedSegment({ id: segmentId, name: `Segment #${segmentId}` });
41
80
  }
42
- } catch {
43
- setPopulatedSegment({ id: rawEntrySegment.id, name: `Segment #${rawEntrySegment.id}` });
81
+ } catch (err) {
82
+ console.warn("[StepFlowBuilder] Failed to fetch segment:", err);
83
+ setPopulatedSegment({ id: segmentId, name: `Segment #${segmentId}` });
44
84
  }
45
85
  };
46
86
  fetchSegmentName();
47
- }, [rawEntrySegment?.id, rawEntrySegment?.name, get]);
87
+ }, [rawEntrySegment]);
48
88
  const campaignContext = React.useMemo(() => {
49
89
  const values = form?.values;
50
90
  if (!values) return {};
@@ -3,15 +3,25 @@ import { forwardRef, useState, useRef, useMemo, useEffect, useCallback } from "r
3
3
  import { ReactFlowProvider } from "reactflow";
4
4
  import "reactflow/dist/style.css";
5
5
  import { Field, Flex, Badge, Box } from "@strapi/design-system";
6
- import { useFetchClient, useForm } from "@strapi/strapi/admin";
6
+ import { useForm } from "@strapi/strapi/admin";
7
7
  import { p as parseValue, F as FlowCanvas } from "./FlowCanvas-DeOEnPV0.mjs";
8
+ const extractSegmentId = (value) => {
9
+ if (!value) return null;
10
+ if (typeof value === "number") return value;
11
+ if (typeof value === "object" && value.id) return value.id;
12
+ return null;
13
+ };
14
+ const extractSegmentName = (value) => {
15
+ if (!value) return null;
16
+ if (typeof value === "object" && value.name) return value.name;
17
+ return null;
18
+ };
8
19
  const StepFlowBuilderInner = forwardRef(
9
20
  ({ name, value, onChange, intlLabel, disabled, error, required, hint }, ref) => {
10
21
  const [steps, setSteps] = useState([]);
11
22
  const [populatedSegment, setPopulatedSegment] = useState(null);
12
23
  const isInitialMount = useRef(true);
13
24
  const syncTimeoutRef = useRef(null);
14
- const { get } = useFetchClient();
15
25
  const form = useForm("StepFlowBuilder", (state) => state);
16
26
  const rawEntrySegment = useMemo(() => {
17
27
  const values = form?.values;
@@ -19,30 +29,38 @@ const StepFlowBuilderInner = forwardRef(
19
29
  }, [form?.values]);
20
30
  useEffect(() => {
21
31
  const fetchSegmentName = async () => {
22
- if (!rawEntrySegment?.id) {
32
+ const segmentId = extractSegmentId(rawEntrySegment);
33
+ const segmentName = extractSegmentName(rawEntrySegment);
34
+ console.log("[StepFlowBuilder] rawEntrySegment:", rawEntrySegment);
35
+ console.log("[StepFlowBuilder] segmentId:", segmentId, "segmentName:", segmentName);
36
+ if (!segmentId) {
23
37
  setPopulatedSegment(null);
24
38
  return;
25
39
  }
26
- if (rawEntrySegment.name) {
27
- setPopulatedSegment(rawEntrySegment);
40
+ if (segmentName) {
41
+ setPopulatedSegment({ id: segmentId, name: segmentName });
28
42
  return;
29
43
  }
30
44
  try {
45
+ const { useFetchClient } = await import("@strapi/strapi/admin");
46
+ const { get } = useFetchClient();
31
47
  const response = await get(
32
- `/content-manager/collection-types/api::crm-segment.crm-segment/${rawEntrySegment.id}`
48
+ `/content-manager/collection-types/api::crm-segment.crm-segment/${segmentId}`
33
49
  );
50
+ console.log("[StepFlowBuilder] API response:", response);
34
51
  const data = response?.data;
35
52
  if (data?.name) {
36
- setPopulatedSegment({ id: rawEntrySegment.id, name: data.name });
53
+ setPopulatedSegment({ id: segmentId, name: data.name });
37
54
  } else {
38
- setPopulatedSegment({ id: rawEntrySegment.id, name: `Segment #${rawEntrySegment.id}` });
55
+ setPopulatedSegment({ id: segmentId, name: `Segment #${segmentId}` });
39
56
  }
40
- } catch {
41
- setPopulatedSegment({ id: rawEntrySegment.id, name: `Segment #${rawEntrySegment.id}` });
57
+ } catch (err) {
58
+ console.warn("[StepFlowBuilder] Failed to fetch segment:", err);
59
+ setPopulatedSegment({ id: segmentId, name: `Segment #${segmentId}` });
42
60
  }
43
61
  };
44
62
  fetchSegmentName();
45
- }, [rawEntrySegment?.id, rawEntrySegment?.name, get]);
63
+ }, [rawEntrySegment]);
46
64
  const campaignContext = useMemo(() => {
47
65
  const values = form?.values;
48
66
  if (!values) return {};
@@ -131,7 +131,7 @@ const index = {
131
131
  components: {
132
132
  Input: async () => Promise.resolve().then(() => require(
133
133
  /* webpackChunkName: "crm-step-flow-builder" */
134
- "../_chunks/index-BzR8lcFF.js"
134
+ "../_chunks/index-M5DjnD5_.js"
135
135
  ))
136
136
  },
137
137
  options: {
@@ -149,7 +149,7 @@ const index = {
149
149
  Component: async () => {
150
150
  const component = await Promise.resolve().then(() => require(
151
151
  /* webpackChunkName: "crm-dashboard-page" */
152
- "../_chunks/index-DGwnIZkt.js"
152
+ "../_chunks/index-D_UhgipO.js"
153
153
  ));
154
154
  return component;
155
155
  },
@@ -130,7 +130,7 @@ const index = {
130
130
  components: {
131
131
  Input: async () => import(
132
132
  /* webpackChunkName: "crm-step-flow-builder" */
133
- "../_chunks/index-dntxW60u.mjs"
133
+ "../_chunks/index-o6OKhTfK.mjs"
134
134
  )
135
135
  },
136
136
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inspirer-dev/crm-dashboard",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
4
4
  "description": "CRM Dashboard and Tools",
5
5
  "strapi": {
6
6
  "name": "crm-dashboard",