@bindu-dashing/dam-solution-v2 5.9.246 → 5.9.249
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.
|
@@ -13,7 +13,7 @@ import _, { filter, find, first, flatMap, get, includes, isEmpty, merge, } from
|
|
|
13
13
|
import FolderListView from "./FolderListView";
|
|
14
14
|
import FolderGridView from "./FolderGridView";
|
|
15
15
|
import TypeAndDateFilters from "../common/folders/TypeAndDateFilters";
|
|
16
|
-
import { Button
|
|
16
|
+
import { Button } from "antd";
|
|
17
17
|
import { addQueryParams, getDateRangeFromKey, getDateRangeLabel } from "../hocs/helpers";
|
|
18
18
|
import { useFolders } from "../react-query/services/folder-services";
|
|
19
19
|
import { DATE_FORMAT, DEFAULT_PAGE } from "../hocs/appConstants";
|
|
@@ -25,17 +25,14 @@ import BreadCrumbList from "./BreadCrumbList";
|
|
|
25
25
|
import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
|
|
26
26
|
import { DriveModes, EntityType, FileTypes, NotificationStatus, SortByKeys, SortOrders, } from "../utilities/constants/interface";
|
|
27
27
|
import { generateFoldersQueryKey } from "../utilities/constants/queryKeys";
|
|
28
|
-
import CustomButton from "../common/Button";
|
|
29
|
-
import { BsUpload } from "react-icons/bs";
|
|
30
28
|
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
31
29
|
import { createApiClient } from "../hocs/configureAxios";
|
|
32
30
|
import { NOT_FOUND_IMAGE_URL } from "../utilities/constants/imageUrls";
|
|
33
31
|
import ImagePickerBreadCrumbList from "./ImagePickerBreadCrumbList";
|
|
34
|
-
import { FETCH_ASSETS_URL
|
|
32
|
+
import { FETCH_ASSETS_URL } from "../utilities/constants/apiUrls";
|
|
35
33
|
import { showNotification } from "../common/notifications";
|
|
36
34
|
import useAppParams from "../utilities/useAppParams";
|
|
37
35
|
import { RefetchFoldersProvider } from "../utilities/FoldersContext";
|
|
38
|
-
const BsUploadIcon = BsUpload;
|
|
39
36
|
function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pickerFolderId, selectedPickerFile, imagePicker, globalSearch, setGlobalSearch, setSelectedKeys, }) {
|
|
40
37
|
const damConfig = useDamConfig();
|
|
41
38
|
const { rootFolderId, brand, isAdmin } = damConfig;
|
|
@@ -46,7 +43,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
46
43
|
selectedType: "",
|
|
47
44
|
selectedDateKey: "",
|
|
48
45
|
customDateRange: null,
|
|
49
|
-
showGrid:
|
|
46
|
+
showGrid: true,
|
|
50
47
|
loadingType: "",
|
|
51
48
|
selectedItems: {},
|
|
52
49
|
assets: [],
|
|
@@ -179,54 +176,6 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
179
176
|
globalSearch,
|
|
180
177
|
]);
|
|
181
178
|
const parentFolder = useMemo(() => get(first(get(foldersPaginatedData, "pages", [])), "folder", {}), [foldersPaginatedData]);
|
|
182
|
-
const onSelectNewFile = (file) => __awaiter(this, void 0, void 0, function* () {
|
|
183
|
-
try {
|
|
184
|
-
setState((prevState) => {
|
|
185
|
-
return Object.assign(Object.assign({}, prevState), { loadingType: "NEW_FILE_UPLOAD" });
|
|
186
|
-
});
|
|
187
|
-
const response = yield api.post(UPLOAD_IMAGE_PICKER_LOCAL_FILE_URL, {
|
|
188
|
-
brandId,
|
|
189
|
-
folderId: parentFolderId || folderId || rootFolderId,
|
|
190
|
-
name: file.name,
|
|
191
|
-
size: file.size,
|
|
192
|
-
});
|
|
193
|
-
// console.log(response);
|
|
194
|
-
const [name, extension] = file.name.split(".");
|
|
195
|
-
const filePath = get(response, "data.filePath");
|
|
196
|
-
const url = get(response, "data.url");
|
|
197
|
-
fetch(url, {
|
|
198
|
-
method: "PUT",
|
|
199
|
-
body: file,
|
|
200
|
-
})
|
|
201
|
-
.then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
202
|
-
// setSelectedFile()
|
|
203
|
-
const fileResponse = yield api.post(FETCH_IMAGE_PCIKER_THUMBNAIL_URL, {
|
|
204
|
-
brandId,
|
|
205
|
-
folderId: parentFolderId || folderId || rootFolderId,
|
|
206
|
-
name: file.name,
|
|
207
|
-
mimetype: `image/${extension}`,
|
|
208
|
-
s3Path: filePath,
|
|
209
|
-
});
|
|
210
|
-
// console.log(fileResponse);
|
|
211
|
-
if (setSelectedFile) {
|
|
212
|
-
setSelectedFile(fileResponse === null || fileResponse === void 0 ? void 0 : fileResponse.data, true);
|
|
213
|
-
}
|
|
214
|
-
}))
|
|
215
|
-
.catch((err) => {
|
|
216
|
-
console.log(err);
|
|
217
|
-
setState((prevState) => {
|
|
218
|
-
return Object.assign(Object.assign({}, prevState), { loadingType: "" });
|
|
219
|
-
});
|
|
220
|
-
showNotification(get(err, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
catch (error) {
|
|
224
|
-
console.error("Error uploading file:", error);
|
|
225
|
-
}
|
|
226
|
-
finally {
|
|
227
|
-
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loadingType: "" })));
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
179
|
useEffect(() => {
|
|
231
180
|
if (brandId) {
|
|
232
181
|
fetchAssets();
|
|
@@ -316,9 +265,7 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
316
265
|
if (setGlobalSearch)
|
|
317
266
|
setGlobalSearch("");
|
|
318
267
|
};
|
|
319
|
-
return (_jsx(RefetchFoldersProvider, { value: refetch, children: _jsxs("div", { className: "md-lib-h-[inherit]", children: [type !== DriveModes.FILE && (_jsx(_Fragment, { children: _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-px-4 md-lib-h-20 md-lib-justify-between md-lib-border-b md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-mb-4", children: [imagePicker ? (_jsx(ImagePickerBreadCrumbList, { folder: parentFolder, parentFolderId: parentFolderId, setParentFolderId: setParentFolderId, pickerFolderId: pickerFolderId, imagePickerModal: true })) : (_jsx(_Fragment, { children: _jsx(BreadCrumbList, { folder: parentFolder, parentFolderId: parentFolderId, setParentFolderId: setParentFolderId, pickerFolderId: pickerFolderId, globalSearch: globalSearch, setSelectedKeys: setSelectedKeys }) })), isAdmin && _jsx(AddDrive, { parentFolderId: parentFolderId }),
|
|
320
|
-
onSelectNewFile(file);
|
|
321
|
-
}, showUploadList: false, accept: "image/*", children: _jsx(CustomButton, { loading: loadingType === "NEW_FILE_UPLOAD", label: "Select File", icon: _jsx(BsUploadIcon, {}) }) }))] }) })), _jsxs("div", { className: `md-lib-px-4 md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-flex ${!includes([DriveModes.FOLDERS, DriveModes.FILE], type)
|
|
268
|
+
return (_jsx(RefetchFoldersProvider, { value: refetch, children: _jsxs("div", { className: "md-lib-h-[inherit]", children: [type !== DriveModes.FILE && (_jsx(_Fragment, { children: _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-px-4 md-lib-h-20 md-lib-justify-between md-lib-border-b md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-mb-4", children: [imagePicker ? (_jsx(ImagePickerBreadCrumbList, { folder: parentFolder, parentFolderId: parentFolderId, setParentFolderId: setParentFolderId, pickerFolderId: pickerFolderId, imagePickerModal: true })) : (_jsx(_Fragment, { children: _jsx(BreadCrumbList, { folder: parentFolder, parentFolderId: parentFolderId, setParentFolderId: setParentFolderId, pickerFolderId: pickerFolderId, globalSearch: globalSearch, setSelectedKeys: setSelectedKeys }) })), isAdmin && _jsx(AddDrive, { parentFolderId: parentFolderId })] }) })), _jsxs("div", { className: `md-lib-px-4 md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-flex ${!includes([DriveModes.FOLDERS, DriveModes.FILE], type)
|
|
322
269
|
? "md-lib-justify-between"
|
|
323
270
|
: "md-lib-justify-end md-lib-my-4"}`, children: [!includes([DriveModes.FOLDERS, DriveModes.FILE], type) && (_jsx("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-4 md-lib-mb-4", children: _jsx(TypeAndDateFilters, { selectedDateKey: selectedDateKey, selectedType: selectedType, customDateRange: customDateRange, onDateMenuClick: onDateMenuClick, onTypeMenuClick: onTypeMenuClick, onChangeDates: (dates) => {
|
|
324
271
|
if (dates) {
|