@bindu-dashing/dam-solution-v2 5.8.95 → 5.8.97

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.
@@ -392,6 +392,6 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
392
392
  ? "md-lib-cursor-not-allowed md-lib-text-disabledBtnColor dark:md-lib-text-darkBorderColor"
393
393
  : "md-lib-cursor-pointer", onClick: (e) => e.stopPropagation() }) }), displayUpdateName && (!!file || !!folder) && (_jsx(AddFolder, { file: file, open: displayUpdateName, handleCancel: toggleDisplayUpdateName, folder: folder, onCloseSelection: onCloseSelection, fileModal: fileModal })), _jsx(DeleteConfirmationModal, { showDeleteModal: showConfirmModal, toggleDeleteModal: toggleConfirmPopup, icon: actionType === "archive" ? (_jsx(IoArchiveOutlineIcon, {})) : (_jsx(DeleteOutlined, {})), okText: actionType === "archive" ? ARCHIVE_OK_TEXT : DELETE_OK_TEXT, description: isMultiSelection
394
394
  ? DELETE_CONFIRMATION_MESSAGE.replace(":action", actionType).replace(" :entity", "")
395
- : DELETE_CONFIRMATION_MESSAGE.replace(":action", actionType).replace(":entity", get(file, "name", "this file")), onOk: actionType === "archive" ? onArchiveFile : onDeleteFile, subHeading: actionType === "archive" ? "" : DELETE_MESSAGE_DESCRIPTION, loading: deleteFileMutation.isLoading || archiveFileMutation.isLoading }), showPreviewModal && (_jsx(FileDetails, { open: showPreviewModal, handleClose: toggleShowPreviewModal, file: file, files: getSelectedFiles(queryClient, folderId ? folderId : rootFolderId, generateFoldersQueryKey(type), fileIds), onCloseSelection: onCloseSelection })), showMoveFolder && (_jsx(MoveToAnotherFolder, { open: showMoveFolder, handleCancel: toggleShowMoveFolder, fileIds: [get(file, "_id")], entity: file, onCloseSelection: onCloseSelection })), showShareModal && (_jsx(InviteTeamModal, { open: showShareModal, onClose: toggleShareModal, onFetchInvitations: () => { }, shareModal: true, fileIds: file ? [get(file, "_id")] : fileIds, folderIds: folderIds, inviteType: DriveModes.FILE, file: file })), showFileAccess && (file || folder) && (_jsx(ManageFile, { open: showFileAccess, onClose: toggleFileAccess, file: file ? file : folder })), showLogsModal && (_jsx(FileDownloadHistory, { file: file ? file : folder, open: showLogsModal, onClose: toggleLogsModal }))] }));
395
+ : DELETE_CONFIRMATION_MESSAGE.replace(":action", actionType).replace(":entity", get(file, "name", "this file")), onOk: actionType === "archive" ? onArchiveFile : onDeleteFile, subHeading: actionType === "archive" ? "" : DELETE_MESSAGE_DESCRIPTION, loading: deleteFileMutation.isLoading || archiveFileMutation.isLoading }), showPreviewModal && (_jsx(FileDetails, { open: showPreviewModal, handleClose: toggleShowPreviewModal, file: file || undefined, files: getSelectedFiles(queryClient, folderId ? folderId : rootFolderId, generateFoldersQueryKey(type), file ? [get(file, "_id")] : fileIds), fileIds: file ? [get(file, "_id")] : fileIds, onCloseSelection: onCloseSelection })), showMoveFolder && (_jsx(MoveToAnotherFolder, { open: showMoveFolder, handleCancel: toggleShowMoveFolder, fileIds: [get(file, "_id")], entity: file, onCloseSelection: onCloseSelection })), showShareModal && (_jsx(InviteTeamModal, { open: showShareModal, onClose: toggleShareModal, onFetchInvitations: () => { }, shareModal: true, fileIds: file ? [get(file, "_id")] : fileIds, folderIds: folderIds, inviteType: DriveModes.FILE, file: file })), showFileAccess && (file || folder) && (_jsx(ManageFile, { open: showFileAccess, onClose: toggleFileAccess, file: file ? file : folder })), showLogsModal && (_jsx(FileDownloadHistory, { file: file ? file : folder, open: showLogsModal, onClose: toggleLogsModal }))] }));
396
396
  }
397
397
  export default FileMenuOptions;
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
2
  import { FileEntity } from "../../utilities/constants/interface";
3
- declare const FileDetails: ({ open, handleClose, file, files, onCloseSelection, }: {
3
+ declare const FileDetails: ({ open, handleClose, file, files, fileIds, onCloseSelection, }: {
4
4
  handleClose?: () => void;
5
5
  open: boolean;
6
6
  file?: FileEntity;
7
7
  files?: FileEntity[] | undefined;
8
+ fileIds?: string[];
8
9
  onCloseSelection?: () => void;
9
10
  }) => React.ReactPortal | null;
10
11
  export default FileDetails;
@@ -9,17 +9,41 @@ import Loader from "../../common/loader/loader";
9
9
  import { createApiClient } from "../../hocs/configureAxios";
10
10
  import { useDamConfig } from "../../hocs/DamConfigContext";
11
11
  import useAppParams from "../../utilities/useAppParams";
12
- const FileDetails = ({ open, handleClose, file, files, onCloseSelection, }) => {
13
- console.log("files", files, "file", file);
12
+ const FileDetails = ({ open, handleClose, file, files, fileIds, onCloseSelection, }) => {
13
+ // Get the initial file - prefer file prop, fallback to first item in files array
14
+ const initialFile = useMemo(() => {
15
+ if (file)
16
+ return file;
17
+ if (files && files.length > 0)
18
+ return nth(files, 0);
19
+ return undefined;
20
+ }, [file, files]);
21
+ // Get the initial file ID - from file, files array, or fileIds prop
22
+ const initialFileId = useMemo(() => {
23
+ if (file)
24
+ return get(file, "_id") || "";
25
+ if (files && files.length > 0)
26
+ return get(nth(files, 0), "_id") || "";
27
+ if (fileIds && fileIds.length > 0)
28
+ return fileIds[0];
29
+ return "";
30
+ }, [file, files, fileIds]);
31
+ console.log("## FileDetails - files:", files, "file:", file, "initialFile:", initialFile, "fileIds:", fileIds, "initialFileId:", initialFileId);
14
32
  const { id } = useAppParams();
15
33
  const damConfig = useDamConfig();
16
34
  const api = useMemo(() => createApiClient(damConfig), [damConfig]);
17
35
  const [state, setState] = useState({
18
36
  visible: false,
19
37
  currentIndex: 0,
20
- currentFileId: get(file, "_id"),
38
+ currentFileId: initialFileId,
21
39
  });
22
40
  const { visible, currentIndex, currentFileId } = state;
41
+ // Update currentFileId when initialFileId changes (e.g., when props load)
42
+ useEffect(() => {
43
+ if (initialFileId && !currentFileId) {
44
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { currentFileId: initialFileId })));
45
+ }
46
+ }, [initialFileId, currentFileId]);
23
47
  const { data: fileData, isFetching, refetch } = useFile(api, currentFileId);
24
48
  console.log("fileData", fileData, "isFetching", isFetching);
25
49
  if (typeof window === "undefined" || typeof document === "undefined") {
@@ -35,14 +59,24 @@ const FileDetails = ({ open, handleClose, file, files, onCloseSelection, }) => {
35
59
  prevFileId.current = currentFileId;
36
60
  }, [currentFileId]);
37
61
  const currentFile = useMemo(() => {
38
- console.log("currentFile", currentFile, "file", file, "fileData", fileData, "isFetching", isFetching, "id", id);
39
- if (id) {
62
+ console.log("## currentFile calc - file:", file, "initialFile:", initialFile, "fileData:", fileData, "isFetching:", isFetching, "id:", id, "currentIndex:", currentIndex);
63
+ // Priority: fileData (from API) > file prop > files array item > initialFile
64
+ if (fileData) {
65
+ return fileData;
66
+ }
67
+ else if (id) {
68
+ return file || initialFile;
69
+ }
70
+ else if (file) {
40
71
  return file;
41
72
  }
73
+ else if (files && files.length > 0) {
74
+ return nth(files, currentIndex);
75
+ }
42
76
  else {
43
- return file ? fileData : nth(files, currentIndex);
77
+ return initialFile;
44
78
  }
45
- }, [files, currentIndex, file, fileData, isFetching, id]);
79
+ }, [files, currentIndex, file, initialFile, fileData, isFetching, id]);
46
80
  const handlePrevious = () => {
47
81
  if (files && currentIndex > 0) {
48
82
  setState((prevState) => (Object.assign(Object.assign({}, prevState), { currentIndex: prevState.currentIndex - 1 })));
@@ -69,6 +103,7 @@ const FileDetails = ({ open, handleClose, file, files, onCloseSelection, }) => {
69
103
  }, [open]);
70
104
  if (!open && !visible)
71
105
  return null;
106
+ console.log("currentFile", currentFile);
72
107
  const modalContent = (_jsxs("div", { className: `md-lib-fixed md-lib-inset-0 md-lib-z-[1000] md-lib-w-screen md-lib-h-screen md-lib-bg-white dark:md-lib-bg-darkPrimary md-lib-text-black dark:md-lib-text-white md-lib-overflow-auto md-lib-transform md-lib-transition-all md-lib-duration-300 md-lib-ease-in-out ${open && visible
73
108
  ? "md-lib-opacity-100 md-lib-translate-y-0"
74
109
  : "md-lib-opacity-0 md-lib-translate-y-4"}`, onTransitionEnd: () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.95",
3
+ "version": "5.8.97",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",