@growupsell/react-ecommerce-core 2.0.16 → 2.0.18
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/{chunk-ID4JKOXT.js → chunk-FOGKAOV4.js} +169 -105
- package/dist/chunk-FOGKAOV4.js.map +1 -0
- package/dist/index.cjs +170 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -14
- package/dist/index.d.ts +39 -14
- package/dist/index.js +1 -1
- package/dist/provider.cjs +170 -104
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.cts +1 -1
- package/dist/provider.d.ts +1 -1
- package/dist/provider.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-ID4JKOXT.js.map +0 -1
package/dist/provider.cjs
CHANGED
|
@@ -561,10 +561,18 @@ var CartProvider = (props) => {
|
|
|
561
561
|
);
|
|
562
562
|
};
|
|
563
563
|
var useCart = () => react.useContext(CartContext);
|
|
564
|
+
var getRouteCategoryId = () => {
|
|
565
|
+
if (typeof window === "undefined") return null;
|
|
566
|
+
const match = window.location.pathname.match(/\/products\/[^/]+\/(\d+)\/?$/);
|
|
567
|
+
if (!match) return null;
|
|
568
|
+
const id = Number(match[1]);
|
|
569
|
+
return Number.isFinite(id) ? id : null;
|
|
570
|
+
};
|
|
564
571
|
var FilterContext = react.createContext({
|
|
565
572
|
selectedCategoryId: [],
|
|
566
573
|
addCategoryFilterId: () => null,
|
|
567
574
|
removeCategoryFilterId: () => null,
|
|
575
|
+
replaceCategoryFilterIds: () => null,
|
|
568
576
|
menuList: [],
|
|
569
577
|
productLoading: true,
|
|
570
578
|
currentPage: 1,
|
|
@@ -588,6 +596,9 @@ var FilterContext = react.createContext({
|
|
|
588
596
|
selectedVariants: [],
|
|
589
597
|
updateSelectedVariants: () => null,
|
|
590
598
|
variantLoading: false,
|
|
599
|
+
selectedSpecifications: [],
|
|
600
|
+
updateSpecificationOption: () => null,
|
|
601
|
+
setSelectedSpecifications: () => null,
|
|
591
602
|
total: 0,
|
|
592
603
|
limit: 10,
|
|
593
604
|
offset: 0
|
|
@@ -614,9 +625,11 @@ var FilterProvider = (props) => {
|
|
|
614
625
|
const [variantList, setVariantList] = react.useState([]);
|
|
615
626
|
const [selectedVariants, setSelectedVariants] = react.useState([]);
|
|
616
627
|
const [variantLoading, setVariantLoading] = react.useState(false);
|
|
628
|
+
const [selectedSpecifications, setSelectedSpecifications] = react.useState([]);
|
|
617
629
|
const [limit, setLimit] = react.useState(10);
|
|
618
630
|
const [offset, setOffset] = react.useState(0);
|
|
619
631
|
const [total, setTotal] = react.useState(0);
|
|
632
|
+
const waitingForRouteCategory = react.useRef(getRouteCategoryId() != null);
|
|
620
633
|
const fetchBrandList = async () => {
|
|
621
634
|
setBrandLoading(true);
|
|
622
635
|
let body = {
|
|
@@ -640,15 +653,39 @@ var FilterProvider = (props) => {
|
|
|
640
653
|
});
|
|
641
654
|
setCurrentPage(1);
|
|
642
655
|
};
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
656
|
+
const replaceCategoryFilterIds = (ids) => {
|
|
657
|
+
const unique = Array.from(new Set(ids.filter((id) => Number.isFinite(id))));
|
|
658
|
+
setSelectedCategoryId(unique);
|
|
659
|
+
setCurrentPage(1);
|
|
660
|
+
setOffset(0);
|
|
661
|
+
setMenuList([]);
|
|
662
|
+
setProductLoading(true);
|
|
663
|
+
waitingForRouteCategory.current = false;
|
|
648
664
|
};
|
|
665
|
+
const categoryFilterKey = selectedCategoryId.length === 1 ? selectedCategoryId[0] : void 0;
|
|
649
666
|
react.useEffect(() => {
|
|
650
|
-
|
|
651
|
-
|
|
667
|
+
let active = true;
|
|
668
|
+
(async () => {
|
|
669
|
+
if (!filterConfig) {
|
|
670
|
+
setFilterConfigLoading(true);
|
|
671
|
+
}
|
|
672
|
+
try {
|
|
673
|
+
const response = await api.api.getProductFilterConfig(categoryFilterKey);
|
|
674
|
+
if (active) {
|
|
675
|
+
setFilterConfig(response);
|
|
676
|
+
}
|
|
677
|
+
} catch (error) {
|
|
678
|
+
console.log(error);
|
|
679
|
+
} finally {
|
|
680
|
+
if (active) {
|
|
681
|
+
setFilterConfigLoading(false);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
})();
|
|
685
|
+
return () => {
|
|
686
|
+
active = false;
|
|
687
|
+
};
|
|
688
|
+
}, [categoryFilterKey]);
|
|
652
689
|
const removeCategoryFilterId = (id) => {
|
|
653
690
|
setSelectedCategoryId((x) => {
|
|
654
691
|
return x.filter((o) => o !== id);
|
|
@@ -666,6 +703,7 @@ var FilterProvider = (props) => {
|
|
|
666
703
|
max_price: selectedMaxPrice,
|
|
667
704
|
brand_ids: selectedCategoryId.length > 0 ? selectedBrandId : null,
|
|
668
705
|
variants: selectedCategoryId.length > 0 ? selectedVariants : null,
|
|
706
|
+
specifications: selectedSpecifications,
|
|
669
707
|
limit,
|
|
670
708
|
offset
|
|
671
709
|
};
|
|
@@ -687,6 +725,21 @@ var FilterProvider = (props) => {
|
|
|
687
725
|
return [...prevIds, id];
|
|
688
726
|
});
|
|
689
727
|
};
|
|
728
|
+
const updateSpecificationOption = (keyId, option) => {
|
|
729
|
+
setSelectedSpecifications((prev) => {
|
|
730
|
+
const current = prev.find((item) => item.id === keyId);
|
|
731
|
+
if (!current) {
|
|
732
|
+
return [...prev, { id: keyId, values: [option] }];
|
|
733
|
+
}
|
|
734
|
+
const values = current.values.includes(option) ? current.values.filter((value) => value !== option) : [...current.values, option];
|
|
735
|
+
if (values.length === 0) {
|
|
736
|
+
return prev.filter((item) => item.id !== keyId);
|
|
737
|
+
}
|
|
738
|
+
return prev.map(
|
|
739
|
+
(item) => item.id === keyId ? { ...item, values } : item
|
|
740
|
+
);
|
|
741
|
+
});
|
|
742
|
+
};
|
|
690
743
|
const updateSelectedVariants = (label) => {
|
|
691
744
|
setSelectedVariants((prevVariants) => {
|
|
692
745
|
if (prevVariants.includes(label)) {
|
|
@@ -705,9 +758,10 @@ var FilterProvider = (props) => {
|
|
|
705
758
|
setVariantLoading(false);
|
|
706
759
|
};
|
|
707
760
|
react.useEffect(() => {
|
|
708
|
-
if (
|
|
709
|
-
|
|
710
|
-
|
|
761
|
+
if (filterConfigLoading) return;
|
|
762
|
+
if (waitingForRouteCategory.current && selectedCategoryId.length === 0) return;
|
|
763
|
+
waitingForRouteCategory.current = false;
|
|
764
|
+
fetchProductList();
|
|
711
765
|
}, [
|
|
712
766
|
selectedCategoryId,
|
|
713
767
|
currentPage,
|
|
@@ -718,9 +772,31 @@ var FilterProvider = (props) => {
|
|
|
718
772
|
selectedMaxPrice,
|
|
719
773
|
selectedBrandId,
|
|
720
774
|
selectedVariants,
|
|
775
|
+
selectedSpecifications,
|
|
721
776
|
limit,
|
|
722
777
|
offset
|
|
723
778
|
]);
|
|
779
|
+
react.useEffect(() => {
|
|
780
|
+
const keys = filterConfig?.specifications ?? [];
|
|
781
|
+
const allowed = new Map(
|
|
782
|
+
keys.map((key) => [
|
|
783
|
+
key.id,
|
|
784
|
+
new Set(key.options ?? [])
|
|
785
|
+
])
|
|
786
|
+
);
|
|
787
|
+
setSelectedSpecifications((prev) => {
|
|
788
|
+
const next = prev.map((item) => ({
|
|
789
|
+
...item,
|
|
790
|
+
values: item.values.filter((value) => allowed.get(item.id)?.has(value))
|
|
791
|
+
})).filter((item) => item.values.length > 0 && allowed.has(item.id));
|
|
792
|
+
if (next.length === prev.length && next.every(
|
|
793
|
+
(item, index) => item.id === prev[index].id && item.values.length === prev[index].values.length && item.values.every((value, valueIndex) => value === prev[index].values[valueIndex])
|
|
794
|
+
)) {
|
|
795
|
+
return prev;
|
|
796
|
+
}
|
|
797
|
+
return next;
|
|
798
|
+
});
|
|
799
|
+
}, [filterConfig]);
|
|
724
800
|
const handlePageChange = (newOffset) => {
|
|
725
801
|
setOffset(newOffset);
|
|
726
802
|
};
|
|
@@ -738,6 +814,7 @@ var FilterProvider = (props) => {
|
|
|
738
814
|
setMenuList,
|
|
739
815
|
addCategoryFilterId,
|
|
740
816
|
removeCategoryFilterId,
|
|
817
|
+
replaceCategoryFilterIds,
|
|
741
818
|
menuList,
|
|
742
819
|
productLoading,
|
|
743
820
|
currentPage,
|
|
@@ -760,6 +837,9 @@ var FilterProvider = (props) => {
|
|
|
760
837
|
selectedVariants,
|
|
761
838
|
updateSelectedVariants,
|
|
762
839
|
variantLoading,
|
|
840
|
+
selectedSpecifications,
|
|
841
|
+
updateSpecificationOption,
|
|
842
|
+
setSelectedSpecifications,
|
|
763
843
|
total,
|
|
764
844
|
limit,
|
|
765
845
|
offset
|
|
@@ -944,6 +1024,7 @@ var HomeConfigProvider = (props) => {
|
|
|
944
1024
|
});
|
|
945
1025
|
const { token } = useThemeEdit();
|
|
946
1026
|
const themeConfig = react.useContext(BusinessConfigContext);
|
|
1027
|
+
const themeId = themeConfig.theme.id;
|
|
947
1028
|
const [themeConfigData, setThemeConfigData] = react.useState(
|
|
948
1029
|
props.initialThemeContent ?? {}
|
|
949
1030
|
);
|
|
@@ -951,16 +1032,13 @@ var HomeConfigProvider = (props) => {
|
|
|
951
1032
|
const updateRef = react.useRef(false);
|
|
952
1033
|
const [loading, setLoading] = react.useState(!hasInitial);
|
|
953
1034
|
const getThemeConfig = react.useCallback(async () => {
|
|
954
|
-
if (!
|
|
955
|
-
setLoading(
|
|
956
|
-
} else {
|
|
1035
|
+
if (hasInitial || !themeId) {
|
|
1036
|
+
if (!themeId) setLoading(false);
|
|
957
1037
|
return;
|
|
958
1038
|
}
|
|
1039
|
+
setLoading(true);
|
|
959
1040
|
try {
|
|
960
|
-
const response = await api$1.retrieveThemeContent(
|
|
961
|
-
themeConfig.theme.id,
|
|
962
|
-
props.page
|
|
963
|
-
);
|
|
1041
|
+
const response = await api$1.retrieveThemeContent(themeId, props.page);
|
|
964
1042
|
setThemeConfigData(response);
|
|
965
1043
|
if (response?.data && Array.isArray(response.data)) {
|
|
966
1044
|
setSelectedConfig(
|
|
@@ -975,7 +1053,7 @@ var HomeConfigProvider = (props) => {
|
|
|
975
1053
|
} finally {
|
|
976
1054
|
setLoading(false);
|
|
977
1055
|
}
|
|
978
|
-
}, [
|
|
1056
|
+
}, [themeId, hasInitial, props.page]);
|
|
979
1057
|
const onUpdateThemeContent = react.useCallback(
|
|
980
1058
|
async (configToUpdate = selectedConfig) => {
|
|
981
1059
|
try {
|
|
@@ -986,16 +1064,9 @@ var HomeConfigProvider = (props) => {
|
|
|
986
1064
|
};
|
|
987
1065
|
if (updateRef.current) return;
|
|
988
1066
|
updateRef.current = true;
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
props.page,
|
|
993
|
-
token
|
|
994
|
-
);
|
|
995
|
-
const updatedResponse = await api$1.retrieveThemeContent(
|
|
996
|
-
themeConfig.theme.id,
|
|
997
|
-
props.page
|
|
998
|
-
);
|
|
1067
|
+
if (!themeId) return;
|
|
1068
|
+
await api$1.updateThemeContent(body, themeId, props.page, token);
|
|
1069
|
+
const updatedResponse = await api$1.retrieveThemeContent(themeId, props.page);
|
|
999
1070
|
setThemeConfigData(updatedResponse);
|
|
1000
1071
|
} catch (error) {
|
|
1001
1072
|
console.error("Error updating theme content:", error);
|
|
@@ -1003,7 +1074,7 @@ var HomeConfigProvider = (props) => {
|
|
|
1003
1074
|
updateRef.current = false;
|
|
1004
1075
|
}
|
|
1005
1076
|
},
|
|
1006
|
-
[isInitialized, token,
|
|
1077
|
+
[isInitialized, token, themeId, selectedConfig]
|
|
1007
1078
|
);
|
|
1008
1079
|
const addConfig = react.useCallback(
|
|
1009
1080
|
async (config) => {
|
|
@@ -1069,73 +1140,76 @@ var HomeConfigProvider = (props) => {
|
|
|
1069
1140
|
);
|
|
1070
1141
|
};
|
|
1071
1142
|
var useHomeConfig = () => react.useContext(HomeConfigContext);
|
|
1072
|
-
var
|
|
1143
|
+
var HERO_SECTION_SLUG = "hero_section";
|
|
1144
|
+
function resolveHeroSection(sectionRow) {
|
|
1145
|
+
if (sectionRow == null) return null;
|
|
1146
|
+
const data = sectionRow.data !== void 0 ? sectionRow.data : sectionRow;
|
|
1147
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return null;
|
|
1148
|
+
if (typeof data.type !== "string" || !data.type) return null;
|
|
1149
|
+
return { type: data.type, data: data.data };
|
|
1150
|
+
}
|
|
1151
|
+
var HomeConfigHeroSectionContext = react.createContext({
|
|
1073
1152
|
loading: true,
|
|
1074
|
-
|
|
1075
|
-
|
|
1153
|
+
heroSection: null,
|
|
1154
|
+
onUpdateHeroSection: async () => void 0
|
|
1076
1155
|
});
|
|
1077
|
-
var
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
const [heroSliderConfigData, setHeroSliderConfigData] = react.useState(
|
|
1081
|
-
() => hasInitial ? props.initialThemeContent.data : []
|
|
1156
|
+
var HomeConfigHeroSectionProvider = (props) => {
|
|
1157
|
+
const [heroSection, setHeroSection] = react.useState(
|
|
1158
|
+
() => props.heroContentFetched ? resolveHeroSection(props.initialHeroSection) : null
|
|
1082
1159
|
);
|
|
1160
|
+
const [loading, setLoading] = react.useState(!props.heroContentFetched);
|
|
1083
1161
|
const { token } = useThemeEdit();
|
|
1084
1162
|
const themeConfig = react.useContext(BusinessConfigContext);
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1163
|
+
const themeId = themeConfig.theme.id;
|
|
1164
|
+
const loadHeroSection = react.useCallback(async () => {
|
|
1165
|
+
if (props.heroContentFetched || !themeId) {
|
|
1166
|
+
if (!themeId) setLoading(false);
|
|
1087
1167
|
return;
|
|
1088
1168
|
}
|
|
1089
1169
|
setLoading(true);
|
|
1090
1170
|
try {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1171
|
+
let sectionRow = null;
|
|
1172
|
+
try {
|
|
1173
|
+
sectionRow = await api$1.retrieveThemeContent(themeId, HERO_SECTION_SLUG);
|
|
1174
|
+
} catch {
|
|
1175
|
+
sectionRow = null;
|
|
1176
|
+
}
|
|
1177
|
+
setHeroSection(resolveHeroSection(sectionRow));
|
|
1096
1178
|
} catch (error) {
|
|
1097
|
-
console.error("Error fetching hero
|
|
1179
|
+
console.error("Error fetching hero section:", error);
|
|
1098
1180
|
} finally {
|
|
1099
1181
|
setLoading(false);
|
|
1100
1182
|
}
|
|
1101
|
-
}, [
|
|
1183
|
+
}, [props.heroContentFetched, themeId]);
|
|
1102
1184
|
react.useEffect(() => {
|
|
1103
|
-
|
|
1104
|
-
}, [
|
|
1105
|
-
const
|
|
1185
|
+
loadHeroSection();
|
|
1186
|
+
}, [loadHeroSection]);
|
|
1187
|
+
const onUpdateHeroSection = async (next) => {
|
|
1106
1188
|
setLoading(true);
|
|
1107
1189
|
try {
|
|
1108
1190
|
const body = {
|
|
1109
|
-
data:
|
|
1110
|
-
slug:
|
|
1191
|
+
data: next ? { type: next.type, data: next.data } : { type: null, data: null },
|
|
1192
|
+
slug: HERO_SECTION_SLUG,
|
|
1111
1193
|
platform: typeof window !== "undefined" ? "website" : "app"
|
|
1112
1194
|
};
|
|
1113
|
-
await api$1.updateThemeContent(
|
|
1114
|
-
|
|
1115
|
-
themeConfig?.theme?.id,
|
|
1116
|
-
"hero_slider",
|
|
1117
|
-
token
|
|
1118
|
-
);
|
|
1119
|
-
const updatedResponse = await api$1.retrieveThemeContent(
|
|
1120
|
-
themeConfig.theme.id,
|
|
1121
|
-
"hero_slider"
|
|
1122
|
-
);
|
|
1123
|
-
setHeroSliderConfigData(updatedResponse.data);
|
|
1195
|
+
await api$1.updateThemeContent(body, themeId, HERO_SECTION_SLUG, token);
|
|
1196
|
+
setHeroSection(next);
|
|
1124
1197
|
} catch (error) {
|
|
1125
|
-
console.error("Error updating
|
|
1198
|
+
console.error("Error updating hero section:", error);
|
|
1199
|
+
throw error;
|
|
1126
1200
|
} finally {
|
|
1127
1201
|
setLoading(false);
|
|
1128
1202
|
}
|
|
1129
1203
|
};
|
|
1130
1204
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1131
|
-
|
|
1205
|
+
HomeConfigHeroSectionContext.Provider,
|
|
1132
1206
|
{
|
|
1133
|
-
value: { loading,
|
|
1207
|
+
value: { loading, heroSection, onUpdateHeroSection },
|
|
1134
1208
|
children: props.children
|
|
1135
1209
|
}
|
|
1136
1210
|
);
|
|
1137
1211
|
};
|
|
1138
|
-
var
|
|
1212
|
+
var useHomeConfigHeroSection = () => react.useContext(HomeConfigHeroSectionContext);
|
|
1139
1213
|
var CustomPageConfigContext = react.createContext({
|
|
1140
1214
|
selectedConfig: [],
|
|
1141
1215
|
setSelectedConfig: () => null,
|
|
@@ -1143,28 +1217,26 @@ var CustomPageConfigContext = react.createContext({
|
|
|
1143
1217
|
updateConfig: () => null,
|
|
1144
1218
|
removeConfig: () => null,
|
|
1145
1219
|
moveConfig: () => null,
|
|
1146
|
-
heroSliderConfigData: [],
|
|
1147
|
-
onUpdateHeroSlider: async () => void 0,
|
|
1148
1220
|
loading: true
|
|
1149
1221
|
});
|
|
1150
1222
|
var CustomPageConfigProvider = (props) => {
|
|
1151
1223
|
const { token } = useThemeEdit();
|
|
1152
1224
|
const [selectedConfig, setSelectedConfig] = react.useState([]);
|
|
1153
|
-
const [
|
|
1225
|
+
const [heroSection, setHeroSection] = react.useState(null);
|
|
1154
1226
|
const [loading, setLoading] = react.useState(true);
|
|
1155
1227
|
const selectedConfigRef = react.useRef([]);
|
|
1156
|
-
const
|
|
1228
|
+
const heroSectionRef = react.useRef(null);
|
|
1157
1229
|
const saveQueueRef = react.useRef(Promise.resolve());
|
|
1158
1230
|
const load = react.useCallback(async () => {
|
|
1159
1231
|
setLoading(true);
|
|
1160
1232
|
try {
|
|
1161
1233
|
const row = await api$1.getCustomPageContent(props.pageId, token);
|
|
1162
1234
|
const fromContent = api$1.splitCustomPageContent(row?.content);
|
|
1163
|
-
const
|
|
1235
|
+
const hero = row?.hero_content !== void 0 && row?.hero_content !== null ? api$1.readHeroSectionValue(row.hero_content) : fromContent.heroSection;
|
|
1164
1236
|
selectedConfigRef.current = fromContent.blocks;
|
|
1165
|
-
|
|
1237
|
+
heroSectionRef.current = hero;
|
|
1166
1238
|
setSelectedConfig(fromContent.blocks);
|
|
1167
|
-
|
|
1239
|
+
setHeroSection(hero);
|
|
1168
1240
|
} catch (e) {
|
|
1169
1241
|
console.error("Error loading custom page content:", e);
|
|
1170
1242
|
} finally {
|
|
@@ -1172,16 +1244,16 @@ var CustomPageConfigProvider = (props) => {
|
|
|
1172
1244
|
}
|
|
1173
1245
|
}, [props.pageId, token]);
|
|
1174
1246
|
const persistLatest = react.useCallback(
|
|
1175
|
-
(
|
|
1247
|
+
() => {
|
|
1176
1248
|
const run = async () => {
|
|
1177
1249
|
try {
|
|
1178
1250
|
const blocks = selectedConfigRef.current;
|
|
1179
|
-
const
|
|
1251
|
+
const hero = heroSectionRef.current;
|
|
1180
1252
|
await api$1.updateCustomPageContent(
|
|
1181
1253
|
props.pageId,
|
|
1182
1254
|
{
|
|
1183
|
-
content: api$1.mergeCustomPageContent(blocks,
|
|
1184
|
-
|
|
1255
|
+
content: api$1.mergeCustomPageContent(blocks, hero),
|
|
1256
|
+
hero_content: hero ? { type: hero.type, data: hero.data } : { type: null, data: null }
|
|
1185
1257
|
},
|
|
1186
1258
|
token
|
|
1187
1259
|
);
|
|
@@ -1240,12 +1312,11 @@ var CustomPageConfigProvider = (props) => {
|
|
|
1240
1312
|
},
|
|
1241
1313
|
[persistLatest]
|
|
1242
1314
|
);
|
|
1243
|
-
const
|
|
1244
|
-
async (
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
await persistLatest(true);
|
|
1315
|
+
const onUpdateHeroSection = react.useCallback(
|
|
1316
|
+
async (next) => {
|
|
1317
|
+
heroSectionRef.current = next;
|
|
1318
|
+
setHeroSection(next);
|
|
1319
|
+
await persistLatest();
|
|
1249
1320
|
},
|
|
1250
1321
|
[persistLatest]
|
|
1251
1322
|
);
|
|
@@ -1262,14 +1333,12 @@ var CustomPageConfigProvider = (props) => {
|
|
|
1262
1333
|
updateConfig,
|
|
1263
1334
|
removeConfig,
|
|
1264
1335
|
moveConfig,
|
|
1265
|
-
heroSliderConfigData,
|
|
1266
|
-
onUpdateHeroSlider,
|
|
1267
1336
|
loading
|
|
1268
1337
|
},
|
|
1269
1338
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1270
|
-
|
|
1339
|
+
HomeConfigHeroSectionContext.Provider,
|
|
1271
1340
|
{
|
|
1272
|
-
value: { loading,
|
|
1341
|
+
value: { loading, heroSection, onUpdateHeroSection },
|
|
1273
1342
|
children: props.children
|
|
1274
1343
|
}
|
|
1275
1344
|
)
|
|
@@ -1445,17 +1514,16 @@ var HeaderFooterProvider = (props) => {
|
|
|
1445
1514
|
);
|
|
1446
1515
|
const { token } = useThemeEdit();
|
|
1447
1516
|
const themeConfig = useBusiness();
|
|
1517
|
+
const themeId = themeConfig.theme.id;
|
|
1448
1518
|
const [loading, setLoading] = react.useState(!hasInitial);
|
|
1449
1519
|
const getThemeConfig = react.useCallback(async () => {
|
|
1450
|
-
if (hasInitial) {
|
|
1520
|
+
if (hasInitial || !themeId) {
|
|
1521
|
+
if (!themeId) setLoading(false);
|
|
1451
1522
|
return;
|
|
1452
1523
|
}
|
|
1453
1524
|
setLoading(true);
|
|
1454
1525
|
try {
|
|
1455
|
-
const response = await api.api.retrieveThemeContent(
|
|
1456
|
-
themeConfig.theme.id,
|
|
1457
|
-
props.page
|
|
1458
|
-
);
|
|
1526
|
+
const response = await api.api.retrieveThemeContent(themeId, props.page);
|
|
1459
1527
|
response.slug === "header" && setHeaderConfig(response.data);
|
|
1460
1528
|
response.slug === "footer" && setFooterConfig(response.data);
|
|
1461
1529
|
response.slug === "announcement" && setAnnouncementConfig(response.data);
|
|
@@ -1464,7 +1532,7 @@ var HeaderFooterProvider = (props) => {
|
|
|
1464
1532
|
} finally {
|
|
1465
1533
|
setLoading(false);
|
|
1466
1534
|
}
|
|
1467
|
-
}, [
|
|
1535
|
+
}, [themeId, hasInitial, props.page]);
|
|
1468
1536
|
const onUpdateThemeContent = react.useCallback(
|
|
1469
1537
|
async (configToUpdate) => {
|
|
1470
1538
|
try {
|
|
@@ -1473,14 +1541,10 @@ var HeaderFooterProvider = (props) => {
|
|
|
1473
1541
|
slug: props.page,
|
|
1474
1542
|
platform: typeof window !== "undefined" ? "website" : "app"
|
|
1475
1543
|
};
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
themeConfig.theme.id,
|
|
1479
|
-
props.page,
|
|
1480
|
-
token
|
|
1481
|
-
);
|
|
1544
|
+
if (!themeId) return;
|
|
1545
|
+
await api.api.updateThemeContent(body, themeId, props.page, token);
|
|
1482
1546
|
const updatedResponse = await api.api.retrieveThemeContent(
|
|
1483
|
-
|
|
1547
|
+
themeId,
|
|
1484
1548
|
props.page
|
|
1485
1549
|
);
|
|
1486
1550
|
updatedResponse.slug === "header" && setHeaderConfig(updatedResponse.data);
|
|
@@ -1492,7 +1556,7 @@ var HeaderFooterProvider = (props) => {
|
|
|
1492
1556
|
setLoading(false);
|
|
1493
1557
|
}
|
|
1494
1558
|
},
|
|
1495
|
-
[props.page,
|
|
1559
|
+
[props.page, themeId, token]
|
|
1496
1560
|
);
|
|
1497
1561
|
react.useEffect(() => {
|
|
1498
1562
|
getThemeConfig();
|
|
@@ -1967,11 +2031,12 @@ exports.CustomerConfigContext = CustomerConfigContext;
|
|
|
1967
2031
|
exports.CustomerConfigProvider = CustomerConfigProvider;
|
|
1968
2032
|
exports.FilterContext = FilterContext;
|
|
1969
2033
|
exports.FilterProvider = FilterProvider;
|
|
2034
|
+
exports.HERO_SECTION_SLUG = HERO_SECTION_SLUG;
|
|
1970
2035
|
exports.HeaderFooterContext = HeaderFooterContext;
|
|
1971
2036
|
exports.HeaderFooterProvider = HeaderFooterProvider;
|
|
1972
2037
|
exports.HomeConfigContext = HomeConfigContext;
|
|
1973
|
-
exports.
|
|
1974
|
-
exports.
|
|
2038
|
+
exports.HomeConfigHeroSectionContext = HomeConfigHeroSectionContext;
|
|
2039
|
+
exports.HomeConfigHeroSectionProvider = HomeConfigHeroSectionProvider;
|
|
1975
2040
|
exports.HomeConfigProvider = HomeConfigProvider;
|
|
1976
2041
|
exports.LiveSupportWidgetProvider = LiveSupportWidgetProvider;
|
|
1977
2042
|
exports.MenuCartContext = MenuCartContext;
|
|
@@ -1991,6 +2056,7 @@ exports.ThemeEditProvider = ThemeEditProvider;
|
|
|
1991
2056
|
exports.ToastSupportProvider = ToastSupportProvider;
|
|
1992
2057
|
exports.WishlistContext = WishlistContext;
|
|
1993
2058
|
exports.WishlistProvider = WishlistProvider;
|
|
2059
|
+
exports.resolveHeroSection = resolveHeroSection;
|
|
1994
2060
|
exports.useAuth = useAuth;
|
|
1995
2061
|
exports.useBusiness = useBusiness;
|
|
1996
2062
|
exports.useBusinessContext = useBusinessContext;
|
|
@@ -2002,7 +2068,7 @@ exports.useCustomer = useCustomer;
|
|
|
2002
2068
|
exports.useFilter = useFilter;
|
|
2003
2069
|
exports.useHeaderFooter = useHeaderFooter;
|
|
2004
2070
|
exports.useHomeConfig = useHomeConfig;
|
|
2005
|
-
exports.
|
|
2071
|
+
exports.useHomeConfigHeroSection = useHomeConfigHeroSection;
|
|
2006
2072
|
exports.useLiveSupportWidget = useLiveSupportWidget;
|
|
2007
2073
|
exports.useMenuCart = useMenuCart;
|
|
2008
2074
|
exports.useMenuFilter = useMenuFilter;
|