@bindu-dashing/dam-solution-v2 5.8.146 → 5.8.150
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.
- package/build/CreateClient/CreateClientBtn.d.ts +6 -1
- package/build/CreateClient/CreateClientBtn.js +3 -2
- package/build/CreateClient/CreateClientForm.d.ts +6 -1
- package/build/CreateClient/CreateClientForm.js +7 -3
- package/build/CreateClient/index.d.ts +5 -0
- package/build/CreateClient/index.js +1 -1
- package/build/MyDrive/BulkUploadModal.js +4 -4
- package/build/MyDrive/DriveContainer.js +7 -21
- package/build/hocs/DamConfigContext.js +0 -7
- package/build/hocs/helpers.d.ts +0 -6
- package/build/hocs/helpers.js +0 -10
- package/package.json +1 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
declare const CreateClient: ({ onSuccess, clientSubdomain, teamsApi, username, password, }: {
|
|
1
|
+
declare const CreateClient: ({ onSuccess, clientSubdomain, teamsApi, username, password, existingClientData, }: {
|
|
2
2
|
onSuccess: (data: any) => void;
|
|
3
3
|
clientSubdomain: string;
|
|
4
4
|
teamsApi: string;
|
|
5
5
|
username: string;
|
|
6
6
|
password: string;
|
|
7
|
+
existingClientData?: {
|
|
8
|
+
accessKey: string;
|
|
9
|
+
secretKey: string;
|
|
10
|
+
subdomain: string;
|
|
11
|
+
} | null;
|
|
7
12
|
}) => JSX.Element;
|
|
8
13
|
export default CreateClient;
|
|
@@ -2,11 +2,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Button } from "antd";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import CreateClientForm from "./CreateClientForm";
|
|
5
|
-
const CreateClient = ({ onSuccess, clientSubdomain, teamsApi, username, password, }) => {
|
|
5
|
+
const CreateClient = ({ onSuccess, clientSubdomain, teamsApi, username, password, existingClientData, }) => {
|
|
6
6
|
const [showForm, setShowForm] = useState(false);
|
|
7
|
+
const isEditMode = !!existingClientData;
|
|
7
8
|
const toggleShow = () => {
|
|
8
9
|
setShowForm(!showForm);
|
|
9
10
|
};
|
|
10
|
-
return (_jsxs(_Fragment, { children: [_jsx(Button, { type: "primary", onClick: toggleShow, children: "Create Client" }), showForm && (_jsx(CreateClientForm, { toggleShow: toggleShow, onSuccess: onSuccess, clientSubdomain: clientSubdomain, teamsApi: teamsApi, username: username, password: password }))] }));
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(Button, { type: "primary", onClick: toggleShow, children: isEditMode ? "Edit Client" : "Create Client" }), showForm && (_jsx(CreateClientForm, { toggleShow: toggleShow, onSuccess: onSuccess, clientSubdomain: clientSubdomain, teamsApi: teamsApi, username: username, password: password, existingClientData: existingClientData }))] }));
|
|
11
12
|
};
|
|
12
13
|
export default CreateClient;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
declare const CreateClientForm: ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, }: {
|
|
1
|
+
declare const CreateClientForm: ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, existingClientData, }: {
|
|
2
2
|
teamsApi: string;
|
|
3
3
|
username: string;
|
|
4
4
|
password: string;
|
|
5
5
|
toggleShow: () => void;
|
|
6
6
|
onSuccess: (data: any) => void;
|
|
7
7
|
clientSubdomain: string;
|
|
8
|
+
existingClientData?: {
|
|
9
|
+
accessKey: string;
|
|
10
|
+
secretKey: string;
|
|
11
|
+
subdomain: string;
|
|
12
|
+
} | null;
|
|
8
13
|
}) => JSX.Element;
|
|
9
14
|
export default CreateClientForm;
|
|
@@ -19,7 +19,7 @@ import { CREATE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/me
|
|
|
19
19
|
import { NotificationStatus } from "../utilities/constants/interface";
|
|
20
20
|
import { showNotification } from "../common/notifications";
|
|
21
21
|
import { get } from "lodash";
|
|
22
|
-
const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, }) => {
|
|
22
|
+
const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, existingClientData, }) => {
|
|
23
23
|
const damConfig = useDamConfig();
|
|
24
24
|
const { appType } = damConfig;
|
|
25
25
|
const [loading, setLoading] = useState(false);
|
|
@@ -27,6 +27,7 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
27
27
|
const [filteredTeams, setFilteredTeams] = useState([]);
|
|
28
28
|
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
29
29
|
const [form] = Form.useForm();
|
|
30
|
+
const isEditMode = !!existingClientData;
|
|
30
31
|
const onChangeDamLocationType = (e) => {
|
|
31
32
|
setDamLocationType(e);
|
|
32
33
|
form.setFieldValue("dam_location_details", { type: e });
|
|
@@ -35,7 +36,10 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
35
36
|
if (clientSubdomain) {
|
|
36
37
|
form.setFieldValue("subdomain", clientSubdomain);
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
if (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain) {
|
|
40
|
+
form.setFieldValue("subdomain", existingClientData.subdomain);
|
|
41
|
+
}
|
|
42
|
+
}, [existingClientData]);
|
|
39
43
|
const onFinish = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
44
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
41
45
|
try {
|
|
@@ -103,7 +107,7 @@ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess,
|
|
|
103
107
|
console.log("Error while fetching external teams", err);
|
|
104
108
|
}
|
|
105
109
|
});
|
|
106
|
-
return (_jsx(Drawer, { open: true, title: "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: [
|
|
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: [
|
|
107
111
|
{
|
|
108
112
|
required: true,
|
|
109
113
|
message: "Name is required",
|
|
@@ -10,5 +10,10 @@ declare function App(props: {
|
|
|
10
10
|
teamIds: string[] | number[];
|
|
11
11
|
styles: Record<string, any>;
|
|
12
12
|
appType: string;
|
|
13
|
+
existingClientData?: {
|
|
14
|
+
accessKey: string;
|
|
15
|
+
secretKey: string;
|
|
16
|
+
subdomain: string;
|
|
17
|
+
} | null;
|
|
13
18
|
}): JSX.Element;
|
|
14
19
|
export default App;
|
|
@@ -13,6 +13,6 @@ function App(props) {
|
|
|
13
13
|
styles: props === null || props === void 0 ? void 0 : props.styles,
|
|
14
14
|
appType: props === null || props === void 0 ? void 0 : props.appType,
|
|
15
15
|
};
|
|
16
|
-
return (_jsx(DamConfigProvider, { config: config, children: _jsxs(ThemeProvider, { styles: props === null || props === void 0 ? void 0 : props.styles, sessionTheme: ThemeModes.LIGHT, children: [_jsx(CreateClient, { teamsApi: props === null || props === void 0 ? void 0 : props.teamsApi, username: props === null || props === void 0 ? void 0 : props.username, password: props === null || props === void 0 ? void 0 : props.password, clientSubdomain: props === null || props === void 0 ? void 0 : props.clientSubdomain, onSuccess: props === null || props === void 0 ? void 0 : props.onSuccess }), _jsx(ToastProvider, {})] }) }));
|
|
16
|
+
return (_jsx(DamConfigProvider, { config: config, children: _jsxs(ThemeProvider, { styles: props === null || props === void 0 ? void 0 : props.styles, sessionTheme: ThemeModes.LIGHT, children: [_jsx(CreateClient, { teamsApi: props === null || props === void 0 ? void 0 : props.teamsApi, username: props === null || props === void 0 ? void 0 : props.username, password: props === null || props === void 0 ? void 0 : props.password, clientSubdomain: props === null || props === void 0 ? void 0 : props.clientSubdomain, onSuccess: props === null || props === void 0 ? void 0 : props.onSuccess, existingClientData: props === null || props === void 0 ? void 0 : props.existingClientData }), _jsx(ToastProvider, {})] }) }));
|
|
17
17
|
}
|
|
18
18
|
export default App;
|
|
@@ -8,9 +8,9 @@ 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 { Form, Modal, Button, Upload, Select, Input, Radio, Typography, Tooltip, } from "antd";
|
|
11
|
+
import { Form, Modal, Button, Upload, Select, Input, Radio, Typography, Tooltip, Checkbox, Popover, } from "antd";
|
|
12
12
|
import { useEffect, useMemo, useState } from "react";
|
|
13
|
-
import { UploadOutlined, InfoCircleOutlined } from "@ant-design/icons";
|
|
13
|
+
import { UploadOutlined, InfoCircleOutlined, QuestionCircleOutlined } from "@ant-design/icons";
|
|
14
14
|
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
15
15
|
import { createApiClient } from "../hocs/configureAxios";
|
|
16
16
|
import { BULK_UPLOAD_URL, FETCH_ASSETS_URL, FILE_UPLOAD_URL, GENERATE_THUMBNAILS_URL, SAMPLE_FILE_DOWNLOAD_URL, } from "../utilities/constants/apiUrls";
|
|
@@ -113,7 +113,7 @@ const BulkUploadModal = ({ toggleUpload, userEmail, folderId, thumbnailsOnly, })
|
|
|
113
113
|
else {
|
|
114
114
|
const formData = new FormData();
|
|
115
115
|
formData.append("assetId", values === null || values === void 0 ? void 0 : values.asset_type_id);
|
|
116
|
-
formData.append("rejectInvalidMetaFile", "true");
|
|
116
|
+
formData.append("rejectInvalidMetaFile", (values === null || values === void 0 ? void 0 : values.reject_invalid_meta_file) ? "true" : "false");
|
|
117
117
|
formData.append("zipFileUrl", values === null || values === void 0 ? void 0 : values.zip_file_url);
|
|
118
118
|
formData.append("file", metaFile);
|
|
119
119
|
formData.append("folderId", folderId);
|
|
@@ -206,7 +206,7 @@ const BulkUploadModal = ({ toggleUpload, userEmail, folderId, thumbnailsOnly, })
|
|
|
206
206
|
}, disabled: !assetTypeId, onRemove: () => {
|
|
207
207
|
setMetaFile(null);
|
|
208
208
|
setFileError("Meta File is required");
|
|
209
|
-
}, accept: ".csv,.xlsx,.xls", maxCount: 1, children: _jsx(Button, { icon: _jsx(UploadOutlined, {}), disabled: !assetTypeId, children: "Upload" }) }) }), fileError && (_jsx(Typography.Text, { style: { color: "red" }, children: fileError }))] })), _jsx(Form.Item, { label: "Upload your DAM Files (must be zipped)", name: "assets_source_type", children: _jsxs(Radio.Group, { onChange: (e) => setAssetsSourceType(e.target.value), value: assetsSourceType, disabled: thumbnailsOnly ? false : !assetTypeId, children: [_jsx(Radio, { value: "zip", children: "Zip file" }), _jsx(Radio, { value: "zipUrl", children: "Zip file url" })] }) }), assetsSourceType == "zip" ? (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Assets zip file", name: "assets_zip_file", rules: [
|
|
209
|
+
}, accept: ".csv,.xlsx,.xls", maxCount: 1, children: _jsx(Button, { icon: _jsx(UploadOutlined, {}), disabled: !assetTypeId, children: "Upload" }) }) }), fileError && (_jsx(Typography.Text, { style: { color: "red" }, children: fileError })), _jsx(Form.Item, { name: "reject_invalid_meta_file", valuePropName: "checked", children: _jsxs(Checkbox, { name: "reject_invalid_meta_file", children: ["Reject invalid meta file", _jsx(Popover, { content: _jsxs("span", { style: { color: "grey", padding: "5px" }, children: ["When this option is selected the uploaded metadata", _jsx("br", {}), " file will be rejected if it contains invalid values"] }), children: _jsx(QuestionCircleOutlined, { style: { marginLeft: "5px", color: "silver" } }) })] }) })] })), _jsx(Form.Item, { label: "Upload your DAM Files (must be zipped)", name: "assets_source_type", children: _jsxs(Radio.Group, { onChange: (e) => setAssetsSourceType(e.target.value), value: assetsSourceType, disabled: thumbnailsOnly ? false : !assetTypeId, children: [_jsx(Radio, { value: "zip", children: "Zip file" }), _jsx(Radio, { value: "zipUrl", children: "Zip file url" })] }) }), assetsSourceType == "zip" ? (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Assets zip file", name: "assets_zip_file", rules: [
|
|
210
210
|
{
|
|
211
211
|
required: true,
|
|
212
212
|
message: "Asset zip file is required",
|
|
@@ -13,7 +13,7 @@ import _, { filter, first, flatMap, get, includes, isEmpty, merge, } from "lodas
|
|
|
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, Upload } from "antd";
|
|
17
17
|
import { addQueryParams, getDateRangeFromKey } from "../hocs/helpers";
|
|
18
18
|
import { useFolders } from "../react-query/services/folder-services";
|
|
19
19
|
import { DEFAULT_PAGE } from "../hocs/appConstants";
|
|
@@ -33,10 +33,8 @@ import ImagePickerBreadCrumbList from "./ImagePickerBreadCrumbList";
|
|
|
33
33
|
import { FETCH_ASSETS_URL, FETCH_IMAGE_PCIKER_THUMBNAIL_URL, UPLOAD_IMAGE_PICKER_LOCAL_FILE_URL, } from "../utilities/constants/apiUrls";
|
|
34
34
|
import { showNotification } from "../common/notifications";
|
|
35
35
|
import useAppParams from "../utilities/useAppParams";
|
|
36
|
-
import { IoIosSearch } from "react-icons/io";
|
|
37
36
|
import { RefetchFoldersProvider } from "../utilities/FoldersContext";
|
|
38
37
|
const BsUploadIcon = BsUpload;
|
|
39
|
-
const IoIosSearchIcon = IoIosSearch;
|
|
40
38
|
function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pickerFolderId, selectedPickerFile, imagePicker, globalSearch, setGlobalSearch, setSelectedKeys, }) {
|
|
41
39
|
const damConfig = useDamConfig();
|
|
42
40
|
const { rootFolderId, brand, isAdmin } = damConfig;
|
|
@@ -59,7 +57,6 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
59
57
|
folderSearch: "",
|
|
60
58
|
});
|
|
61
59
|
const { selectedType, selectedDateKey, showGrid, loadingType, selectedItems, assets, sortBy, sortOrder, searchKey, searchValue, metadataKey, metadataValue, folderSearch, } = state;
|
|
62
|
-
const nameSearchRef = useRef();
|
|
63
60
|
const getSearchParams = () => {
|
|
64
61
|
const params = {};
|
|
65
62
|
if (searchKey === "name") {
|
|
@@ -234,23 +231,12 @@ function DriveContainer({ parentFolderId, setSelectedFile, setParentFolderId, pi
|
|
|
234
231
|
onSelectNewFile(file);
|
|
235
232
|
}, 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)
|
|
236
233
|
? "md-lib-justify-between"
|
|
237
|
-
: "md-lib-justify-end md-lib-my-4"}`, children: [
|
|
238
|
-
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
setState((prevState) => {
|
|
244
|
-
return Object.assign(Object.assign({}, prevState), { folderSearch: value });
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
} }), !includes([DriveModes.FOLDERS, DriveModes.FILE], type) && (_jsx(TypeAndDateFilters, { selectedDateKey: selectedDateKey, selectedType: selectedType, onDateMenuClick: onDateMenuClick, onTypeMenuClick: onTypeMenuClick, onChangeDates: (dates) => {
|
|
249
|
-
if (dates) {
|
|
250
|
-
const [start, end] = dates;
|
|
251
|
-
setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
|
|
252
|
-
}
|
|
253
|
-
}, 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" }), 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
|
|
234
|
+
: "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, onDateMenuClick: onDateMenuClick, onTypeMenuClick: onTypeMenuClick, onChangeDates: (dates) => {
|
|
235
|
+
if (dates) {
|
|
236
|
+
const [start, end] = dates;
|
|
237
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { customDateRange: dates, selectedDateKey: "custom" })));
|
|
238
|
+
}
|
|
239
|
+
}, 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" }), 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
|
|
254
240
|
? get(error, "message", SOMETHING_WENT_WRONG)
|
|
255
241
|
: includes(Object.values(DriveModes), type)
|
|
256
242
|
? "No data found"
|
|
@@ -96,17 +96,13 @@ export const DamConfigProvider = ({ children, config }) => {
|
|
|
96
96
|
const fullUrl = teamsApiBaseUrl + teamsEndpoint;
|
|
97
97
|
console.log("Fetching teams from:", fullUrl);
|
|
98
98
|
console.log("TeamID from token:", teamID);
|
|
99
|
-
// Call the new API endpoint using Teams API base URL
|
|
100
99
|
const response = yield axios.get(fullUrl, {
|
|
101
100
|
headers: {
|
|
102
101
|
Authorization: authorizationHeader,
|
|
103
102
|
},
|
|
104
103
|
});
|
|
105
104
|
console.log("Teams API response:", response === null || response === void 0 ? void 0 : response.data);
|
|
106
|
-
// Set teams from the API response
|
|
107
|
-
// Assuming the response structure is { data: [...] } or similar
|
|
108
105
|
const teamsData = ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) || (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
109
|
-
console.log("Parsed teams data:", teamsData);
|
|
110
106
|
setTeams(Array.isArray(teamsData) ? teamsData : []);
|
|
111
107
|
}
|
|
112
108
|
catch (err) {
|
|
@@ -117,7 +113,6 @@ export const DamConfigProvider = ({ children, config }) => {
|
|
|
117
113
|
status: (_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.status,
|
|
118
114
|
url: (_d = err === null || err === void 0 ? void 0 : err.config) === null || _d === void 0 ? void 0 : _d.url,
|
|
119
115
|
});
|
|
120
|
-
// Set empty array on error to prevent stale data
|
|
121
116
|
setTeams([]);
|
|
122
117
|
}
|
|
123
118
|
});
|
|
@@ -131,12 +126,10 @@ export const DamConfigProvider = ({ children, config }) => {
|
|
|
131
126
|
}
|
|
132
127
|
}
|
|
133
128
|
}, [damAccessKey, secretKey, subdomain]);
|
|
134
|
-
// Fetch teams after token is available
|
|
135
129
|
useEffect(() => {
|
|
136
130
|
if (accessToken) {
|
|
137
131
|
getTeams(accessToken);
|
|
138
132
|
}
|
|
139
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
140
133
|
}, [accessToken]);
|
|
141
134
|
return (_jsx(DamConfigContext.Provider, { value: {
|
|
142
135
|
damAccessKey,
|
package/build/hocs/helpers.d.ts
CHANGED
|
@@ -9,12 +9,6 @@ export declare const getDateRangeFromKey: (key: string) => {
|
|
|
9
9
|
endDate?: string;
|
|
10
10
|
};
|
|
11
11
|
export declare const getBaseUrl: (appType: string) => string;
|
|
12
|
-
/**
|
|
13
|
-
* Encodes a string to Base64 in a cross-platform way
|
|
14
|
-
* Works in both browser and Node.js environments
|
|
15
|
-
* @param str - The string to encode
|
|
16
|
-
* @returns Base64 encoded string
|
|
17
|
-
*/
|
|
18
12
|
export declare const encodeBase64: (str: string) => string;
|
|
19
13
|
export declare const getRelativeTime: (timestamp: string) => string;
|
|
20
14
|
export declare const getReadableFileType: (file: FileEntity) => string;
|
package/build/hocs/helpers.js
CHANGED
|
@@ -102,26 +102,16 @@ export const getBaseUrl = (appType) => {
|
|
|
102
102
|
return process.env.REACT_APP_MIXDRIVE_API_URL || "";
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
|
-
/**
|
|
106
|
-
* Encodes a string to Base64 in a cross-platform way
|
|
107
|
-
* Works in both browser and Node.js environments
|
|
108
|
-
* @param str - The string to encode
|
|
109
|
-
* @returns Base64 encoded string
|
|
110
|
-
*/
|
|
111
105
|
export const encodeBase64 = (str) => {
|
|
112
|
-
// Use Buffer if available (Node.js environment)
|
|
113
106
|
if (typeof Buffer !== "undefined") {
|
|
114
107
|
return Buffer.from(str, "utf-8").toString("base64");
|
|
115
108
|
}
|
|
116
|
-
// Fallback to btoa for browser environments
|
|
117
|
-
// Note: btoa only works with Latin-1 characters, so we encode URI component first
|
|
118
109
|
try {
|
|
119
110
|
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => {
|
|
120
111
|
return String.fromCharCode(parseInt(p1, 16));
|
|
121
112
|
}));
|
|
122
113
|
}
|
|
123
114
|
catch (e) {
|
|
124
|
-
// If btoa fails, throw a more descriptive error
|
|
125
115
|
throw new Error("Failed to encode string to Base64");
|
|
126
116
|
}
|
|
127
117
|
};
|