@bindu-dashing/dam-solution-v2 5.8.150 → 5.8.153

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.
@@ -8,11 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- import { Button, Drawer, Form, Input, Select, Typography } from "antd";
11
+ import { Button, Checkbox, Drawer, Form, Input, Select, Typography } from "antd";
12
12
  import { useEffect, useMemo, useState } from "react";
13
13
  import { ACCESS_TYPES, DAM_LOCATION_TYPES } from "../hocs/appConstants";
14
14
  import { useDamConfig } from "../hocs/DamConfigContext";
15
- import { CREATE_SUB_BRAND } from "../utilities/constants/apiUrls";
15
+ import { CREATE_SUB_BRAND, FETCH_BRAND_USING_SUBDOMAIN } from "../utilities/constants/apiUrls";
16
16
  import axios from "axios";
17
17
  import { createApiClient } from "../hocs/configureAxios";
18
18
  import { CREATE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
@@ -21,8 +21,9 @@ import { showNotification } from "../common/notifications";
21
21
  import { get } from "lodash";
22
22
  const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, existingClientData, }) => {
23
23
  const damConfig = useDamConfig();
24
- const { appType } = damConfig;
24
+ const { appType, brand } = damConfig;
25
25
  const [loading, setLoading] = useState(false);
26
+ const [fetchingClientData, setFetchingClientData] = useState(false);
26
27
  const [damLocationType, setDamLocationType] = useState("external");
27
28
  const [filteredTeams, setFilteredTeams] = useState([]);
28
29
  const api = useMemo(() => createApiClient(damConfig), [damConfig]);
@@ -32,18 +33,63 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
32
33
  setDamLocationType(e);
33
34
  form.setFieldValue("dam_location_details", { type: e });
34
35
  };
36
+ // Fetch client data when editing
35
37
  useEffect(() => {
36
- if (clientSubdomain) {
37
- form.setFieldValue("subdomain", clientSubdomain);
38
- }
39
- if (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain) {
40
- form.setFieldValue("subdomain", existingClientData.subdomain);
41
- }
42
- }, [existingClientData]);
38
+ const fetchClientData = () => __awaiter(void 0, void 0, void 0, function* () {
39
+ if (isEditMode && (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain)) {
40
+ setFetchingClientData(true);
41
+ try {
42
+ const response = yield api.get(`${FETCH_BRAND_USING_SUBDOMAIN}?subdomain=${existingClientData.subdomain}`);
43
+ const clientData = get(response, "data.data", {});
44
+ // Populate form with existing client data
45
+ if (clientData) {
46
+ form.setFieldsValue({
47
+ name: get(clientData, "name", ""),
48
+ subdomain: get(clientData, "subdomain", existingClientData.subdomain),
49
+ accessTypes: get(clientData, "accessTypes", []),
50
+ adminTeams: get(clientData, "adminTeams", []),
51
+ showFilePreview: get(clientData, "showFilePreview", false),
52
+ damLocationDetails: {
53
+ type: get(clientData, "damLocationDetails.locationType") === "EXTERNAL" ? "external" : "internal",
54
+ bucket: get(clientData, "damLocationDetails.bucket", ""),
55
+ rootPath: get(clientData, "damLocationDetails.rootPath", ""),
56
+ accessKeyId: get(clientData, "damLocationDetails.accessKeyId", ""),
57
+ secretAccessKey: get(clientData, "damLocationDetails.secretAccessKey", ""),
58
+ url: get(clientData, "damLocationDetails.url", ""),
59
+ region: get(clientData, "damLocationDetails.region", ""),
60
+ },
61
+ });
62
+ // Set DAM location type
63
+ const locationType = get(clientData, "damLocationDetails.locationType");
64
+ if (locationType === "EXTERNAL") {
65
+ setDamLocationType("external");
66
+ }
67
+ else {
68
+ setDamLocationType("internal");
69
+ }
70
+ }
71
+ }
72
+ catch (error) {
73
+ console.error("Error fetching client data:", error);
74
+ // If fetch fails, still set subdomain
75
+ if (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain) {
76
+ form.setFieldValue("subdomain", existingClientData.subdomain);
77
+ }
78
+ }
79
+ finally {
80
+ setFetchingClientData(false);
81
+ }
82
+ }
83
+ else if (clientSubdomain) {
84
+ form.setFieldValue("subdomain", clientSubdomain);
85
+ }
86
+ });
87
+ fetchClientData();
88
+ }, [isEditMode, existingClientData, api, form]);
43
89
  const onFinish = (data) => __awaiter(void 0, void 0, void 0, function* () {
44
- var _a, _b, _c, _d, _e, _f, _g;
90
+ var _a, _b, _c, _d, _e, _f, _g, _h;
45
91
  try {
46
- const values = Object.assign(Object.assign({}, data), { accessKey: appType == "reactJs"
92
+ const values = Object.assign(Object.assign({}, data), { showFilePreview: (_a = data.showFilePreview) !== null && _a !== void 0 ? _a : false, accessKey: appType == "reactJs"
47
93
  ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY
48
94
  : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY, secretKey: appType == "reactJs"
49
95
  ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SECRET_KEY
@@ -55,13 +101,13 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
55
101
  password: password,
56
102
  }, damLocationDetails: damLocationType === "external"
57
103
  ? {
58
- bucket: (_a = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _a === void 0 ? void 0 : _a.bucket,
104
+ bucket: (_b = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _b === void 0 ? void 0 : _b.bucket,
59
105
  locationType: damLocationType === "external" ? "EXTERNAL" : "INTERNAL",
60
- rootPath: (_b = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _b === void 0 ? void 0 : _b.rootPath,
61
- accessKeyId: (_c = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _c === void 0 ? void 0 : _c.accessKeyId,
62
- secretAccessKey: (_d = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _d === void 0 ? void 0 : _d.secretAccessKey,
63
- url: (_e = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _e === void 0 ? void 0 : _e.url,
64
- region: (_f = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _f === void 0 ? void 0 : _f.region,
106
+ rootPath: (_c = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _c === void 0 ? void 0 : _c.rootPath,
107
+ accessKeyId: (_d = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _d === void 0 ? void 0 : _d.accessKeyId,
108
+ secretAccessKey: (_e = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _e === void 0 ? void 0 : _e.secretAccessKey,
109
+ url: (_f = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _f === void 0 ? void 0 : _f.url,
110
+ region: (_g = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _g === void 0 ? void 0 : _g.region,
65
111
  }
66
112
  : {
67
113
  locationType: damLocationType === "external" ? "EXTERNAL" : "INTERNAL",
@@ -69,7 +115,7 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
69
115
  setLoading(true);
70
116
  const response = yield api.post(CREATE_SUB_BRAND, values);
71
117
  setLoading(false);
72
- showNotification((_g = response === null || response === void 0 ? void 0 : response.message) !== null && _g !== void 0 ? _g : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
118
+ showNotification((_h = response === null || response === void 0 ? void 0 : response.message) !== null && _h !== void 0 ? _h : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
73
119
  toggleShow();
74
120
  if (onSuccess) {
75
121
  onSuccess(response === null || response === void 0 ? void 0 : response.data);
@@ -107,7 +153,7 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
107
153
  console.log("Error while fetching external teams", err);
108
154
  }
109
155
  });
110
- return (_jsx(Drawer, { open: true, title: isEditMode ? "Edit Client" : "Create Client", onClose: toggleShow, width: 500, maskClosable: false, children: _jsxs(Form, { layout: "vertical", form: form, onFinish: onFinish, children: [_jsx(Form.Item, { label: "Name", name: "name", rules: [
156
+ return (_jsx(Drawer, { open: true, title: isEditMode ? "Edit Client" : "Create Client", onClose: toggleShow, width: 500, maskClosable: false, children: fetchingClientData ? (_jsx("div", { style: { textAlign: "center", padding: "20px" }, children: _jsx(Typography.Text, { children: "Loading client data..." }) })) : (_jsxs(Form, { layout: "vertical", form: form, onFinish: onFinish, children: [_jsx(Form.Item, { label: "Name", name: "name", rules: [
111
157
  {
112
158
  required: true,
113
159
  message: "Name is required",
@@ -164,6 +210,6 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
164
210
  required: true,
165
211
  message: "Subdomain is required",
166
212
  },
167
- ], children: _jsx(Input, { placeholder: "Subdomain" }) }), _jsx(Form.Item, { children: _jsx(Button, { htmlType: "submit", type: "primary", block: true, loading: loading, children: "Submit" }) })] }) }));
213
+ ], children: _jsx(Input, { placeholder: "Subdomain" }) }), _jsx(Form.Item, { name: "showFilePreview", valuePropName: "checked", initialValue: false, children: _jsx(Checkbox, { children: "Show File Preview" }) }), _jsx(Form.Item, { children: _jsx(Button, { htmlType: "submit", type: "primary", block: true, loading: loading, children: "Submit" }) })] })) }));
168
214
  };
169
215
  export default CreateClientForm;
@@ -1,12 +1,17 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Layout, Button } from "antd";
3
3
  import { useState } from "react";
4
4
  import { LeftOutlined, RightOutlined } from "@ant-design/icons";
5
5
  import PreviewDetails from "./Previewdetails";
6
6
  import MapFile from "../files/MapFile";
7
+ import { useDamConfig } from "../../hocs/DamConfigContext";
8
+ import { get } from "lodash";
7
9
  const { Content } = Layout;
8
10
  const FileViewer = ({ file, onNext, onPrev, hasNext, hasPrev, handleClose, }) => {
9
- const [metadataOpen, setMetadataOpen] = useState(true);
10
- return (_jsx(Layout, { className: "md-lib-h-full", children: _jsxs(Content, { className: "md-lib-flex md-lib-h-full md-lib-w-full", children: [_jsx("div", { className: `md-lib-flex md-lib-items-center md-lib-justify-center md-lib-relative md-lib-bg-textColorActive dark:md-lib-bg-darkSecondaryColor md-lib-min-h-full ${metadataOpen ? "md-lib-flex-1" : "md-lib-flex-1 md-lib-w-full"}`, children: _jsx(PreviewDetails, { file: file, hasNext: hasNext, hasPrev: hasPrev, onNext: onNext, onPrev: onPrev }) }), _jsx(Button, { type: "text", className: "md-lib-shrink-0 md-lib-flex md-lib-items-center md-lib-justify-center md-lib-w-10 md-lib-h-10 md-lib-rounded-none md-lib-bg-black/50 hover:md-lib-bg-black/70 dark:md-lib-bg-white/20 dark:hover:md-lib-bg-white/30 md-lib-text-white md-lib-border-0 md-lib-self-start md-lib-mt-4", onClick: () => setMetadataOpen((prev) => !prev), "aria-label": metadataOpen ? "Hide metadata" : "Show metadata", children: metadataOpen ? (_jsx(RightOutlined, { className: "md-lib-text-lg" })) : (_jsx(LeftOutlined, { className: "md-lib-text-lg" })) }), metadataOpen && (_jsx("div", { className: "md-lib-w-[400px] md-lib-min-w-[320px] md-lib-shrink-0 md-lib-border-l md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-bg-backgroundColor dark:md-lib-bg-darkPrimary md-lib-overflow-y-auto", children: _jsx(MapFile, { fromUpload: false, filesList: file ? [file] : [], handleCancel: handleClose ? () => handleClose() : undefined }) }))] }) }));
11
+ const damConfig = useDamConfig();
12
+ const brand = damConfig === null || damConfig === void 0 ? void 0 : damConfig.brand;
13
+ const showFilePreview = get(brand, "showFilePreview", false);
14
+ const [metadataOpen, setMetadataOpen] = useState(showFilePreview);
15
+ return (_jsx(Layout, { className: "md-lib-h-full", children: _jsxs(Content, { className: "md-lib-flex md-lib-h-full md-lib-w-full", children: [_jsx("div", { className: `md-lib-flex md-lib-items-center md-lib-justify-center md-lib-relative md-lib-bg-textColorActive dark:md-lib-bg-darkSecondaryColor md-lib-min-h-full ${metadataOpen ? "md-lib-flex-1" : "md-lib-flex-1 md-lib-w-full"}`, children: _jsx(PreviewDetails, { file: file, hasNext: hasNext, hasPrev: hasPrev, onNext: onNext, onPrev: onPrev }) }), showFilePreview && (_jsxs(_Fragment, { children: [_jsx(Button, { type: "text", className: "md-lib-shrink-0 md-lib-flex md-lib-items-center md-lib-justify-center md-lib-w-10 md-lib-h-10 md-lib-rounded-none md-lib-bg-black/50 hover:md-lib-bg-black/70 dark:md-lib-bg-white/20 dark:hover:md-lib-bg-white/30 md-lib-text-white md-lib-border-0 md-lib-self-start md-lib-mt-4", onClick: () => setMetadataOpen((prev) => !prev), "aria-label": metadataOpen ? "Hide showFilePreviewEditor" : "Show showFilePreviewEditor", children: metadataOpen ? (_jsx(RightOutlined, { className: "md-lib-text-lg" })) : (_jsx(LeftOutlined, { className: "md-lib-text-lg" })) }), metadataOpen && (_jsx("div", { className: "md-lib-w-[400px] md-lib-min-w-[320px] md-lib-shrink-0 md-lib-border-l md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-bg-backgroundColor dark:md-lib-bg-darkPrimary md-lib-overflow-y-auto", children: _jsx(MapFile, { fromUpload: false, filesList: file ? [file] : [], handleCancel: handleClose ? () => handleClose() : undefined }) }))] }))] }) }));
11
16
  };
12
17
  export default FileViewer;
@@ -231,6 +231,6 @@ function MapFile({ open, handleCancel, filesList, fromUpload, parentFolderId, })
231
231
  const getMetadataForm = (_jsxs(Form, { layout: "vertical", form: form, scrollToFirstError: true, onFinish: fromUpload ? handleSubmit : handleUpdate, className: "md-lib-m-2", children: [_jsx(AssetSelectionFormItem, { handleAssetTemplateChange: handleAssetTemplateChange, assetOptions: assetOptions, assetsLoading: assetsLoading }), selectedAssetTemplate && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { name: "teamIds", label: "Teams", children: _jsx(Select, { options: teamOptions, placeholder: "Select teams", mode: "multiple", onChange: (val) => onChangeTeams(val), style: { width: "100%" }, showSearch: true, optionFilterProp: "key" }) }), _jsx(Form.Item, { name: "expiryDate", label: "Expiry Date", children: _jsx(DatePicker, { placeholder: "Expiry Date", style: { width: "100%" } }) }), _jsx(Metadata, { asset: selectedAssetTemplate, form: form, file: (filesList === null || filesList === void 0 ? void 0 : filesList[0]) || null })] })), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-justify-end md-lib-gap-3", children: [_jsx(Button, { onClick: handleCancelWithConfirmation, children: "Cancel" }), _jsx(Button, { disabled: !selectedAssetTemplate, type: "primary",
232
232
  // onClick={handleSubmit}
233
233
  loading: loading || updateFileMutation.isLoading, htmlType: "submit", children: "Save" })] })] }));
234
- return (_jsx(_Fragment, { children: fromUpload ? (_jsx(Drawer, { title: "Metadata", open: open, onClose: handleCancelWithConfirmation, maskClosable: false, children: getMetadataForm })) : (_jsxs("div", { className: "md-lib-p-2 md-lib-overflow-y-scroll md-lib-max-h-[calc(100vh-65px)]", children: [_jsx("p", { className: "md-lib-text-lg md-lib-font-semibold", children: "Metadata" }), getMetadataForm] })) }));
234
+ return (_jsx(_Fragment, { children: fromUpload ? (_jsx(Drawer, { title: "showFilePreviewEditor", open: open, onClose: handleCancelWithConfirmation, maskClosable: false, children: getMetadataForm })) : (_jsxs("div", { className: "md-lib-p-2 md-lib-overflow-y-scroll md-lib-max-h-[calc(100vh-65px)]", children: [_jsx("p", { className: "md-lib-text-lg md-lib-font-semibold", children: "showFilePreviewEditor" }), getMetadataForm] })) }));
235
235
  }
236
236
  export default MapFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.150",
3
+ "version": "5.8.153",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",