@bindu-dashing/dam-solution-v2 5.8.71 → 5.8.73
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.
|
@@ -76,8 +76,11 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
76
76
|
return params;
|
|
77
77
|
};
|
|
78
78
|
const hasValidSearch = (globalSearch && globalSearch.length >= 2) || (folderSearch && folderSearch.length >= 2);
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
// In shopifySearchMode, NEVER fetch from DAM folders API - only use Shopify API
|
|
80
|
+
// In regular searchOnly mode, fetch only when there's a valid search
|
|
81
|
+
// In normal mode, always fetch
|
|
82
|
+
const shouldFetchFromDamApi = shopifySearchMode ? false : (!searchOnly || hasValidSearch);
|
|
83
|
+
console.log('## DriveContainer - shopifySearchMode:', shopifySearchMode, 'searchOnly:', searchOnly, 'hasValidSearch:', hasValidSearch, 'shouldFetchFromDamApi:', shouldFetchFromDamApi);
|
|
81
84
|
const { data: foldersPaginatedData, isLoading, hasNextPage, fetchNextPage, refetch, isFetching, error, } = useFolders(api, generateFoldersQueryKey(type), merge({}, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ page: DEFAULT_PAGE }, (type ? { category: type } : {})), (!!imagePicker
|
|
82
85
|
? {
|
|
83
86
|
includeSubFolders: get(imagePicker, "includeSubFolders", true),
|
|
@@ -89,8 +92,9 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
89
92
|
? { globalSearch }
|
|
90
93
|
: {})), { sortBy: sortBy, sortOrder: sortOrder }), Object.assign(Object.assign({}, getDateRangeFromKey(selectedDateKey)), (!!selectedType ? { type: selectedType } : {}))),
|
|
91
94
|
// Priority: parentFolderId (from selection) > folderId (from URL params) > id > rootFolderId
|
|
95
|
+
// In shopifySearchMode, pass empty string to disable DAM API fetch
|
|
92
96
|
(() => {
|
|
93
|
-
const computedFolderId =
|
|
97
|
+
const computedFolderId = shouldFetchFromDamApi
|
|
94
98
|
? (parentFolderId
|
|
95
99
|
? parentFolderId
|
|
96
100
|
: folderId
|
|
@@ -99,7 +103,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
99
103
|
? id
|
|
100
104
|
: rootFolderId)
|
|
101
105
|
: "";
|
|
102
|
-
console.log('## useFolders computedFolderId:', computedFolderId, '
|
|
106
|
+
console.log('## useFolders computedFolderId:', computedFolderId, 'shouldFetchFromDamApi:', shouldFetchFromDamApi);
|
|
103
107
|
return computedFolderId;
|
|
104
108
|
})());
|
|
105
109
|
useEffect(() => {
|
|
@@ -112,13 +116,15 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
112
116
|
}, []);
|
|
113
117
|
const folders = useMemo(() => {
|
|
114
118
|
// For shopify search mode, return shopify products instead of DAM folders
|
|
115
|
-
if (shopifySearchMode
|
|
116
|
-
|
|
119
|
+
if (shopifySearchMode) {
|
|
120
|
+
// In Shopify mode, only show products when there's a valid search
|
|
121
|
+
return hasValidSearch ? shopifyProducts : [];
|
|
117
122
|
}
|
|
118
|
-
// For searchOnly mode without valid search, return empty array
|
|
123
|
+
// For regular searchOnly mode without valid search, return empty array
|
|
119
124
|
if (searchOnly && !hasValidSearch) {
|
|
120
125
|
return [];
|
|
121
126
|
}
|
|
127
|
+
// Normal mode - return DAM folders
|
|
122
128
|
return !!foldersPaginatedData
|
|
123
129
|
? flatMap(get(foldersPaginatedData, "pages"), "folders")
|
|
124
130
|
: [];
|
|
@@ -251,7 +257,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
251
257
|
setState((prevState) => (Object.assign(Object.assign({}, prevState), { shopifyLoading: true })));
|
|
252
258
|
try {
|
|
253
259
|
// Use coreApiUrl if provided, otherwise use staging URL as fallback
|
|
254
|
-
const shopifyApiBaseUrl =
|
|
260
|
+
const shopifyApiBaseUrl = "https://staging-api.dashingone.com.au";
|
|
255
261
|
console.log("Shopify API Base URL:", shopifyApiBaseUrl);
|
|
256
262
|
console.log("Core API Token available:", !!coreApiToken);
|
|
257
263
|
const response = yield axios.get(`${shopifyApiBaseUrl}${FETCH_SHOPIFY_PRODUCTS_URL}`, {
|
|
@@ -323,7 +329,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
323
329
|
const [start, end] = dates;
|
|
324
330
|
setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
|
|
325
331
|
}
|
|
326
|
-
}, loading: isFetching, loadingType: loadingType }))] }), _jsx(ToggleView, { showGrid: showGrid, toggleView: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showGrid: value }))) })] }), _jsx("div", { className: "md-lib-border-b md-lib-border-borderColor md-lib-mb-4" }), searchOnly && !hasValidSearch ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center md-lib-py-16", children: [_jsx(IoIosSearchIcon, { className: "md-lib-text-6xl md-lib-text-borderColor dark:md-lib-text-darkBorderColor md-lib-mb-4" }), _jsx("p", { className: "md-lib-text-sm md-lib-font-semibold md-lib-text-textColor dark:md-lib-text-darkTextColor", children: "Search for files" }), _jsx("p", { className: "md-lib-text-xs md-lib-text-gray-500 md-lib-mt-2", children: "Enter at least 2 characters to search" })] })) : (
|
|
332
|
+
}, loading: isFetching, loadingType: loadingType }))] }), _jsx(ToggleView, { showGrid: showGrid, toggleView: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { showGrid: value }))) })] }), _jsx("div", { className: "md-lib-border-b md-lib-border-borderColor md-lib-mb-4" }), searchOnly && !hasValidSearch ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center md-lib-py-16", children: [_jsx(IoIosSearchIcon, { className: "md-lib-text-6xl md-lib-text-borderColor dark:md-lib-text-darkBorderColor md-lib-mb-4" }), _jsx("p", { className: "md-lib-text-sm md-lib-font-semibold md-lib-text-textColor dark:md-lib-text-darkTextColor", children: "Search for files" }), _jsx("p", { className: "md-lib-text-xs md-lib-text-gray-500 md-lib-mt-2", children: "Enter at least 2 characters to search" })] })) : (shopifySearchMode ? shopifyLoading : isLoading) ? (_jsx(Loader, {})) : isEmpty(folders) ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center", children: [_jsx("img", { src: NOT_FOUND_IMAGE_URL, alt: "Not Found", width: 300, height: 300 }), _jsx("p", { className: "md-lib-mt-3 md-lib-text-sm md-lib-font-semibold", children: error
|
|
327
333
|
? get(error, "message", SOMETHING_WENT_WRONG)
|
|
328
334
|
: includes(Object.values(DriveModes), type)
|
|
329
335
|
? "No data found"
|