@streamoid/catalogix-chat 0.2.10 → 0.2.12
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/dist/index.d.ts +2 -1
- package/dist/index.js +199 -112
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -141,11 +141,12 @@ interface MapAttributesChatProps {
|
|
|
141
141
|
uniqueValues: Record<string, string[]>;
|
|
142
142
|
lovOptions?: Record<string, string[]>;
|
|
143
143
|
storeId: string;
|
|
144
|
+
marketplace?: string;
|
|
144
145
|
submitted?: boolean;
|
|
145
146
|
submittedValues?: Record<string, unknown>;
|
|
146
147
|
onSubmit: (values: Record<string, unknown>) => void;
|
|
147
148
|
}
|
|
148
|
-
declare function MapAttributesChat({ mappingData: initialData, mpAttributes, valuesOntologyAttributes, uniqueValues, lovOptions, submitted, onSubmit, }: MapAttributesChatProps): react_jsx_runtime.JSX.Element;
|
|
149
|
+
declare function MapAttributesChat({ mappingData: initialData, mpAttributes, valuesOntologyAttributes, uniqueValues, lovOptions, storeId, marketplace, submitted, onSubmit, }: MapAttributesChatProps): react_jsx_runtime.JSX.Element;
|
|
149
150
|
|
|
150
151
|
interface ProductAutomationProps {
|
|
151
152
|
storeId: string;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/CatalogixChat.tsx
|
|
2
|
-
import { useEffect as
|
|
2
|
+
import { useEffect as useEffect8 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/api.ts
|
|
5
5
|
var _config = {
|
|
@@ -2435,19 +2435,32 @@ function CreateStore({
|
|
|
2435
2435
|
}
|
|
2436
2436
|
|
|
2437
2437
|
// src/MapAttributes/index.tsx
|
|
2438
|
-
import { useState as useState7, useMemo as useMemo5, useCallback as useCallback5 } from "react";
|
|
2438
|
+
import React7, { useState as useState7, useMemo as useMemo5, useCallback as useCallback5, useTransition, useEffect as useEffect5 } from "react";
|
|
2439
2439
|
import {
|
|
2440
2440
|
Check as Check2,
|
|
2441
2441
|
X,
|
|
2442
2442
|
ChevronRight as ChevronRight2,
|
|
2443
|
+
ChevronDown as ChevronDown2,
|
|
2443
2444
|
Pencil as Pencil2,
|
|
2444
2445
|
Search as Search3,
|
|
2445
2446
|
ArrowRight,
|
|
2446
2447
|
ArrowLeft as ArrowLeft2,
|
|
2447
2448
|
Send,
|
|
2448
|
-
AlertTriangle
|
|
2449
|
+
AlertTriangle,
|
|
2450
|
+
Loader2 as Loader25
|
|
2449
2451
|
} from "lucide-react";
|
|
2450
2452
|
import { Fragment as Fragment4, jsx as jsx21, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2453
|
+
async function fetchLovValues(storeId, marketplace, feedCol, smpAttr) {
|
|
2454
|
+
const { catalogixBaseUrl } = getApiConfig();
|
|
2455
|
+
const params = new URLSearchParams({
|
|
2456
|
+
vendor_attribute: feedCol,
|
|
2457
|
+
mp_attribute: smpAttr
|
|
2458
|
+
});
|
|
2459
|
+
const res = await fetchJson(
|
|
2460
|
+
`${catalogixBaseUrl}/api/v1/store/${storeId}/product/${marketplace}/metavalue/unique_attributes/get?${params}`
|
|
2461
|
+
);
|
|
2462
|
+
return (res.data?.ontology_values ?? []).map((v) => v.value);
|
|
2463
|
+
}
|
|
2451
2464
|
function getAllAttributes(mpAttributes) {
|
|
2452
2465
|
return Object.values(mpAttributes).flat();
|
|
2453
2466
|
}
|
|
@@ -2462,7 +2475,7 @@ function hasIncompleteLovValues(item, valuesOntologyAttributes, uniqueValues) {
|
|
|
2462
2475
|
}
|
|
2463
2476
|
return false;
|
|
2464
2477
|
}
|
|
2465
|
-
|
|
2478
|
+
var AttributeRow = React7.memo(function AttributeRow2({
|
|
2466
2479
|
item,
|
|
2467
2480
|
index,
|
|
2468
2481
|
allAttributes,
|
|
@@ -2595,14 +2608,50 @@ function AttributeRow({
|
|
|
2595
2608
|
)
|
|
2596
2609
|
] })
|
|
2597
2610
|
] });
|
|
2598
|
-
}
|
|
2611
|
+
});
|
|
2612
|
+
var ValueRow = React7.memo(function ValueRow2({
|
|
2613
|
+
raw,
|
|
2614
|
+
mapped,
|
|
2615
|
+
options,
|
|
2616
|
+
itemIndex,
|
|
2617
|
+
attribute,
|
|
2618
|
+
onValueChange
|
|
2619
|
+
}) {
|
|
2620
|
+
return /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2", children: [
|
|
2621
|
+
/* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground truncate min-w-0 flex-1", children: raw }),
|
|
2622
|
+
/* @__PURE__ */ jsx21(ArrowRight, { className: "size-3 shrink-0 text-muted-foreground/50" }),
|
|
2623
|
+
/* @__PURE__ */ jsxs10(
|
|
2624
|
+
Select,
|
|
2625
|
+
{
|
|
2626
|
+
value: mapped || "__unmapped__",
|
|
2627
|
+
onValueChange: (v) => {
|
|
2628
|
+
const val = v === "__skip__" ? null : v;
|
|
2629
|
+
onValueChange(itemIndex, attribute, raw, val);
|
|
2630
|
+
},
|
|
2631
|
+
children: [
|
|
2632
|
+
/* @__PURE__ */ jsx21(SelectTrigger, { className: "h-7 w-[140px] text-xs", children: /* @__PURE__ */ jsx21(SelectValue, { placeholder: "Select..." }) }),
|
|
2633
|
+
/* @__PURE__ */ jsxs10(SelectContent, { children: [
|
|
2634
|
+
/* @__PURE__ */ jsx21(SelectItem, { value: "__unmapped__", children: /* @__PURE__ */ jsx21("span", { className: "text-muted-foreground", children: "Select..." }) }),
|
|
2635
|
+
/* @__PURE__ */ jsx21(SelectItem, { value: "__skip__", children: /* @__PURE__ */ jsx21("span", { className: "italic text-muted-foreground", children: "Skip" }) }),
|
|
2636
|
+
options.map((v) => /* @__PURE__ */ jsx21(SelectItem, { value: v, children: v }, v))
|
|
2637
|
+
] })
|
|
2638
|
+
]
|
|
2639
|
+
}
|
|
2640
|
+
)
|
|
2641
|
+
] });
|
|
2642
|
+
});
|
|
2599
2643
|
function ValueMappingPanel({
|
|
2600
2644
|
data,
|
|
2601
2645
|
valuesOntologyAttributes,
|
|
2602
2646
|
uniqueValues,
|
|
2603
2647
|
lovOptions,
|
|
2648
|
+
storeId,
|
|
2649
|
+
marketplace,
|
|
2604
2650
|
onValueChange
|
|
2605
2651
|
}) {
|
|
2652
|
+
const [expandedIndex, setExpandedIndex] = useState7(null);
|
|
2653
|
+
const [lovCache, setLovCache] = useState7({});
|
|
2654
|
+
const [loadingLov, setLoadingLov] = useState7(false);
|
|
2606
2655
|
const lovItems = useMemo5(() => {
|
|
2607
2656
|
const items = [];
|
|
2608
2657
|
data.forEach((item, itemIndex) => {
|
|
@@ -2634,63 +2683,83 @@ function ValueMappingPanel({
|
|
|
2634
2683
|
});
|
|
2635
2684
|
return items;
|
|
2636
2685
|
}, [data, valuesOntologyAttributes, uniqueValues]);
|
|
2686
|
+
useEffect5(() => {
|
|
2687
|
+
const first = lovItems.findIndex((i) => i.mappedCount < i.totalCount);
|
|
2688
|
+
setExpandedIndex(first >= 0 ? first : 0);
|
|
2689
|
+
}, [lovItems.length]);
|
|
2690
|
+
useEffect5(() => {
|
|
2691
|
+
if (expandedIndex == null) return;
|
|
2692
|
+
const item = lovItems[expandedIndex];
|
|
2693
|
+
if (!item || lovCache[item.attribute]) return;
|
|
2694
|
+
if (!storeId || !marketplace) return;
|
|
2695
|
+
let cancelled = false;
|
|
2696
|
+
setLoadingLov(true);
|
|
2697
|
+
fetchLovValues(storeId, marketplace, item.feedCol, item.attribute).then((values) => {
|
|
2698
|
+
if (!cancelled && values.length > 0) {
|
|
2699
|
+
setLovCache((prev) => ({ ...prev, [item.attribute]: values }));
|
|
2700
|
+
}
|
|
2701
|
+
}).catch((err) => console.warn("LOV fetch failed:", err)).finally(() => {
|
|
2702
|
+
if (!cancelled) setLoadingLov(false);
|
|
2703
|
+
});
|
|
2704
|
+
return () => {
|
|
2705
|
+
cancelled = true;
|
|
2706
|
+
};
|
|
2707
|
+
}, [expandedIndex, storeId, marketplace]);
|
|
2637
2708
|
if (lovItems.length === 0) {
|
|
2638
2709
|
return /* @__PURE__ */ jsx21("div", { className: "flex items-center justify-center py-6 text-xs text-muted-foreground", children: "No value mapping required." });
|
|
2639
2710
|
}
|
|
2640
|
-
return /* @__PURE__ */ jsx21("div", { className: "divide-y divide-border/50", children: lovItems.map((item, idx) =>
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2711
|
+
return /* @__PURE__ */ jsx21("div", { className: "divide-y divide-border/50", children: lovItems.map((item, idx) => {
|
|
2712
|
+
const isExpanded = expandedIndex === idx;
|
|
2713
|
+
const isComplete = item.mappedCount >= item.totalCount;
|
|
2714
|
+
const options = lovCache[item.attribute] ?? lovOptions[item.attribute] ?? [...new Set(
|
|
2715
|
+
Object.values(item.mappedValues).filter(Boolean)
|
|
2716
|
+
)];
|
|
2717
|
+
return /* @__PURE__ */ jsxs10("div", { className: "py-1", children: [
|
|
2645
2718
|
/* @__PURE__ */ jsxs10(
|
|
2646
|
-
"
|
|
2719
|
+
"button",
|
|
2647
2720
|
{
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
),
|
|
2721
|
+
type: "button",
|
|
2722
|
+
onClick: () => setExpandedIndex(isExpanded ? null : idx),
|
|
2723
|
+
className: "w-full flex items-center gap-1.5 py-1.5 hover:bg-muted/50 rounded-sm px-1 -mx-1 transition-colors",
|
|
2652
2724
|
children: [
|
|
2653
|
-
|
|
2654
|
-
"
|
|
2655
|
-
|
|
2725
|
+
isExpanded ? /* @__PURE__ */ jsx21(ChevronDown2, { className: "size-3 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ jsx21(ChevronRight2, { className: "size-3 shrink-0 text-muted-foreground" }),
|
|
2726
|
+
/* @__PURE__ */ jsx21("span", { className: "text-xs font-medium truncate", children: item.feedCol }),
|
|
2727
|
+
/* @__PURE__ */ jsx21(ArrowRight, { className: "size-3 shrink-0 text-muted-foreground/50" }),
|
|
2728
|
+
/* @__PURE__ */ jsx21("span", { className: "text-xs text-muted-foreground truncate", children: item.attribute }),
|
|
2729
|
+
/* @__PURE__ */ jsxs10(
|
|
2730
|
+
"span",
|
|
2731
|
+
{
|
|
2732
|
+
className: cn(
|
|
2733
|
+
"ml-auto text-[11px] tabular-nums shrink-0",
|
|
2734
|
+
isComplete ? "text-emerald-600 dark:text-emerald-400" : "text-amber-600 dark:text-amber-400"
|
|
2735
|
+
),
|
|
2736
|
+
children: [
|
|
2737
|
+
item.mappedCount,
|
|
2738
|
+
"/",
|
|
2739
|
+
item.totalCount
|
|
2740
|
+
]
|
|
2741
|
+
}
|
|
2742
|
+
)
|
|
2656
2743
|
]
|
|
2657
2744
|
}
|
|
2658
|
-
)
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
item.attribute,
|
|
2677
|
-
raw,
|
|
2678
|
-
val
|
|
2679
|
-
);
|
|
2680
|
-
},
|
|
2681
|
-
children: [
|
|
2682
|
-
/* @__PURE__ */ jsx21(SelectTrigger, { className: "h-7 w-[140px] text-xs", children: /* @__PURE__ */ jsx21(SelectValue, { placeholder: "Select..." }) }),
|
|
2683
|
-
/* @__PURE__ */ jsxs10(SelectContent, { children: [
|
|
2684
|
-
/* @__PURE__ */ jsx21(SelectItem, { value: "__unmapped__", children: /* @__PURE__ */ jsx21("span", { className: "text-muted-foreground", children: "Select..." }) }),
|
|
2685
|
-
/* @__PURE__ */ jsx21(SelectItem, { value: "__skip__", children: /* @__PURE__ */ jsx21("span", { className: "italic text-muted-foreground", children: "Skip" }) }),
|
|
2686
|
-
options.map((v) => /* @__PURE__ */ jsx21(SelectItem, { value: v, children: v }, v))
|
|
2687
|
-
] })
|
|
2688
|
-
]
|
|
2689
|
-
}
|
|
2690
|
-
)
|
|
2691
|
-
] }, raw);
|
|
2692
|
-
}) })
|
|
2693
|
-
] }, idx)) });
|
|
2745
|
+
),
|
|
2746
|
+
isExpanded && /* @__PURE__ */ jsx21("div", { className: "space-y-1 pl-4 pb-1.5 pt-1", children: loadingLov && !lovCache[item.attribute] ? /* @__PURE__ */ jsxs10("div", { className: "flex items-center gap-2 py-2 text-xs text-muted-foreground", children: [
|
|
2747
|
+
/* @__PURE__ */ jsx21(Loader25, { className: "size-3 animate-spin" }),
|
|
2748
|
+
"Loading values..."
|
|
2749
|
+
] }) : item.rawValues.map((raw) => /* @__PURE__ */ jsx21(
|
|
2750
|
+
ValueRow,
|
|
2751
|
+
{
|
|
2752
|
+
raw,
|
|
2753
|
+
mapped: item.mappedValues[raw],
|
|
2754
|
+
options,
|
|
2755
|
+
itemIndex: item.itemIndex,
|
|
2756
|
+
attribute: item.attribute,
|
|
2757
|
+
onValueChange
|
|
2758
|
+
},
|
|
2759
|
+
raw
|
|
2760
|
+
)) })
|
|
2761
|
+
] }, idx);
|
|
2762
|
+
}) });
|
|
2694
2763
|
}
|
|
2695
2764
|
function MapAttributesChat({
|
|
2696
2765
|
mappingData: initialData,
|
|
@@ -2698,6 +2767,8 @@ function MapAttributesChat({
|
|
|
2698
2767
|
valuesOntologyAttributes,
|
|
2699
2768
|
uniqueValues,
|
|
2700
2769
|
lovOptions = {},
|
|
2770
|
+
storeId,
|
|
2771
|
+
marketplace = "SMP",
|
|
2701
2772
|
submitted,
|
|
2702
2773
|
onSubmit
|
|
2703
2774
|
}) {
|
|
@@ -2705,6 +2776,8 @@ function MapAttributesChat({
|
|
|
2705
2776
|
() => initialData.map((item) => ({ ...item }))
|
|
2706
2777
|
);
|
|
2707
2778
|
const [step, setStep] = useState7("attributes");
|
|
2779
|
+
const [isPending, startTransition] = useTransition();
|
|
2780
|
+
const [isSaving, setIsSaving] = useState7(false);
|
|
2708
2781
|
const allAttributes = useMemo5(
|
|
2709
2782
|
() => getAllAttributes(mpAttributes),
|
|
2710
2783
|
[mpAttributes]
|
|
@@ -2804,23 +2877,31 @@ function MapAttributesChat({
|
|
|
2804
2877
|
}, []);
|
|
2805
2878
|
const handleValueChange = useCallback5(
|
|
2806
2879
|
(itemIndex, attribute, rawValue, mappedValue) => {
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2880
|
+
startTransition(() => {
|
|
2881
|
+
setData((prev) => {
|
|
2882
|
+
const next = [...prev];
|
|
2883
|
+
const item = { ...next[itemIndex] };
|
|
2884
|
+
const attrValues = { ...item.mappedValues[attribute] || {} };
|
|
2885
|
+
attrValues[rawValue] = mappedValue;
|
|
2886
|
+
item.mappedValues = {
|
|
2887
|
+
...item.mappedValues,
|
|
2888
|
+
[attribute]: attrValues
|
|
2889
|
+
};
|
|
2890
|
+
next[itemIndex] = item;
|
|
2891
|
+
return next;
|
|
2892
|
+
});
|
|
2818
2893
|
});
|
|
2819
2894
|
},
|
|
2820
2895
|
[]
|
|
2821
2896
|
);
|
|
2897
|
+
const handleGoToValues = useCallback5(() => {
|
|
2898
|
+
startTransition(() => setStep("values"));
|
|
2899
|
+
}, []);
|
|
2822
2900
|
const handleSubmit = useCallback5(() => {
|
|
2823
|
-
|
|
2901
|
+
setIsSaving(true);
|
|
2902
|
+
requestAnimationFrame(() => {
|
|
2903
|
+
onSubmit(data);
|
|
2904
|
+
});
|
|
2824
2905
|
}, [data, onSubmit]);
|
|
2825
2906
|
if (submitted) {
|
|
2826
2907
|
return /* @__PURE__ */ jsxs10("div", { className: "rounded-lg border border-border bg-muted/20 p-3 flex items-start gap-3", children: [
|
|
@@ -2877,30 +2958,35 @@ function MapAttributesChat({
|
|
|
2877
2958
|
] })
|
|
2878
2959
|
] })
|
|
2879
2960
|
] }),
|
|
2880
|
-
/* @__PURE__ */
|
|
2881
|
-
|
|
2882
|
-
{
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2961
|
+
/* @__PURE__ */ jsxs10("div", { className: "px-4 overflow-y-auto flex-1 min-h-0 relative", children: [
|
|
2962
|
+
isPending && /* @__PURE__ */ jsx21("div", { className: "absolute inset-0 z-10 flex items-center justify-center bg-background/60 backdrop-blur-[1px]", children: /* @__PURE__ */ jsx21(Loader25, { className: "size-5 animate-spin text-muted-foreground" }) }),
|
|
2963
|
+
step === "attributes" ? /* @__PURE__ */ jsx21("div", { className: "divide-y divide-border/50", children: sortedIndices.map((idx) => /* @__PURE__ */ jsx21(
|
|
2964
|
+
AttributeRow,
|
|
2965
|
+
{
|
|
2966
|
+
item: data[idx],
|
|
2967
|
+
index: idx,
|
|
2968
|
+
allAttributes,
|
|
2969
|
+
needsValueAttention: lovAttentionSet.has(idx),
|
|
2970
|
+
onMap: handleMap,
|
|
2971
|
+
onConfirm: handleConfirm,
|
|
2972
|
+
onIgnore: handleIgnore,
|
|
2973
|
+
onEdit: handleEdit,
|
|
2974
|
+
onUnmap: handleUnmap
|
|
2975
|
+
},
|
|
2976
|
+
idx
|
|
2977
|
+
)) }) : /* @__PURE__ */ jsx21(
|
|
2978
|
+
ValueMappingPanel,
|
|
2979
|
+
{
|
|
2980
|
+
data,
|
|
2981
|
+
valuesOntologyAttributes,
|
|
2982
|
+
uniqueValues,
|
|
2983
|
+
lovOptions,
|
|
2984
|
+
storeId,
|
|
2985
|
+
marketplace,
|
|
2986
|
+
onValueChange: handleValueChange
|
|
2987
|
+
}
|
|
2988
|
+
)
|
|
2989
|
+
] }),
|
|
2904
2990
|
/* @__PURE__ */ jsxs10("div", { className: "flex justify-end gap-2 px-4 py-2 flex-shrink-0 border-t border-border/50", children: [
|
|
2905
2991
|
step === "values" && /* @__PURE__ */ jsxs10(
|
|
2906
2992
|
Button,
|
|
@@ -2920,12 +3006,12 @@ function MapAttributesChat({
|
|
|
2920
3006
|
{
|
|
2921
3007
|
variant: "ghost",
|
|
2922
3008
|
size: "sm",
|
|
2923
|
-
onClick:
|
|
2924
|
-
disabled: progress.done < progress.total,
|
|
3009
|
+
onClick: handleGoToValues,
|
|
3010
|
+
disabled: progress.done < progress.total || isPending,
|
|
2925
3011
|
className: "h-7 text-xs",
|
|
2926
3012
|
children: [
|
|
2927
|
-
"
|
|
2928
|
-
|
|
3013
|
+
isPending ? /* @__PURE__ */ jsx21(Loader25, { className: "mr-1 size-3 animate-spin" }) : /* @__PURE__ */ jsx21(ArrowRight, { className: "ml-1 size-3" }),
|
|
3014
|
+
isPending ? "Loading..." : "Map Values"
|
|
2929
3015
|
]
|
|
2930
3016
|
}
|
|
2931
3017
|
),
|
|
@@ -2934,11 +3020,11 @@ function MapAttributesChat({
|
|
|
2934
3020
|
{
|
|
2935
3021
|
size: "sm",
|
|
2936
3022
|
onClick: handleSubmit,
|
|
2937
|
-
disabled: progress.done < progress.total || hasLovAttributes && !allValuesComplete,
|
|
3023
|
+
disabled: progress.done < progress.total || hasLovAttributes && !allValuesComplete || isSaving,
|
|
2938
3024
|
className: "h-7 text-xs bg-primary text-primary-foreground shadow-none hover:bg-primary/90",
|
|
2939
3025
|
children: [
|
|
2940
|
-
/* @__PURE__ */ jsx21(Send, { className: "mr-1 size-3" }),
|
|
2941
|
-
"Save Mapping"
|
|
3026
|
+
isSaving ? /* @__PURE__ */ jsx21(Loader25, { className: "mr-1 size-3 animate-spin" }) : /* @__PURE__ */ jsx21(Send, { className: "mr-1 size-3" }),
|
|
3027
|
+
isSaving ? "Saving..." : "Save Mapping"
|
|
2942
3028
|
]
|
|
2943
3029
|
}
|
|
2944
3030
|
)
|
|
@@ -2947,8 +3033,8 @@ function MapAttributesChat({
|
|
|
2947
3033
|
}
|
|
2948
3034
|
|
|
2949
3035
|
// src/Automations/ProductAutomation.tsx
|
|
2950
|
-
import { useState as useState9, useEffect as
|
|
2951
|
-
import { ArrowLeft as ArrowLeft3, Search as Search4, Loader2 as
|
|
3036
|
+
import { useState as useState9, useEffect as useEffect6, useCallback as useCallback7, useRef as useRef5 } from "react";
|
|
3037
|
+
import { ArrowLeft as ArrowLeft3, Search as Search4, Loader2 as Loader27, ChevronDown as ChevronDown3, Play } from "lucide-react";
|
|
2952
3038
|
|
|
2953
3039
|
// src/Automations/api.ts
|
|
2954
3040
|
async function fetchAutomationList(storeId, tag, includeGroupings = false) {
|
|
@@ -3075,7 +3161,7 @@ function parseLovResponse(response, curl, configs) {
|
|
|
3075
3161
|
|
|
3076
3162
|
// src/Automations/SchemaFieldRenderer.tsx
|
|
3077
3163
|
import { useCallback as useCallback6, useState as useState8 } from "react";
|
|
3078
|
-
import { Check as Check3, ChevronsUpDown as ChevronsUpDown2, Loader2 as
|
|
3164
|
+
import { Check as Check3, ChevronsUpDown as ChevronsUpDown2, Loader2 as Loader26, X as X2 } from "lucide-react";
|
|
3079
3165
|
import { jsx as jsx22, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3080
3166
|
function SchemaFieldRenderer({
|
|
3081
3167
|
schema,
|
|
@@ -3273,7 +3359,7 @@ function SingleSelectField({
|
|
|
3273
3359
|
] }),
|
|
3274
3360
|
item.description && /* @__PURE__ */ jsx22("p", { className: "text-xs text-muted-foreground", children: item.description }),
|
|
3275
3361
|
loading ? /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
3276
|
-
/* @__PURE__ */ jsx22(
|
|
3362
|
+
/* @__PURE__ */ jsx22(Loader26, { className: "size-4 animate-spin" }),
|
|
3277
3363
|
"Loading options..."
|
|
3278
3364
|
] }) : /* @__PURE__ */ jsxs11(
|
|
3279
3365
|
Select,
|
|
@@ -3313,7 +3399,7 @@ function MultiSelectField({
|
|
|
3313
3399
|
] }),
|
|
3314
3400
|
item.description && /* @__PURE__ */ jsx22("p", { className: "text-xs text-muted-foreground", children: item.description }),
|
|
3315
3401
|
loading ? /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
3316
|
-
/* @__PURE__ */ jsx22(
|
|
3402
|
+
/* @__PURE__ */ jsx22(Loader26, { className: "size-4 animate-spin" }),
|
|
3317
3403
|
"Loading options..."
|
|
3318
3404
|
] }) : /* @__PURE__ */ jsxs11(Popover, { open, onOpenChange: setOpen, children: [
|
|
3319
3405
|
/* @__PURE__ */ jsx22(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs11(
|
|
@@ -3443,7 +3529,7 @@ function ProductAutomation({
|
|
|
3443
3529
|
const loadingOptionsRef = useRef5(loadingOptions);
|
|
3444
3530
|
loadingOptionsRef.current = loadingOptions;
|
|
3445
3531
|
const productsCount = selectedProducts.includes("all") ? excludedProducts.length === 0 ? totalProducts : totalProducts - excludedProducts.length : productsCountProp;
|
|
3446
|
-
|
|
3532
|
+
useEffect6(() => {
|
|
3447
3533
|
setLoading(true);
|
|
3448
3534
|
fetchAutomationList(storeId, "product", true).then((data) => {
|
|
3449
3535
|
const groups = {};
|
|
@@ -3459,7 +3545,7 @@ function ProductAutomation({
|
|
|
3459
3545
|
if (sorted.length > 0) setExpandedGroups([sorted[0]]);
|
|
3460
3546
|
}).catch(console.error).finally(() => setLoading(false));
|
|
3461
3547
|
}, [storeId]);
|
|
3462
|
-
|
|
3548
|
+
useEffect6(() => {
|
|
3463
3549
|
if (!selected) {
|
|
3464
3550
|
setSchema([]);
|
|
3465
3551
|
setConfigs({});
|
|
@@ -3478,7 +3564,7 @@ function ProductAutomation({
|
|
|
3478
3564
|
configsRef.current = defaults;
|
|
3479
3565
|
}).catch(console.error).finally(() => setSchemaLoading(false));
|
|
3480
3566
|
}, [selected, storeId]);
|
|
3481
|
-
|
|
3567
|
+
useEffect6(() => {
|
|
3482
3568
|
if (schema.length === 0) return;
|
|
3483
3569
|
const flatItems = schema.flatMap((s) => s.mapping_parameters ?? [s]);
|
|
3484
3570
|
for (const item of flatItems) {
|
|
@@ -3628,7 +3714,7 @@ function ProductAutomation({
|
|
|
3628
3714
|
children: [
|
|
3629
3715
|
group,
|
|
3630
3716
|
/* @__PURE__ */ jsx23(
|
|
3631
|
-
|
|
3717
|
+
ChevronDown3,
|
|
3632
3718
|
{
|
|
3633
3719
|
className: cn(
|
|
3634
3720
|
"size-4 transition-transform",
|
|
@@ -3690,7 +3776,7 @@ function ProductAutomation({
|
|
|
3690
3776
|
disabled: !isRunAllowed() || applying,
|
|
3691
3777
|
className: "flex-1",
|
|
3692
3778
|
children: applying ? /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
3693
|
-
/* @__PURE__ */ jsx23(
|
|
3779
|
+
/* @__PURE__ */ jsx23(Loader27, { className: "size-4 animate-spin" }),
|
|
3694
3780
|
"Applying..."
|
|
3695
3781
|
] }) : /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
3696
3782
|
/* @__PURE__ */ jsx23(Play, { className: "size-4" }),
|
|
@@ -3734,7 +3820,7 @@ function formatTimeSaved(totalSeconds) {
|
|
|
3734
3820
|
}
|
|
3735
3821
|
|
|
3736
3822
|
// src/Automations/StoreAutomation.tsx
|
|
3737
|
-
import { useState as useState10, useEffect as
|
|
3823
|
+
import { useState as useState10, useEffect as useEffect7, useCallback as useCallback8, useRef as useRef6 } from "react";
|
|
3738
3824
|
import { ArrowLeft as ArrowLeft4, Settings } from "lucide-react";
|
|
3739
3825
|
import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3740
3826
|
function StoreAutomation({
|
|
@@ -3748,7 +3834,7 @@ function StoreAutomation({
|
|
|
3748
3834
|
const [automations, setAutomations] = useState10([]);
|
|
3749
3835
|
const [selectedConfigs, setSelectedConfigs] = useState10({ ...enabledAutomations });
|
|
3750
3836
|
const [selectedAutomation, setSelectedAutomation] = useState10(null);
|
|
3751
|
-
|
|
3837
|
+
useEffect7(() => {
|
|
3752
3838
|
setLoading(true);
|
|
3753
3839
|
fetchAutomationList(storeId, "default").then((data) => {
|
|
3754
3840
|
setAutomations(
|
|
@@ -3887,7 +3973,7 @@ function AutomationConfigEditor({
|
|
|
3887
3973
|
configsRef.current = configs;
|
|
3888
3974
|
const optionsRef = useRef6(options);
|
|
3889
3975
|
optionsRef.current = options;
|
|
3890
|
-
|
|
3976
|
+
useEffect7(() => {
|
|
3891
3977
|
if (!automation.isEnabled) return;
|
|
3892
3978
|
setSchemaLoading(true);
|
|
3893
3979
|
fetchAutomationSchema(storeId, automation.automation, "default").then((items) => {
|
|
@@ -3902,7 +3988,7 @@ function AutomationConfigEditor({
|
|
|
3902
3988
|
}
|
|
3903
3989
|
}).catch(console.error).finally(() => setSchemaLoading(false));
|
|
3904
3990
|
}, [storeId, automation, initialConfigs]);
|
|
3905
|
-
|
|
3991
|
+
useEffect7(() => {
|
|
3906
3992
|
if (schema.length === 0) return;
|
|
3907
3993
|
for (const item of schema) {
|
|
3908
3994
|
if (!item.curl) continue;
|
|
@@ -4031,7 +4117,7 @@ function CatalogixChat(props) {
|
|
|
4031
4117
|
const filters = uiProps.filters ?? {};
|
|
4032
4118
|
const selectedPageRange = uiProps.selectedPageRange ?? [];
|
|
4033
4119
|
const enabledAutomations = uiProps.enabledAutomations ?? {};
|
|
4034
|
-
|
|
4120
|
+
useEffect8(() => {
|
|
4035
4121
|
configureApi({ catalogixBaseUrl });
|
|
4036
4122
|
}, [catalogixBaseUrl]);
|
|
4037
4123
|
if (section === "select_products") {
|
|
@@ -4075,6 +4161,7 @@ function CatalogixChat(props) {
|
|
|
4075
4161
|
uniqueValues: uiProps.uniqueValues ?? {},
|
|
4076
4162
|
lovOptions: uiProps.lovOptions ?? {},
|
|
4077
4163
|
storeId,
|
|
4164
|
+
marketplace: uiProps.marketplace ?? "SMP",
|
|
4078
4165
|
submitted: props.submitted,
|
|
4079
4166
|
submittedValues: props.submittedValues,
|
|
4080
4167
|
onSubmit: (mapping) => onSubmit(mapping, "Attribute mapping confirmed.")
|
package/package.json
CHANGED