@bindu-dashing/dam-solution-v2 5.8.72 → 5.8.74

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
- const shouldFetchInSearchOnlyMode = !searchOnly || hasValidSearch;
80
- console.log('## DriveContainer - folderId:', parentFolderId, 'searchOnly:', searchOnly, 'hasValidSearch:', hasValidSearch, 'shouldFetch:', shouldFetchInSearchOnlyMode, 'globalSearch:', globalSearch, 'folderSearch:', folderSearch);
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 = shouldFetchInSearchOnlyMode
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, 'shouldFetch:', shouldFetchInSearchOnlyMode);
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 && hasValidSearch) {
116
- return shopifyProducts;
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
  : [];
@@ -238,26 +244,27 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
238
244
  }, [brandId]);
239
245
  // Fetch Shopify products when in shopify search mode
240
246
  useEffect(() => {
241
- console.log("Shopify search effect - shopifySearchMode:", shopifySearchMode, "coreApiToken:", !!coreApiToken, "folderSearch:", folderSearch);
242
- // Only require coreApiToken (not coreApiUrl since we have a fallback)
243
- if (shopifySearchMode && coreApiToken && folderSearch && folderSearch.length >= 2) {
247
+ console.log("Shopify search effect - shopifySearchMode:", shopifySearchMode, "folderSearch:", folderSearch);
248
+ // Using static token, so no need to check for coreApiToken
249
+ if (shopifySearchMode && folderSearch && folderSearch.length >= 2) {
244
250
  fetchShopifyProducts(folderSearch);
245
251
  }
246
252
  else if (shopifySearchMode && (!folderSearch || folderSearch.length < 2)) {
247
253
  setState((prevState) => (Object.assign(Object.assign({}, prevState), { shopifyProducts: [] })));
248
254
  }
249
- }, [shopifySearchMode, coreApiToken, folderSearch]);
255
+ }, [shopifySearchMode, folderSearch]);
250
256
  const fetchShopifyProducts = (searchTerm) => __awaiter(this, void 0, void 0, function* () {
251
257
  setState((prevState) => (Object.assign(Object.assign({}, prevState), { shopifyLoading: true })));
252
258
  try {
253
- // Use coreApiUrl if provided, otherwise use staging URL as fallback
259
+ // Hardcoded Shopify API URL and token for now
254
260
  const shopifyApiBaseUrl = "https://staging-api.dashingone.com.au";
261
+ // Static token for Shopify API access - TODO: Replace with proper auth mechanism later
262
+ const shopifyStaticToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAyOSwicGVybWlzc2lvbnMiOiJbe1wicmVzb3VyY2VfaWRcIjoyLFwiYWNjZXNzXCI6W1wicmVhZFwiXX0se1wicmVzb3VyY2VfaWRcIjoxLFwiYWNjZXNzXCI6W1wicmVhZFwiXX0se1wicmVzb3VyY2VfaWRcIjo1LFwiYWNjZXNzXCI6W1wiY3JlYXRlXCJdfSx7XCJyZXNvdXJjZV9pZFwiOjUsXCJhY2Nlc3NcIjpbXCJyZWFkXCJdfSx7XCJyZXNvdXJjZV9pZFwiOjUsXCJhY2Nlc3NcIjpbXCJ1cGRhdGVcIl19XSIsInRlYW1zIjoiWzE1OCwxNjUsMTA0XSIsInRlYW1JRCI6MTU4LCJicmFuZFRlYW1JRCI6MTA0LCJ0aGVtZUlEIjoxLCJlbWFpbCI6Im1haGVuZHJha29uZGFkYXN1QGdtYWlsLmNvbSIsImZpcnN0TmFtZSI6Ik1haGVuZHJhIiwibGFzdE5hbWUiOiJLb25kYWRhc3UiLCJpYXQiOjE3NjUyNjE1MzIsImV4cCI6MTc2NTMyMTUzMn0.1KcLUytTQQ2cqqOfNwuMt8vIdm1mJMv5mZZtCC9M1KA";
255
263
  console.log("Shopify API Base URL:", shopifyApiBaseUrl);
256
- console.log("Core API Token available:", !!coreApiToken);
257
264
  const response = yield axios.get(`${shopifyApiBaseUrl}${FETCH_SHOPIFY_PRODUCTS_URL}`, {
258
265
  params: { title: searchTerm },
259
266
  headers: {
260
- Authorization: `Bearer ${coreApiToken}`,
267
+ Authorization: `Bearer ${shopifyStaticToken}`,
261
268
  },
262
269
  });
263
270
  // Transform Shopify products to file entity format
@@ -323,7 +330,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
323
330
  const [start, end] = dates;
324
331
  setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
325
332
  }
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" })] })) : (isLoading || shopifyLoading) ? (_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
333
+ }, 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
334
  ? get(error, "message", SOMETHING_WENT_WRONG)
328
335
  : includes(Object.values(DriveModes), type)
329
336
  ? "No data found"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.72",
3
+ "version": "5.8.74",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",