@bindu-dashing/dam-solution-v2 5.8.68 → 5.8.69

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.
@@ -10,5 +10,8 @@ declare function App(props: {
10
10
  url?: string;
11
11
  routerVersion: 4 | 5 | 6;
12
12
  searchOnly?: boolean;
13
+ coreApiUrl?: string;
14
+ coreApiToken?: string;
15
+ shopifySearchMode?: boolean;
13
16
  }): JSX.Element;
14
17
  export default App;
@@ -16,6 +16,9 @@ function App(props) {
16
16
  styles: props === null || props === void 0 ? void 0 : props.styles,
17
17
  appType: props === null || props === void 0 ? void 0 : props.appType,
18
18
  searchOnly: props === null || props === void 0 ? void 0 : props.searchOnly,
19
+ coreApiUrl: props === null || props === void 0 ? void 0 : props.coreApiUrl,
20
+ coreApiToken: props === null || props === void 0 ? void 0 : props.coreApiToken,
21
+ shopifySearchMode: props === null || props === void 0 ? void 0 : props.shopifySearchMode,
19
22
  };
20
23
  if (typeof window !== "undefined" && !window.process) {
21
24
  window.process = process;
@@ -30,7 +30,8 @@ import { useDamConfig } from "../hocs/DamConfigContext";
30
30
  import { createApiClient } from "../hocs/configureAxios";
31
31
  import { NOT_FOUND_IMAGE_URL } from "../utilities/constants/imageUrls";
32
32
  import ImagePickerBreadCrumbList from "./ImagePickerBreadCrumbList";
33
- import { FETCH_ASSETS_URL, FETCH_IMAGE_PCIKER_THUMBNAIL_URL, UPLOAD_IMAGE_PICKER_LOCAL_FILE_URL, } from "../utilities/constants/apiUrls";
33
+ import { FETCH_ASSETS_URL, FETCH_IMAGE_PCIKER_THUMBNAIL_URL, UPLOAD_IMAGE_PICKER_LOCAL_FILE_URL, FETCH_SHOPIFY_PRODUCTS_URL, } from "../utilities/constants/apiUrls";
34
+ import axios from "axios";
34
35
  import { showNotification } from "../common/notifications";
35
36
  import useAppParams from "../utilities/useAppParams";
36
37
  import { IoIosSearch } from "react-icons/io";
@@ -38,7 +39,7 @@ const BsUploadIcon = BsUpload;
38
39
  const IoIosSearchIcon = IoIosSearch;
39
40
  function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pickerFolderId, selectedPickerFile, imagePicker, globalSearch, setGlobalSearch, setSelectedKeys, searchOnly, }) {
40
41
  const damConfig = useDamConfig();
41
- const { rootFolderId, brand, isAdmin } = damConfig;
42
+ const { rootFolderId, brand, isAdmin, coreApiUrl, coreApiToken, shopifySearchMode } = damConfig;
42
43
  const brandId = get(brand, "_id");
43
44
  const { folderId, type, id } = useAppParams();
44
45
  const api = useMemo(() => createApiClient(damConfig), [damConfig]);
@@ -56,8 +57,10 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
56
57
  metadataKey: "",
57
58
  metadataValue: "",
58
59
  folderSearch: "",
60
+ shopifyProducts: [],
61
+ shopifyLoading: false,
59
62
  });
60
- const { selectedType, selectedDateKey, showGrid, loadingType, selectedItems, assets, sortBy, sortOrder, searchKey, searchValue, metadataKey, metadataValue, folderSearch, } = state;
63
+ const { selectedType, selectedDateKey, showGrid, loadingType, selectedItems, assets, sortBy, sortOrder, searchKey, searchValue, metadataKey, metadataValue, folderSearch, shopifyProducts, shopifyLoading, } = state;
61
64
  const nameSearchRef = useRef();
62
65
  const getSearchParams = () => {
63
66
  const params = {};
@@ -72,8 +75,6 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
72
75
  }
73
76
  return params;
74
77
  };
75
- // For searchOnly mode, only fetch when there's a search term with at least 2 characters
76
- // Check both globalSearch and folderSearch
77
78
  const hasValidSearch = (globalSearch && globalSearch.length >= 2) || (folderSearch && folderSearch.length >= 2);
78
79
  const shouldFetchInSearchOnlyMode = !searchOnly || hasValidSearch;
79
80
  console.log('## DriveContainer - folderId:', parentFolderId, 'searchOnly:', searchOnly, 'hasValidSearch:', hasValidSearch, 'shouldFetch:', shouldFetchInSearchOnlyMode, 'globalSearch:', globalSearch, 'folderSearch:', folderSearch);
@@ -88,7 +89,6 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
88
89
  ? { globalSearch }
89
90
  : {})), { sortBy: sortBy, sortOrder: sortOrder }), Object.assign(Object.assign({}, getDateRangeFromKey(selectedDateKey)), (!!selectedType ? { type: selectedType } : {}))),
90
91
  // Priority: parentFolderId (from selection) > folderId (from URL params) > id > rootFolderId
91
- // For searchOnly mode, only fetch when there's a valid search term (2+ chars)
92
92
  (() => {
93
93
  const computedFolderId = shouldFetchInSearchOnlyMode
94
94
  ? (parentFolderId
@@ -98,7 +98,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
98
98
  : id
99
99
  ? id
100
100
  : rootFolderId)
101
- : ""; // Empty string disables the query
101
+ : "";
102
102
  console.log('## useFolders computedFolderId:', computedFolderId, 'shouldFetch:', shouldFetchInSearchOnlyMode);
103
103
  return computedFolderId;
104
104
  })());
@@ -111,6 +111,10 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
111
111
  }
112
112
  }, []);
113
113
  const folders = useMemo(() => {
114
+ // For shopify search mode, return shopify products instead of DAM folders
115
+ if (shopifySearchMode && hasValidSearch) {
116
+ return shopifyProducts;
117
+ }
114
118
  // For searchOnly mode without valid search, return empty array
115
119
  if (searchOnly && !hasValidSearch) {
116
120
  return [];
@@ -118,7 +122,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
118
122
  return !!foldersPaginatedData
119
123
  ? flatMap(get(foldersPaginatedData, "pages"), "folders")
120
124
  : [];
121
- }, [foldersPaginatedData, searchOnly, hasValidSearch]);
125
+ }, [foldersPaginatedData, searchOnly, hasValidSearch, shopifySearchMode, shopifyProducts]);
122
126
  const onDateMenuClick = ({ key }) => {
123
127
  const { startDate, endDate } = getDateRangeFromKey(key);
124
128
  setState((prev) => (Object.assign(Object.assign({}, prev), { selectedDateKey: key, customDateRange: null, loadingType: "date" })));
@@ -232,6 +236,49 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
232
236
  fetchAssets();
233
237
  }
234
238
  }, [brandId]);
239
+ // Fetch Shopify products when in shopify search mode
240
+ useEffect(() => {
241
+ if (shopifySearchMode && coreApiUrl && coreApiToken && folderSearch && folderSearch.length >= 2) {
242
+ fetchShopifyProducts(folderSearch);
243
+ }
244
+ else if (shopifySearchMode && (!folderSearch || folderSearch.length < 2)) {
245
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { shopifyProducts: [] })));
246
+ }
247
+ }, [shopifySearchMode, coreApiUrl, coreApiToken, folderSearch]);
248
+ const fetchShopifyProducts = (searchTerm) => __awaiter(this, void 0, void 0, function* () {
249
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { shopifyLoading: true })));
250
+ try {
251
+ const response = yield axios.get(`${coreApiUrl}${FETCH_SHOPIFY_PRODUCTS_URL}`, {
252
+ params: { title: searchTerm },
253
+ headers: {
254
+ Authorization: `Bearer ${coreApiToken}`,
255
+ },
256
+ });
257
+ // Transform Shopify products to file entity format
258
+ // API response structure: { data: { products: [...], totalCount, currentPage, totalPages } }
259
+ const products = get(response, "data.data.products", get(response, "data.products", []));
260
+ console.log("Shopify products response:", response.data);
261
+ console.log("Extracted products:", products);
262
+ const transformedProducts = (Array.isArray(products) ? products : []).map((product) => ({
263
+ _id: product.id || product._id || `shopify-${Date.now()}-${Math.random()}`,
264
+ name: product.title || product.name || "Unknown Product",
265
+ thumbnailUrl: product.image || product.thumbnailUrl || "",
266
+ s3Url: product.image || product.s3Url || "",
267
+ type: EntityType.FILE,
268
+ fileType: "jpeg",
269
+ createdAt: product.created_at || product.createdAt || new Date().toISOString(),
270
+ updatedAt: product.updated_at || product.updatedAt || new Date().toISOString(),
271
+ size: 0,
272
+ // Keep original product data for reference
273
+ shopifyProduct: product,
274
+ }));
275
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { shopifyProducts: transformedProducts, shopifyLoading: false })));
276
+ }
277
+ catch (error) {
278
+ console.error("Error fetching Shopify products:", error);
279
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { shopifyProducts: [], shopifyLoading: false })));
280
+ }
281
+ });
235
282
  const fetchAssets = () => __awaiter(this, void 0, void 0, function* () {
236
283
  setState((prevState) => (Object.assign(Object.assign({}, prevState), { assetsLoading: true })));
237
284
  try {
@@ -270,7 +317,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
270
317
  const [start, end] = dates;
271
318
  setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
272
319
  }
273
- }, 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 ? (_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
320
+ }, 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
274
321
  ? get(error, "message", SOMETHING_WENT_WRONG)
275
322
  : includes(Object.values(DriveModes), type)
276
323
  ? "No data found"
@@ -19,7 +19,7 @@ import { SUBSCRIPTION_EXPIRED_ERROR_MESSAGE } from "./appConstants";
19
19
  const DamConfigContext = createContext(null);
20
20
  export const DamConfigProvider = ({ children, config }) => {
21
21
  // console.log(config);
22
- const { damAccessKey, secretKey, subdomain, teamIds, appType, initialRootFolderId } = config;
22
+ const { damAccessKey, secretKey, subdomain, teamIds, appType, initialRootFolderId, coreApiUrl, coreApiToken, shopifySearchMode } = config;
23
23
  const [accessToken, setAccessToken] = useState(null);
24
24
  const [user, setDamUser] = useState(null);
25
25
  const [brand, setBrand] = useState(null);
@@ -104,6 +104,9 @@ export const DamConfigProvider = ({ children, config }) => {
104
104
  rootFolderId,
105
105
  teams,
106
106
  isAdmin,
107
+ coreApiUrl,
108
+ coreApiToken,
109
+ shopifySearchMode,
107
110
  }, children: loading ? (_jsx(Loader, {})) : (_jsx(_Fragment, { children: showPaymentErr ? (_jsx("div", { className: "flex items-center justify-center h-[calc(100vh-200px)]", children: _jsx("p", { className: "text-sm font-medium text-textColor dark:text-darkTextColor", children: SUBSCRIPTION_EXPIRED_ERROR_MESSAGE }) })) : (children) })) }));
108
111
  };
109
112
  export const useDamConfig = () => useContext(DamConfigContext);
@@ -93,3 +93,4 @@ export declare const REFRESH_KEY_URL = "/keys/refresh";
93
93
  export declare const GET_BASE64_USING_PATH_URL = "/files/blob";
94
94
  export declare const FETCH_FILE_DOWNLOAD_LOGS_URL = "/dashboard/download-summary";
95
95
  export declare const FETCH_USER_DOWNLOAD_LOGS_URL = "/dashboard/download-summary/user";
96
+ export declare const FETCH_SHOPIFY_PRODUCTS_URL = "/api/products/shopify";
@@ -113,3 +113,5 @@ export const GET_BASE64_USING_PATH_URL = "/files/blob";
113
113
  //download logs
114
114
  export const FETCH_FILE_DOWNLOAD_LOGS_URL = "/dashboard/download-summary";
115
115
  export const FETCH_USER_DOWNLOAD_LOGS_URL = "/dashboard/download-summary/user";
116
+ // Shopify products (external API - uses core API URL)
117
+ export const FETCH_SHOPIFY_PRODUCTS_URL = "/api/products/shopify";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.68",
3
+ "version": "5.8.69",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",