@bindu-dashing/dam-solution-v2 5.8.6
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/README.md +53 -0
- package/build/AssetType/AddFieldProperties.d.ts +9 -0
- package/build/AssetType/AddFieldProperties.js +197 -0
- package/build/AssetType/AssetTemplatesTable.d.ts +10 -0
- package/build/AssetType/AssetTemplatesTable.js +153 -0
- package/build/AssetType/CreateAssetTemplate.d.ts +3 -0
- package/build/AssetType/CreateAssetTemplate.js +68 -0
- package/build/AssetType/CreateOrEditAssetTemplate.d.ts +1 -0
- package/build/AssetType/CreateOrEditAssetTemplate.js +77 -0
- package/build/AssetType/DraggedField.d.ts +14 -0
- package/build/AssetType/DraggedField.js +40 -0
- package/build/AssetType/EditAssetTemplate.d.ts +5 -0
- package/build/AssetType/EditAssetTemplate.js +179 -0
- package/build/AssetType/FieldsSection.d.ts +14 -0
- package/build/AssetType/FieldsSection.js +239 -0
- package/build/AssetType/assetTemplatesContainer.d.ts +2 -0
- package/build/AssetType/assetTemplatesContainer.js +71 -0
- package/build/AssetType/fieldProperties/DateField.d.ts +5 -0
- package/build/AssetType/fieldProperties/DateField.js +23 -0
- package/build/AssetType/fieldProperties/NumberField.d.ts +5 -0
- package/build/AssetType/fieldProperties/NumberField.js +91 -0
- package/build/AssetType/fieldProperties/OptionsField.d.ts +6 -0
- package/build/AssetType/fieldProperties/OptionsField.js +55 -0
- package/build/AssetType/fieldProperties/TextField.d.ts +5 -0
- package/build/AssetType/fieldProperties/TextField.js +92 -0
- package/build/AssetType/index.d.ts +11 -0
- package/build/AssetType/index.js +24 -0
- package/build/AssetType/routes.d.ts +3 -0
- package/build/AssetType/routes.js +17 -0
- package/build/BookView/ProductDescription.d.ts +4 -0
- package/build/BookView/ProductDescription.js +20 -0
- package/build/BookView/bookDetail.d.ts +4 -0
- package/build/BookView/bookDetail.js +106 -0
- package/build/BookView/bookInfo.d.ts +4 -0
- package/build/BookView/bookInfo.js +17 -0
- package/build/BookView/description.d.ts +4 -0
- package/build/BookView/description.js +5 -0
- package/build/BookView/index.d.ts +10 -0
- package/build/BookView/index.js +23 -0
- package/build/CreateClient/CreateClientBtn.d.ts +8 -0
- package/build/CreateClient/CreateClientBtn.js +12 -0
- package/build/CreateClient/CreateClientForm.d.ts +9 -0
- package/build/CreateClient/CreateClientForm.js +165 -0
- package/build/CreateClient/index.d.ts +14 -0
- package/build/CreateClient/index.js +18 -0
- package/build/ImagePicker/MetaFieldOptions.d.ts +14 -0
- package/build/ImagePicker/MetaFieldOptions.js +75 -0
- package/build/ImagePicker/TestImagePickerModal.d.ts +8 -0
- package/build/ImagePicker/TestImagePickerModal.js +61 -0
- package/build/ImagePicker/TestImgFromMetaData.d.ts +7 -0
- package/build/ImagePicker/TestImgFromMetaData.js +82 -0
- package/build/ImagePicker/imagePickerComponent.d.ts +6 -0
- package/build/ImagePicker/imagePickerComponent.js +63 -0
- package/build/ImagePicker/index.d.ts +13 -0
- package/build/ImagePicker/index.js +24 -0
- package/build/ImagePicker/routes.d.ts +6 -0
- package/build/ImagePicker/routes.js +17 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.d.ts +8 -0
- package/build/ImagePickerFilters/ImagePickerFiltersComponent.js +223 -0
- package/build/ImagePickerFilters/index.d.ts +12 -0
- package/build/ImagePickerFilters/index.js +19 -0
- package/build/MyDrive/ActionBar.d.ts +6 -0
- package/build/MyDrive/ActionBar.js +165 -0
- package/build/MyDrive/AddDrive.d.ts +3 -0
- package/build/MyDrive/AddDrive.js +169 -0
- package/build/MyDrive/AddFolder.d.ts +10 -0
- package/build/MyDrive/AddFolder.js +150 -0
- package/build/MyDrive/BreadCrumbList.d.ts +9 -0
- package/build/MyDrive/BreadCrumbList.js +86 -0
- package/build/MyDrive/BulkUploadModal.d.ts +2 -0
- package/build/MyDrive/BulkUploadModal.js +279 -0
- package/build/MyDrive/DriveContainer.d.ts +13 -0
- package/build/MyDrive/DriveContainer.js +276 -0
- package/build/MyDrive/FileDownloadHistory.d.ts +7 -0
- package/build/MyDrive/FileDownloadHistory.js +94 -0
- package/build/MyDrive/FileMenuOptions.d.ts +11 -0
- package/build/MyDrive/FileMenuOptions.js +397 -0
- package/build/MyDrive/FilesGridView.d.ts +9 -0
- package/build/MyDrive/FilesGridView.js +25 -0
- package/build/MyDrive/FolderGridView.d.ts +19 -0
- package/build/MyDrive/FolderGridView.js +91 -0
- package/build/MyDrive/FolderListView.d.ts +25 -0
- package/build/MyDrive/FolderListView.js +188 -0
- package/build/MyDrive/FolderMenuOptions.d.ts +5 -0
- package/build/MyDrive/FolderMenuOptions.js +350 -0
- package/build/MyDrive/FolderTree.d.ts +8 -0
- package/build/MyDrive/FolderTree.js +342 -0
- package/build/MyDrive/ImageEditor/EditImage.d.ts +6 -0
- package/build/MyDrive/ImageEditor/EditImage.js +97 -0
- package/build/MyDrive/ImageEditor/EditImageModal.d.ts +8 -0
- package/build/MyDrive/ImageEditor/EditImageModal.js +30 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.d.ts +10 -0
- package/build/MyDrive/ImageEditor/TuiImageEditor.js +99 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.d.ts +8 -0
- package/build/MyDrive/ImagePickerBreadCrumbList.js +35 -0
- package/build/MyDrive/ImagePickerDrive.d.ts +1 -0
- package/build/MyDrive/ImagePickerDrive.js +41 -0
- package/build/MyDrive/MyDriveMainContainer.d.ts +1 -0
- package/build/MyDrive/MyDriveMainContainer.js +32 -0
- package/build/MyDrive/SearchFilter.d.ts +8 -0
- package/build/MyDrive/SearchFilter.js +73 -0
- package/build/MyDrive/ShareBtn.d.ts +5 -0
- package/build/MyDrive/ShareBtn.js +19 -0
- package/build/MyDrive/ToggleView.d.ts +4 -0
- package/build/MyDrive/ToggleView.js +12 -0
- package/build/MyDrive/UploadStatusModal.d.ts +12 -0
- package/build/MyDrive/UploadStatusModal.js +40 -0
- package/build/MyDrive/fileDetails/CommentEntity.d.ts +8 -0
- package/build/MyDrive/fileDetails/CommentEntity.js +102 -0
- package/build/MyDrive/fileDetails/Comments.d.ts +6 -0
- package/build/MyDrive/fileDetails/Comments.js +65 -0
- package/build/MyDrive/fileDetails/Compliance.d.ts +2 -0
- package/build/MyDrive/fileDetails/Compliance.js +18 -0
- package/build/MyDrive/fileDetails/CreateComment.d.ts +7 -0
- package/build/MyDrive/fileDetails/CreateComment.js +48 -0
- package/build/MyDrive/fileDetails/Editor.d.ts +6 -0
- package/build/MyDrive/fileDetails/Editor.js +55 -0
- package/build/MyDrive/fileDetails/EmojiPicker.d.ts +5 -0
- package/build/MyDrive/fileDetails/EmojiPicker.js +6 -0
- package/build/MyDrive/fileDetails/FileDetails.d.ts +10 -0
- package/build/MyDrive/fileDetails/FileDetails.js +78 -0
- package/build/MyDrive/fileDetails/FileHeader.d.ts +7 -0
- package/build/MyDrive/fileDetails/FileHeader.js +25 -0
- package/build/MyDrive/fileDetails/FileViewer.d.ts +10 -0
- package/build/MyDrive/fileDetails/FileViewer.js +31 -0
- package/build/MyDrive/fileDetails/ImageOptions.d.ts +2 -0
- package/build/MyDrive/fileDetails/ImageOptions.js +44 -0
- package/build/MyDrive/fileDetails/ImageViewer.d.ts +5 -0
- package/build/MyDrive/fileDetails/ImageViewer.js +16 -0
- package/build/MyDrive/fileDetails/ManageFile.d.ts +7 -0
- package/build/MyDrive/fileDetails/ManageFile.js +34 -0
- package/build/MyDrive/fileDetails/MetaForm.d.ts +15 -0
- package/build/MyDrive/fileDetails/MetaForm.js +195 -0
- package/build/MyDrive/fileDetails/Metadata.d.ts +8 -0
- package/build/MyDrive/fileDetails/Metadata.js +52 -0
- package/build/MyDrive/fileDetails/PdfOptions.d.ts +9 -0
- package/build/MyDrive/fileDetails/PdfOptions.js +35 -0
- package/build/MyDrive/fileDetails/PdfViewer.d.ts +8 -0
- package/build/MyDrive/fileDetails/PdfViewer.js +18 -0
- package/build/MyDrive/fileDetails/Previewdetails.d.ts +9 -0
- package/build/MyDrive/fileDetails/Previewdetails.js +53 -0
- package/build/MyDrive/fileDetails/VideoPlayer.d.ts +4 -0
- package/build/MyDrive/fileDetails/VideoPlayer.js +21 -0
- package/build/MyDrive/files/AssetSelectionFormItem.d.ts +7 -0
- package/build/MyDrive/files/AssetSelectionFormItem.js +14 -0
- package/build/MyDrive/files/FolderTabs.d.ts +6 -0
- package/build/MyDrive/files/FolderTabs.js +83 -0
- package/build/MyDrive/files/MapFile.d.ts +8 -0
- package/build/MyDrive/files/MapFile.js +217 -0
- package/build/MyDrive/files/MoveToAnotherFolder.d.ts +9 -0
- package/build/MyDrive/files/MoveToAnotherFolder.js +53 -0
- package/build/MyDrive/filesListView.d.ts +2 -0
- package/build/MyDrive/filesListView.js +57 -0
- package/build/MyDrive/index.d.ts +10 -0
- package/build/MyDrive/index.js +35 -0
- package/build/MyDrive/routes.d.ts +7 -0
- package/build/MyDrive/routes.js +17 -0
- package/build/PenView/PenDetails.d.ts +4 -0
- package/build/PenView/PenDetails.js +114 -0
- package/build/PenView/ProductDescription.d.ts +5 -0
- package/build/PenView/ProductDescription.js +51 -0
- package/build/PenView/index.d.ts +10 -0
- package/build/PenView/index.js +23 -0
- package/build/RefreshKey/RefreshKeyBtn.d.ts +1 -0
- package/build/RefreshKey/RefreshKeyBtn.js +42 -0
- package/build/RefreshKey/index.d.ts +9 -0
- package/build/RefreshKey/index.js +23 -0
- package/build/ShoesView/ProductDescription.d.ts +4 -0
- package/build/ShoesView/ProductDescription.js +25 -0
- package/build/ShoesView/ShoeDetails.d.ts +4 -0
- package/build/ShoesView/ShoeDetails.js +96 -0
- package/build/ShoesView/index.d.ts +10 -0
- package/build/ShoesView/index.js +23 -0
- package/build/common/Button.d.ts +2 -0
- package/build/common/Button.js +18 -0
- package/build/common/CustomElements.d.ts +98 -0
- package/build/common/CustomElements.js +77 -0
- package/build/common/LoadMoreItems.d.ts +7 -0
- package/build/common/LoadMoreItems.js +33 -0
- package/build/common/RenderFormItem.d.ts +42 -0
- package/build/common/RenderFormItem.js +98 -0
- package/build/common/RenderThumnail.d.ts +7 -0
- package/build/common/RenderThumnail.js +6 -0
- package/build/common/deleteModal.d.ts +1 -0
- package/build/common/deleteModal.js +12 -0
- package/build/common/folders/TypeAndDateFilters.d.ts +10 -0
- package/build/common/folders/TypeAndDateFilters.js +59 -0
- package/build/common/folders/getFolderOrFileIcon.d.ts +2 -0
- package/build/common/folders/getFolderOrFileIcon.js +41 -0
- package/build/common/loader/CustomLoader.d.ts +7 -0
- package/build/common/loader/CustomLoader.js +8 -0
- package/build/common/loader/loader.d.ts +1 -0
- package/build/common/loader/loader.js +6 -0
- package/build/common/notifications.d.ts +2 -0
- package/build/common/notifications.js +30 -0
- package/build/common/steps.d.ts +4 -0
- package/build/common/steps.js +7 -0
- package/build/hocs/AppProvider.d.ts +3 -0
- package/build/hocs/AppProvider.js +11 -0
- package/build/hocs/DamConfigContext.d.ts +2 -0
- package/build/hocs/DamConfigContext.js +108 -0
- package/build/hocs/ThemeContext.d.ts +15 -0
- package/build/hocs/ThemeContext.js +131 -0
- package/build/hocs/ToastProvider.d.ts +2 -0
- package/build/hocs/ToastProvider.js +6 -0
- package/build/hocs/appConstants.d.ts +124 -0
- package/build/hocs/appConstants.js +211 -0
- package/build/hocs/configureAxios.d.ts +2 -0
- package/build/hocs/configureAxios.js +65 -0
- package/build/hocs/helpers.d.ts +15 -0
- package/build/hocs/helpers.js +177 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +11 -0
- package/build/react-query/hooks/brand-hooks.d.ts +3 -0
- package/build/react-query/hooks/brand-hooks.js +10 -0
- package/build/react-query/hooks/folder-hooks.d.ts +7 -0
- package/build/react-query/hooks/folder-hooks.js +119 -0
- package/build/react-query/services/brand-services.d.ts +3 -0
- package/build/react-query/services/brand-services.js +30 -0
- package/build/react-query/services/file-services.d.ts +43 -0
- package/build/react-query/services/file-services.js +69 -0
- package/build/react-query/services/folder-services.d.ts +44 -0
- package/build/react-query/services/folder-services.js +87 -0
- package/build/react-query/services/image-picker-services.d.ts +5 -0
- package/build/react-query/services/image-picker-services.js +48 -0
- package/build/settings/InviteTeamModal.d.ts +12 -0
- package/build/settings/InviteTeamModal.js +174 -0
- package/build/settings/UpdateInvitationAccessType.d.ts +9 -0
- package/build/settings/UpdateInvitationAccessType.js +96 -0
- package/build/settings/getUserAvatar.d.ts +7 -0
- package/build/settings/getUserAvatar.js +11 -0
- package/build/style.css +1 -0
- package/build/types/assetType.d.ts +8 -0
- package/build/types/assetType.js +1 -0
- package/build/ui/pageTitle.d.ts +3 -0
- package/build/ui/pageTitle.js +4 -0
- package/build/utilities/FoldersContext.d.ts +14 -0
- package/build/utilities/FoldersContext.js +10 -0
- package/build/utilities/NavigatorProvider.d.ts +2 -0
- package/build/utilities/NavigatorProvider.js +10 -0
- package/build/utilities/constants/apiUrls.d.ts +95 -0
- package/build/utilities/constants/apiUrls.js +115 -0
- package/build/utilities/constants/imageUrls.d.ts +6 -0
- package/build/utilities/constants/imageUrls.js +6 -0
- package/build/utilities/constants/interface.d.ts +371 -0
- package/build/utilities/constants/interface.js +142 -0
- package/build/utilities/constants/messages.d.ts +54 -0
- package/build/utilities/constants/messages.js +54 -0
- package/build/utilities/constants/queryKeys.d.ts +16 -0
- package/build/utilities/constants/queryKeys.js +33 -0
- package/build/utilities/constants/routes.d.ts +22 -0
- package/build/utilities/constants/routes.js +22 -0
- package/build/utilities/helpers/validators.d.ts +12 -0
- package/build/utilities/helpers/validators.js +89 -0
- package/build/utilities/useAppNavigate.d.ts +2 -0
- package/build/utilities/useAppNavigate.js +19 -0
- package/build/utilities/useAppParams.d.ts +6 -0
- package/build/utilities/useAppParams.js +27 -0
- package/package.json +93 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
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";
|
|
12
|
+
import { useEffect, useMemo, useState } from "react";
|
|
13
|
+
import { ACCESS_TYPES, DAM_LOCATION_TYPES } from "../hocs/appConstants";
|
|
14
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
15
|
+
import { CREATE_SUB_BRAND } from "../utilities/constants/apiUrls";
|
|
16
|
+
import axios from "axios";
|
|
17
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
18
|
+
import { CREATE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
|
|
19
|
+
import { NotificationStatus } from "../utilities/constants/interface";
|
|
20
|
+
import { showNotification } from "../common/notifications";
|
|
21
|
+
import { get } from "lodash";
|
|
22
|
+
const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, }) => {
|
|
23
|
+
const damConfig = useDamConfig();
|
|
24
|
+
const { appType } = damConfig;
|
|
25
|
+
const [loading, setLoading] = useState(false);
|
|
26
|
+
const [damLocationType, setDamLocationType] = useState("external");
|
|
27
|
+
const [filteredTeams, setFilteredTeams] = useState([]);
|
|
28
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
29
|
+
const [form] = Form.useForm();
|
|
30
|
+
const onChangeDamLocationType = (e) => {
|
|
31
|
+
setDamLocationType(e);
|
|
32
|
+
form.setFieldValue("dam_location_details", { type: e });
|
|
33
|
+
};
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (clientSubdomain) {
|
|
36
|
+
form.setFieldValue("subdomain", clientSubdomain);
|
|
37
|
+
}
|
|
38
|
+
}, []);
|
|
39
|
+
const onFinish = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
41
|
+
try {
|
|
42
|
+
const values = Object.assign(Object.assign({}, data), { accessKey: appType == "reactJs"
|
|
43
|
+
? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY
|
|
44
|
+
: process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY, secretKey: appType == "reactJs"
|
|
45
|
+
? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SECRET_KEY
|
|
46
|
+
: process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SECRET_KEY, parentSubdomain: appType == "reactJs"
|
|
47
|
+
? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN
|
|
48
|
+
: process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN, teamsApiDetails: {
|
|
49
|
+
teamsApi: teamsApi,
|
|
50
|
+
username: username,
|
|
51
|
+
password: password,
|
|
52
|
+
}, damLocationDetails: damLocationType === "external"
|
|
53
|
+
? {
|
|
54
|
+
bucket: (_a = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _a === void 0 ? void 0 : _a.bucket,
|
|
55
|
+
locationType: damLocationType === "external" ? "EXTERNAL" : "INTERNAL",
|
|
56
|
+
rootPath: (_b = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _b === void 0 ? void 0 : _b.rootPath,
|
|
57
|
+
accessKeyId: (_c = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _c === void 0 ? void 0 : _c.accessKeyId,
|
|
58
|
+
secretAccessKey: (_d = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _d === void 0 ? void 0 : _d.secretAccessKey,
|
|
59
|
+
url: (_e = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _e === void 0 ? void 0 : _e.url,
|
|
60
|
+
region: (_f = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _f === void 0 ? void 0 : _f.region,
|
|
61
|
+
}
|
|
62
|
+
: {
|
|
63
|
+
locationType: damLocationType === "external" ? "EXTERNAL" : "INTERNAL",
|
|
64
|
+
} });
|
|
65
|
+
setLoading(true);
|
|
66
|
+
const response = yield api.post(CREATE_SUB_BRAND, values);
|
|
67
|
+
setLoading(false);
|
|
68
|
+
showNotification((_g = response === null || response === void 0 ? void 0 : response.message) !== null && _g !== void 0 ? _g : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
|
|
69
|
+
toggleShow();
|
|
70
|
+
if (onSuccess) {
|
|
71
|
+
onSuccess(response === null || response === void 0 ? void 0 : response.data);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
// console.error("Error creating client:", error);
|
|
76
|
+
setLoading(false);
|
|
77
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (teamsApi && username && password) {
|
|
82
|
+
fetchTeams();
|
|
83
|
+
}
|
|
84
|
+
}, [teamsApi, username, password]);
|
|
85
|
+
const fetchTeams = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
try {
|
|
88
|
+
const response = yield axios.get(teamsApi, {
|
|
89
|
+
headers: {
|
|
90
|
+
Authorization: "Basic " + btoa(username + ":" + password),
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
const options = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.map((team) => {
|
|
94
|
+
return {
|
|
95
|
+
label: (_jsxs(Typography.Text, { style: { display: "flex" }, children: [team === null || team === void 0 ? void 0 : team.id, " ", team === null || team === void 0 ? void 0 : team.name, " ", _jsx("span", { style: { marginLeft: "auto" }, children: team === null || team === void 0 ? void 0 : team.type })] })),
|
|
96
|
+
value: team === null || team === void 0 ? void 0 : team.id,
|
|
97
|
+
key: `${team === null || team === void 0 ? void 0 : team.id} - ${team === null || team === void 0 ? void 0 : team.name} - ${team === null || team === void 0 ? void 0 : team.type}`,
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
setFilteredTeams(options);
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
console.log("Error while fetching external teams", err);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
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: [
|
|
107
|
+
{
|
|
108
|
+
required: true,
|
|
109
|
+
message: "Name is required",
|
|
110
|
+
},
|
|
111
|
+
], children: _jsx(Input, { placeholder: "Name" }) }), _jsx(Form.Item, { label: "Access Types", name: "accessTypes", rules: [
|
|
112
|
+
{
|
|
113
|
+
required: true,
|
|
114
|
+
message: "Access type is required",
|
|
115
|
+
},
|
|
116
|
+
], children: _jsx(Select, { options: ACCESS_TYPES, mode: "multiple", placeholder: "Select Access Type" }) }), _jsx(Form.Item, { label: "Admin Teams", name: "adminTeams", rules: [
|
|
117
|
+
{
|
|
118
|
+
required: true,
|
|
119
|
+
message: "Team Ids is required",
|
|
120
|
+
},
|
|
121
|
+
], children: _jsx(Select, { showSearch: true, mode: "multiple", placeholder: "Team Ids", options: filteredTeams, optionFilterProp: "key" }) }), _jsxs(Form.Item, { label: "DAM Location Details", name: "damLocationDetails", children: [_jsx(Form.Item, { label: "Type", name: ["damLocationDetails", "type"], rules: [
|
|
122
|
+
{
|
|
123
|
+
required: true,
|
|
124
|
+
message: "Type is required",
|
|
125
|
+
},
|
|
126
|
+
], children: _jsx(Select, { options: DAM_LOCATION_TYPES, onChange: (e) => {
|
|
127
|
+
onChangeDamLocationType(e);
|
|
128
|
+
}, placeholder: "Type" }) }), damLocationType === "external" && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Bucket", name: ["damLocationDetails", "bucket"], rules: [
|
|
129
|
+
{
|
|
130
|
+
required: true,
|
|
131
|
+
message: "Bucket is required",
|
|
132
|
+
},
|
|
133
|
+
], children: _jsx(Input, { placeholder: "Bucket" }) }), _jsx(Form.Item, { label: "Root Path", name: ["damLocationDetails", "rootPath"], rules: [
|
|
134
|
+
{
|
|
135
|
+
required: true,
|
|
136
|
+
message: "Root path is required",
|
|
137
|
+
},
|
|
138
|
+
], children: _jsx(Input, { placeholder: "Root path" }) }), _jsx(Form.Item, { label: "Access Key", name: ["damLocationDetails", "accessKeyId"], rules: [
|
|
139
|
+
{
|
|
140
|
+
required: true,
|
|
141
|
+
message: "Access key is required",
|
|
142
|
+
},
|
|
143
|
+
], children: _jsx(Input, { placeholder: "Access Key" }) }), _jsx(Form.Item, { label: "Secret Access Key", name: ["damLocationDetails", "secretAccessKey"], rules: [
|
|
144
|
+
{
|
|
145
|
+
required: true,
|
|
146
|
+
message: "Secret Access Key is required",
|
|
147
|
+
},
|
|
148
|
+
], children: _jsx(Input, { placeholder: "Secret Key" }) }), _jsx(Form.Item, { label: "Url", name: ["damLocationDetails", "url"], rules: [
|
|
149
|
+
{
|
|
150
|
+
required: true,
|
|
151
|
+
message: "Url is required",
|
|
152
|
+
},
|
|
153
|
+
], children: _jsx(Input, { placeholder: "Url" }) }), _jsx(Form.Item, { label: "Region", name: ["damLocationDetails", "region"], rules: [
|
|
154
|
+
{
|
|
155
|
+
required: true,
|
|
156
|
+
message: "Region is required",
|
|
157
|
+
},
|
|
158
|
+
], children: _jsx(Input, { placeholder: "Region" }) })] }))] }), _jsx(Form.Item, { label: "Subdomain", name: "subdomain", rules: [
|
|
159
|
+
{
|
|
160
|
+
required: true,
|
|
161
|
+
message: "Subdomain is required",
|
|
162
|
+
},
|
|
163
|
+
], children: _jsx(Input, { placeholder: "Subdomain" }) }), _jsx(Form.Item, { children: _jsx(Button, { htmlType: "submit", type: "primary", block: true, loading: loading, children: "Submit" }) })] }) }));
|
|
164
|
+
};
|
|
165
|
+
export default CreateClientForm;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare function App(props: {
|
|
2
|
+
accessKey: string;
|
|
3
|
+
secretKey: string;
|
|
4
|
+
subdomain: string;
|
|
5
|
+
clientSubdomain: string;
|
|
6
|
+
teamsApi: string;
|
|
7
|
+
username: string;
|
|
8
|
+
password: string;
|
|
9
|
+
onSuccess: (data: any) => void;
|
|
10
|
+
teamIds: string[] | number[];
|
|
11
|
+
styles: Record<string, any>;
|
|
12
|
+
appType: string;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
export default App;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DamConfigProvider } from "../hocs/DamConfigContext";
|
|
3
|
+
import { ThemeProvider } from "../hocs/ThemeContext";
|
|
4
|
+
import { ThemeModes } from "../utilities/constants/interface";
|
|
5
|
+
import CreateClient from "./CreateClientBtn";
|
|
6
|
+
import ToastProvider from "../hocs/ToastProvider";
|
|
7
|
+
function App(props) {
|
|
8
|
+
const config = {
|
|
9
|
+
damAccessKey: props === null || props === void 0 ? void 0 : props.accessKey,
|
|
10
|
+
secretKey: props === null || props === void 0 ? void 0 : props.secretKey,
|
|
11
|
+
subdomain: props === null || props === void 0 ? void 0 : props.subdomain,
|
|
12
|
+
teamIds: props === null || props === void 0 ? void 0 : props.teamIds,
|
|
13
|
+
styles: props === null || props === void 0 ? void 0 : props.styles,
|
|
14
|
+
appType: props === null || props === void 0 ? void 0 : props.appType,
|
|
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, {})] }) }));
|
|
17
|
+
}
|
|
18
|
+
export default App;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormInstance } from "antd";
|
|
2
|
+
import { MetaDataFieldEntity } from "../utilities/constants/interface";
|
|
3
|
+
declare function MetaFieldOptions({ meta, imagePickerId, form, previousMetaFields, index, totalFields, onMetaFieldChange, nextFieldId, allFieldIds, }: {
|
|
4
|
+
meta: MetaDataFieldEntity;
|
|
5
|
+
imagePickerId: string;
|
|
6
|
+
form: FormInstance;
|
|
7
|
+
previousMetaFields: MetaDataFieldEntity[];
|
|
8
|
+
index: number;
|
|
9
|
+
totalFields: number;
|
|
10
|
+
onMetaFieldChange?: (filters: Record<string, any>, index: number) => void;
|
|
11
|
+
nextFieldId?: string;
|
|
12
|
+
allFieldIds: string[];
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
export default MetaFieldOptions;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Form } from "antd";
|
|
12
|
+
import { useEffect, useMemo, useState } from "react";
|
|
13
|
+
import { find, get, map, pick, slice } from "lodash";
|
|
14
|
+
import { FETCH_META_FIELD_OPTIONS_URL } from "../utilities/constants/apiUrls";
|
|
15
|
+
import { InputTypes, NotificationStatus, } from "../utilities/constants/interface";
|
|
16
|
+
import { CustomSelectFormItem } from "../common/RenderFormItem";
|
|
17
|
+
import { showNotification } from "../common/notifications";
|
|
18
|
+
import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
|
|
19
|
+
import { useQueryClient } from "react-query";
|
|
20
|
+
import { getCurrentBrandUsers } from "../react-query/hooks/brand-hooks";
|
|
21
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
22
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
23
|
+
function MetaFieldOptions({ meta, imagePickerId, form, previousMetaFields, index, totalFields, onMetaFieldChange, nextFieldId, allFieldIds, }) {
|
|
24
|
+
const allFormValues = Form.useWatch([], form);
|
|
25
|
+
const filters = pick(allFormValues, slice(allFieldIds, 0, index));
|
|
26
|
+
const damConfig = useDamConfig();
|
|
27
|
+
const { brand } = damConfig;
|
|
28
|
+
const brandId = get(brand, "_id");
|
|
29
|
+
const queryClient = useQueryClient();
|
|
30
|
+
const users = getCurrentBrandUsers(queryClient, brandId);
|
|
31
|
+
const [state, setState] = useState({
|
|
32
|
+
loading: false,
|
|
33
|
+
options: [],
|
|
34
|
+
});
|
|
35
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
36
|
+
const { loading, options } = state;
|
|
37
|
+
const currentValue = Form.useWatch(get(meta, "_id"), form);
|
|
38
|
+
const allValues = Form.useWatch([], form);
|
|
39
|
+
const fetchOptions = (...args_1) => __awaiter(this, [...args_1], void 0, function* (filters = {}) {
|
|
40
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
|
|
41
|
+
try {
|
|
42
|
+
const payload = {
|
|
43
|
+
distinctValuesKey: get(meta, "_id"),
|
|
44
|
+
filters,
|
|
45
|
+
};
|
|
46
|
+
const response = yield api.put(FETCH_META_FIELD_OPTIONS_URL.replace(":id", imagePickerId), payload);
|
|
47
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false, options: get(meta, "defaultValue") === InputTypes.PERSON
|
|
48
|
+
? map(get(response, "data.values"), (id) => {
|
|
49
|
+
const user = find(users, (u) => get(u, "_id") === id);
|
|
50
|
+
return {
|
|
51
|
+
label: get(user, "name", "Unknown"),
|
|
52
|
+
value: get(user, "_id", id),
|
|
53
|
+
};
|
|
54
|
+
})
|
|
55
|
+
: map(get(response, "data.values"), (text) => ({
|
|
56
|
+
label: text,
|
|
57
|
+
value: text,
|
|
58
|
+
})) })));
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
showNotification(get(err, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
62
|
+
setState({ loading: false, options: [] });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
fetchOptions(filters);
|
|
67
|
+
}, [JSON.stringify(filters)]);
|
|
68
|
+
return (_jsx(CustomSelectFormItem, { name: get(meta, "_id"), label: get(meta, "name"), options: options, loading: loading, onChange: (value) => {
|
|
69
|
+
form.setFieldValue(get(meta, "_id"), value);
|
|
70
|
+
if (typeof onMetaFieldChange === "function") {
|
|
71
|
+
onMetaFieldChange(filters, index);
|
|
72
|
+
}
|
|
73
|
+
} }));
|
|
74
|
+
}
|
|
75
|
+
export default MetaFieldOptions;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ImagePickerEntity } from "../utilities/constants/interface";
|
|
2
|
+
declare function TestImagePickerModal({ imagePicker, open, toggleModal, setSelectedFile, }: {
|
|
3
|
+
imagePicker: ImagePickerEntity | {};
|
|
4
|
+
open: boolean;
|
|
5
|
+
toggleModal: () => void;
|
|
6
|
+
setSelectedFile: (thumbnailUrl: string, value: string) => void;
|
|
7
|
+
}): JSX.Element;
|
|
8
|
+
export default TestImagePickerModal;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Modal } from "antd";
|
|
12
|
+
import { get } from "lodash";
|
|
13
|
+
import DriveContainer from "../MyDrive/DriveContainer";
|
|
14
|
+
import { useMemo, useState } from "react";
|
|
15
|
+
import CustomButton from "../common/Button";
|
|
16
|
+
import TestImageFromMetalData from "./TestImgFromMetaData";
|
|
17
|
+
import { getFormattedValue } from "../hocs/helpers";
|
|
18
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
19
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
20
|
+
import { FETCH_ASSET_URL, FETCH_SHARED_FILE_URL, } from "../utilities/constants/apiUrls";
|
|
21
|
+
function TestImagePickerModal({ imagePicker, open, toggleModal, setSelectedFile, }) {
|
|
22
|
+
const [state, setState] = useState({
|
|
23
|
+
parentFolderId: get(imagePicker, "folderId"),
|
|
24
|
+
fileForConfirmation: {},
|
|
25
|
+
});
|
|
26
|
+
const damConfig = useDamConfig();
|
|
27
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
28
|
+
const { parentFolderId, fileForConfirmation } = state;
|
|
29
|
+
const onSelectFile = () => __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
// console.log(fileForConfirmation);
|
|
31
|
+
const response = yield api.get(FETCH_SHARED_FILE_URL.replace(":fileId", get(fileForConfirmation, "_id")));
|
|
32
|
+
// console.log(response);
|
|
33
|
+
const fileData = get(response, "data");
|
|
34
|
+
const assetId = get(fileData, "assetId");
|
|
35
|
+
const assetTypeResponse = yield api.get(FETCH_ASSET_URL.replace(":assetId", assetId));
|
|
36
|
+
const imagePickerOutputFormat = get(assetTypeResponse, "data.imagePickerOutputFormat", []);
|
|
37
|
+
const metadataFields = get(assetTypeResponse, "data.metadataFields", []);
|
|
38
|
+
// console.log(imagePickerOutputFormat);
|
|
39
|
+
const formattedOutputFormat = imagePickerOutputFormat.map((field) => {
|
|
40
|
+
// console.log("field", field);
|
|
41
|
+
const metaField = metadataFields.find((item) => (item === null || item === void 0 ? void 0 : item.name) == (field === null || field === void 0 ? void 0 : field.name));
|
|
42
|
+
return Object.assign(Object.assign({}, field), { fieldId: get(metaField, "_id") });
|
|
43
|
+
});
|
|
44
|
+
// console.log(formattedOutputFormat);
|
|
45
|
+
const value = getFormattedValue(formattedOutputFormat, fileForConfirmation === null || fileForConfirmation === void 0 ? void 0 : fileForConfirmation.s3Url, get(fileData, "metadata", {}));
|
|
46
|
+
console.log(value);
|
|
47
|
+
setSelectedFile(fileForConfirmation === null || fileForConfirmation === void 0 ? void 0 : fileForConfirmation.thumbnailUrl, value);
|
|
48
|
+
});
|
|
49
|
+
return (_jsx(Modal, { title: `Test ${get(imagePicker, "name", "Image picker")}`, open: open, onCancel: toggleModal, okText: "Create", maskClosable: false, width: get(imagePicker, "assetId") ? 600 : 1000, footer: get(fileForConfirmation, "thumbnailUrl") ? (_jsx(CustomButton, { type: "primary", label: "Confirm", onClick: () => {
|
|
50
|
+
onSelectFile();
|
|
51
|
+
} }, "confirm")) : null, children: get(imagePicker, "assetId") ? (_jsx(TestImageFromMetalData, { imagePicker: imagePicker, selectedPickerFile: fileForConfirmation, setSelectedFile: (file) => {
|
|
52
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { fileForConfirmation: file })));
|
|
53
|
+
} })) : (_jsx(DriveContainer, { setSelectedFile: (file, localFile = false) => {
|
|
54
|
+
console.log("local file", file);
|
|
55
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { fileForConfirmation: file })));
|
|
56
|
+
if (localFile) {
|
|
57
|
+
setSelectedFile(get(file, "s3Url", ""), get(file, "thumbnailUrl", ""));
|
|
58
|
+
}
|
|
59
|
+
}, parentFolderId: parentFolderId, setParentFolderId: (id) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { parentFolderId: id, fileForConfirmation: {} }))), pickerFolderId: get(imagePicker, "folderId"), selectedPickerFile: fileForConfirmation, imagePicker: imagePicker })) }));
|
|
60
|
+
}
|
|
61
|
+
export default TestImagePickerModal;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FileEntity, ImagePickerEntity } from "../utilities/constants/interface";
|
|
2
|
+
declare function TestImageFromMetalData({ imagePicker, selectedPickerFile, setSelectedFile, }: {
|
|
3
|
+
imagePicker: ImagePickerEntity;
|
|
4
|
+
selectedPickerFile: FileEntity;
|
|
5
|
+
setSelectedFile: (file: FileEntity) => void;
|
|
6
|
+
}): JSX.Element;
|
|
7
|
+
export default TestImageFromMetalData;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { FETCH_ASSET_URL, FETCH_META_FIELD_FILES_URL, } from "../utilities/constants/apiUrls";
|
|
12
|
+
import { NotificationStatus, } from "../utilities/constants/interface";
|
|
13
|
+
import { get, map, reduce, slice } from "lodash";
|
|
14
|
+
import { useEffect, useMemo, useState } from "react";
|
|
15
|
+
import { showNotification } from "../common/notifications";
|
|
16
|
+
import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
|
|
17
|
+
import Loader from "../common/loader/loader";
|
|
18
|
+
import { Form } from "antd";
|
|
19
|
+
import PageTitle from "../ui/pageTitle";
|
|
20
|
+
import MetaFieldOptions from "./MetaFieldOptions";
|
|
21
|
+
import { FiImage } from "react-icons/fi";
|
|
22
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
23
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
24
|
+
const FiImageIcon = FiImage;
|
|
25
|
+
function TestImageFromMetalData({ imagePicker, selectedPickerFile, setSelectedFile, }) {
|
|
26
|
+
const [form] = Form.useForm();
|
|
27
|
+
const [state, setState] = useState({
|
|
28
|
+
templateLoading: false,
|
|
29
|
+
assetTemplate: {},
|
|
30
|
+
loading: false,
|
|
31
|
+
files: [],
|
|
32
|
+
});
|
|
33
|
+
const damConfig = useDamConfig();
|
|
34
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
35
|
+
const { templateLoading, assetTemplate, loading, files } = state;
|
|
36
|
+
const fetchTemplate = (assetId) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { templateLoading: true })));
|
|
38
|
+
try {
|
|
39
|
+
const response = yield api.get(`${FETCH_ASSET_URL.replace(":assetId", assetId)}`);
|
|
40
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { assetTemplate: get(response, "data", {}), templateLoading: false })));
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { assetTemplate: {}, templateLoading: false })));
|
|
44
|
+
showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const handleFinalFilterSelect = (filters) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
|
|
49
|
+
try {
|
|
50
|
+
const response = yield api.put(FETCH_META_FIELD_FILES_URL.replace(":id", get(imagePicker, "_id")), { filters });
|
|
51
|
+
setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false, files: get(response, "data", []) })));
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
showNotification(SOMETHING_WENT_WRONG, NotificationStatus.ERROR);
|
|
55
|
+
setState((prev) => (Object.assign(Object.assign({}, prev), { images: [], loading: false })));
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (get(imagePicker, "assetId")) {
|
|
60
|
+
fetchTemplate(get(imagePicker, "assetId"));
|
|
61
|
+
}
|
|
62
|
+
}, [imagePicker]);
|
|
63
|
+
const handleMetaFieldChange = (...args_1) => __awaiter(this, [...args_1], void 0, function* (filters = {}, index) {
|
|
64
|
+
const allFieldIds = map(get(assetTemplate, "metadataFields", []), "_id");
|
|
65
|
+
const succeedingFieldIds = slice(allFieldIds, index + 1);
|
|
66
|
+
form.setFieldsValue(reduce(succeedingFieldIds, (acc, id) => {
|
|
67
|
+
acc[id] = undefined;
|
|
68
|
+
return acc;
|
|
69
|
+
}, {}));
|
|
70
|
+
handleFinalFilterSelect(filters);
|
|
71
|
+
});
|
|
72
|
+
return (_jsx("div", { children: templateLoading ? (_jsx(Loader, {})) : (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-gap-3", children: [_jsx(PageTitle, { label: get(assetTemplate, "name", "Asset Template") }), _jsx(Form, { layout: "vertical", form: form, children: map(get(assetTemplate, "metadataFields", []), (meta, index) => {
|
|
73
|
+
const metadataFields = get(assetTemplate, "metadataFields", []);
|
|
74
|
+
const allFieldIds = map(metadataFields, "_id");
|
|
75
|
+
const nextField = metadataFields[index + 1];
|
|
76
|
+
const nextFieldId = get(nextField, "_id");
|
|
77
|
+
return (_jsx(MetaFieldOptions, { meta: meta, imagePickerId: get(imagePicker, "_id"), form: form, previousMetaFields: slice(metadataFields, 0, index), index: index, totalFields: metadataFields.length, onMetaFieldChange: handleMetaFieldChange, nextFieldId: nextFieldId, allFieldIds: allFieldIds }, index));
|
|
78
|
+
}) }), loading ? (_jsx(Loader, {})) : (_jsx(_Fragment, { children: get(files, "length") > 0 && (_jsx("div", { className: "md-lib-grid md-lib-grid-cols-1 sm:md-lib-grid-cols-2 md:md-lib-grid-cols-3 lg:md-lib-grid-cols-4 xl:md-lib-grid-cols-5 md-lib-gap-4 md-lib-p-4", children: map(files, (file) => (_jsxs("div", { onClick: () => setSelectedFile(file), className: `md-lib-flex md-lib-flex-col md-lib-items-center md-lib-border md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-rounded-md md-lib-p-3 dark:md-lib-bg-darkPrimaryBg ${get(file, "_id") === get(selectedPickerFile, "_id")
|
|
79
|
+
? "md-lib-bg-borderColor dark:md-lib-bg-darkBorderColor"
|
|
80
|
+
: ""}`, children: [_jsx("div", { className: "md-lib-w-full md-lib-aspect-square md-lib-flex md-lib-items-center md-lib-justify-center md-lib-rounded md-lib-border md-lib-border-dashed md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-overflow-hidden", children: get(file, `${get(imagePicker, "_id")}.s3Url`) ? (_jsx("img", { src: get(file, `s3Url`), alt: get(file, `name`, "Unknown"), width: 200, height: 200, className: "md-lib-object-contain md-lib-w-full md-lib-h-full" })) : (_jsx(FiImageIcon, { className: "md-lib-text-4xl md-lib-text-borderColor dark:md-lib-text-darkBorderColor" })) }), _jsx("div", { className: "md-lib-font-medium md-lib-text-sm md-lib-mt-3 md-lib-text-center md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-truncate md-lib-w-[80px]", title: get(file, "name"), children: get(file, "name") })] }, get(file, "_id")))) })) }))] })) }));
|
|
81
|
+
}
|
|
82
|
+
export default TestImageFromMetalData;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
|
+
import { useEffect, useMemo, useState } from "react";
|
|
12
|
+
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
13
|
+
import { createApiClient } from "../hocs/configureAxios";
|
|
14
|
+
import { FETCH_IMAGEPICKER_URL } from "../utilities/constants/apiUrls";
|
|
15
|
+
import { get } from "lodash";
|
|
16
|
+
import { FiImage } from "react-icons/fi";
|
|
17
|
+
import CustomButton from "../common/Button";
|
|
18
|
+
import TestImagePickerModal from "./TestImagePickerModal";
|
|
19
|
+
const FiImageIcon = FiImage;
|
|
20
|
+
function ImagePicker({ id, onSelect, url, }) {
|
|
21
|
+
const damConfig = useDamConfig();
|
|
22
|
+
const { brand } = damConfig;
|
|
23
|
+
const [picker, setPicker] = useState({});
|
|
24
|
+
const [imagePickerUrl, setImagePickerUrl] = useState("");
|
|
25
|
+
const [show, setShow] = useState(false);
|
|
26
|
+
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
27
|
+
const [loading, setLoading] = useState(false);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (url) {
|
|
30
|
+
setImagePickerUrl(url);
|
|
31
|
+
}
|
|
32
|
+
}, [url]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (brand) {
|
|
35
|
+
getImagePicker();
|
|
36
|
+
}
|
|
37
|
+
}, [brand]);
|
|
38
|
+
const getImagePicker = () => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
try {
|
|
40
|
+
setLoading(true);
|
|
41
|
+
const response = yield api.get(FETCH_IMAGEPICKER_URL.replace(":id", id));
|
|
42
|
+
setPicker(get(response, "data", {}));
|
|
43
|
+
setLoading(false);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
console.log("Error while fetching image picker", err);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
const onImageSelect = (url, value) => {
|
|
50
|
+
setImagePickerUrl(url);
|
|
51
|
+
toggleShow();
|
|
52
|
+
if (onSelect) {
|
|
53
|
+
onSelect(url, value);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const toggleShow = () => {
|
|
57
|
+
setShow(!show);
|
|
58
|
+
};
|
|
59
|
+
return (_jsxs(_Fragment, { children: [" ", _jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-border md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-rounded-md md-lib-p-3 dark:md-lib-bg-darkPrimaryBg", children: [_jsx("div", { className: "md-lib-w-full md-lib-aspect-square md-lib-flex md-lib-items-center md-lib-justify-center md-lib-rounded md-lib-border md-lib-border-dashed md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-overflow-hidden", children: imagePickerUrl ? (_jsx("img", { src: imagePickerUrl, alt: get(picker, "name", "Unknown"), width: 200, height: 200, className: "md-lib-object-contain md-lib-w-full md-lib-h-full" })) : (_jsx(FiImageIcon, { className: "md-lib-text-4xl md-lib-text-borderColor dark:md-lib-text-darkBorderColor" })) }), _jsx("div", { className: "md-lib-font-medium md-lib-text-sm md-lib-mt-3 md-lib-text-center md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-truncate md-lib-w-[150px]", title: get(picker, "name"), children: get(picker, "name") }), _jsx("div", { className: "md-lib-flex md-lib-items-center md-lib-justify-between md-lib-w-full md-lib-mt-3", children: _jsx(CustomButton, { type: "primary", label: "Select", className: "md-lib-w-11/12", onClick: toggleShow }) })] }, get(picker, "_id")), show && (_jsx(TestImagePickerModal, { open: show, toggleModal: toggleShow, imagePicker: picker, setSelectedFile: (thumbnailUrl, value) => {
|
|
60
|
+
onImageSelect(thumbnailUrl, value);
|
|
61
|
+
} }))] }));
|
|
62
|
+
}
|
|
63
|
+
export default ImagePicker;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare function App(props: {
|
|
2
|
+
accessKey?: string;
|
|
3
|
+
secretKey?: string;
|
|
4
|
+
subdomain?: string;
|
|
5
|
+
teamIds?: string[];
|
|
6
|
+
styles?: any;
|
|
7
|
+
appType?: string;
|
|
8
|
+
id: string;
|
|
9
|
+
onSelect?: (url: string, value: any) => void;
|
|
10
|
+
url?: string;
|
|
11
|
+
routerVersion: 4 | 5 | 6;
|
|
12
|
+
}): JSX.Element;
|
|
13
|
+
export default App;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DamConfigProvider } from "../hocs/DamConfigContext";
|
|
3
|
+
import { ThemeProvider } from "../hocs/ThemeContext";
|
|
4
|
+
import { ThemeModes } from "../utilities/constants/interface";
|
|
5
|
+
import AppProvider from "../hocs/AppProvider";
|
|
6
|
+
import ToastProvider from "../hocs/ToastProvider";
|
|
7
|
+
import { MemoryRouter } from "react-router-dom";
|
|
8
|
+
import AppRoutes from "./routes";
|
|
9
|
+
import process from "process";
|
|
10
|
+
function App(props) {
|
|
11
|
+
const config = {
|
|
12
|
+
damAccessKey: props === null || props === void 0 ? void 0 : props.accessKey,
|
|
13
|
+
secretKey: props === null || props === void 0 ? void 0 : props.secretKey,
|
|
14
|
+
subdomain: props === null || props === void 0 ? void 0 : props.subdomain,
|
|
15
|
+
teamIds: props === null || props === void 0 ? void 0 : props.teamIds,
|
|
16
|
+
styles: props === null || props === void 0 ? void 0 : props.styles,
|
|
17
|
+
appType: props === null || props === void 0 ? void 0 : props.appType,
|
|
18
|
+
};
|
|
19
|
+
if (typeof window !== "undefined" && !window.process) {
|
|
20
|
+
window.process = process;
|
|
21
|
+
}
|
|
22
|
+
return (_jsx(DamConfigProvider, { config: config, children: _jsx(ThemeProvider, { styles: props === null || props === void 0 ? void 0 : props.styles, sessionTheme: ThemeModes.LIGHT, children: _jsxs(AppProvider, { children: [_jsx(MemoryRouter, { initialEntries: ["/"], children: _jsx(AppRoutes, { id: props.id, onSelect: props === null || props === void 0 ? void 0 : props.onSelect, url: props === null || props === void 0 ? void 0 : props.url, routerVersion: (props === null || props === void 0 ? void 0 : props.routerVersion) || 6 }) }), _jsx(ToastProvider, {})] }) }) }));
|
|
23
|
+
}
|
|
24
|
+
export default App;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { IMAGE_PICKER_SCREEN } from "../utilities/constants/routes";
|
|
3
|
+
import ImagePicker from "./imagePickerComponent";
|
|
4
|
+
import { NavigatorProvider } from "../utilities/NavigatorProvider";
|
|
5
|
+
export default function AppRoutes(props) {
|
|
6
|
+
const { routerVersion } = props;
|
|
7
|
+
if (routerVersion === 6) {
|
|
8
|
+
// ✅ React Router v6
|
|
9
|
+
const { Routes, Route } = require("react-router-dom");
|
|
10
|
+
return (_jsx(Routes, { children: _jsx(Route, { path: IMAGE_PICKER_SCREEN, element: _jsx(ImagePicker, { id: props.id, onSelect: props === null || props === void 0 ? void 0 : props.onSelect, url: props === null || props === void 0 ? void 0 : props.url }) }, IMAGE_PICKER_SCREEN) }));
|
|
11
|
+
}
|
|
12
|
+
// ✅ React Router v4/v5
|
|
13
|
+
const { Switch, Route, withRouter } = require("react-router-dom");
|
|
14
|
+
const Wrapper = ({ history }) => (_jsx(NavigatorProvider, { history: history, children: _jsx(Switch, { children: _jsx(Route, { path: IMAGE_PICKER_SCREEN, render: (props) => (_jsx(ImagePicker, Object.assign({ id: props.id, onSelect: props === null || props === void 0 ? void 0 : props.onSelect, url: props === null || props === void 0 ? void 0 : props.url }, props))) }, IMAGE_PICKER_SCREEN) }) }));
|
|
15
|
+
const WithRouterWrapper = withRouter(Wrapper);
|
|
16
|
+
return _jsx(WithRouterWrapper, {});
|
|
17
|
+
}
|