@integry/sdk 4.5.2 → 4.5.4
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/.vscode/launch.json +2 -2
- package/THIRD_PARTY_LICENSES +0 -37
- package/dist/esm/index.csm.d.ts +12 -2
- package/dist/esm/index.csm.js +7262 -1
- package/dist/umd/index.umd.d.ts +9 -1
- package/dist/umd/index.umd.js +7262 -1
- package/jest.config.cjs +10 -0
- package/package.json +10 -4
- package/src/components/AddTagButton/index.ts +23 -0
- package/src/components/BasicSelect/index.ts +114 -0
- package/src/components/BasicSelect/styles.module.scss +44 -0
- package/src/components/Button/index.ts +94 -0
- package/src/components/Button/styles.module.scss +152 -0
- package/src/components/CheckboxGroup/Checkbox.ts +104 -0
- package/src/components/CheckboxGroup/index.ts +190 -0
- package/src/components/CheckboxGroup/styles.module.scss +63 -0
- package/src/components/CollapsedMenu/index.ts +101 -0
- package/src/components/CollapsedMenu/styles.module.scss +46 -0
- package/src/components/ConfigureFieldWrapper/index.ts +85 -0
- package/src/components/ConfigureFieldWrapper/styles.module.scss +57 -0
- package/src/components/EditableText/index.ts +121 -0
- package/src/components/EditableText/styles.module.scss +38 -0
- package/src/components/EditableTextArea/index.ts +143 -0
- package/src/components/EditableTextArea/styles.module.scss +91 -0
- package/src/components/ErrorMessage/index.ts +16 -0
- package/src/components/ErrorMessage/styles.module.scss +19 -0
- package/src/components/ErrorPage/index.ts +42 -0
- package/src/components/ErrorPage/styles.module.scss +26 -0
- package/src/components/Footer/index.ts +41 -0
- package/src/components/Footer/styles.module.scss +40 -0
- package/src/components/HTMLContent/index.tsx +275 -0
- package/src/components/HTMLContent/styles.module.scss +3 -0
- package/src/components/InfoBox/index.ts +48 -0
- package/src/components/InfoBox/styles.module.scss +21 -0
- package/src/components/Input/BaseInput/index.ts +170 -0
- package/src/components/Input/BaseInput/styles.module.scss +94 -0
- package/src/components/Input/DateInput/index.ts +103 -0
- package/src/components/Input/DateInput/styles.module.scss +50 -0
- package/src/components/Input/Input/index.ts +206 -0
- package/src/components/Input/Input/styles.module.scss +14 -0
- package/src/components/Input/PasswordInput/index.ts +164 -0
- package/src/components/Input/PasswordInput/styles.module.scss +37 -0
- package/src/components/Input/index.ts +7 -0
- package/src/components/Label/index.ts +61 -0
- package/src/components/Label/styles.module.scss +41 -0
- package/src/components/LargeLoader/index.ts +25 -0
- package/src/components/LargeLoader/styles.module.scss +16 -0
- package/src/components/Listbox/ListBoxItem.ts +57 -0
- package/src/components/Listbox/index.ts +479 -0
- package/src/components/Listbox/styles.module.scss +197 -0
- package/src/components/Loader/index.ts +25 -0
- package/src/components/Loader/styles.module.scss +16 -0
- package/src/components/MediaGallery/MediaGalleryModal.ts +82 -0
- package/src/components/MediaGallery/MediaSlider.ts +76 -0
- package/src/components/MediaGallery/index.ts +92 -0
- package/src/components/MediaGallery/styles.module.scss +156 -0
- package/src/components/MediaUpload/index.ts +233 -0
- package/src/components/MediaUpload/styles.module.scss +118 -0
- package/src/components/Modal/index.ts +87 -0
- package/src/components/Modal/styles.module.scss +441 -0
- package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +58 -0
- package/src/components/MultipurposeField/Dropdown/index.tsx +981 -0
- package/src/components/MultipurposeField/Dropdown/styles.module.scss +208 -0
- package/src/components/MultipurposeField/TagMenu/index.ts +384 -0
- package/src/components/MultipurposeField/TagMenu/styles.module.scss +136 -0
- package/src/components/MultipurposeField/TagOptions/index.tsx +83 -0
- package/src/components/MultipurposeField/TagOptions/styles.module.scss +95 -0
- package/src/components/MultipurposeField/index.tsx +687 -0
- package/src/components/MultipurposeField/styles.module.scss +56 -0
- package/src/components/NewModal/index.ts +69 -0
- package/src/components/NewModal/styles.module.scss +70 -0
- package/src/components/OverflowTooltip/index.tsx +59 -0
- package/src/components/PopUp/ConfirmationPopUp/index.ts +58 -0
- package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +49 -0
- package/src/components/PopUp/SuccessPopUp/index.ts +62 -0
- package/src/components/PopUp/SuccessPopUp/styles.module.scss +38 -0
- package/src/components/RadioGroup/Radio.ts +129 -0
- package/src/components/RadioGroup/index.ts +169 -0
- package/src/components/RadioGroup/styles.module.scss +81 -0
- package/src/components/Search/index.ts +69 -0
- package/src/components/Search/styles.module.scss +149 -0
- package/src/components/TabBar/Tab.ts +33 -0
- package/src/components/TabBar/index.ts +64 -0
- package/src/components/TabBar/styles.module.scss +43 -0
- package/src/components/Tag/index.ts +29 -0
- package/src/components/Tag/styles.module.scss +57 -0
- package/src/components/TextArea/index.ts +172 -0
- package/src/components/TextArea/styles.module.scss +70 -0
- package/src/components/TextContent/index.tsx +128 -0
- package/src/components/TextContent/styles.module.scss +6 -0
- package/src/components/ThreeDotLoader/index.ts +39 -0
- package/src/components/ThreeDotLoader/styles.module.scss +41 -0
- package/src/components/TimeInput/index.ts +129 -0
- package/src/components/TimeInput/styles.module.scss +16 -0
- package/src/components/Toggle/index.ts +34 -0
- package/src/components/Toggle/styles.module.scss +56 -0
- package/src/components/Toggle-v2/index.ts +40 -0
- package/src/components/Toggle-v2/styles.module.scss +86 -0
- package/src/components/Tooltip/index.ts +271 -0
- package/src/components/Tooltip/styles.module.scss +105 -0
- package/src/components/form/ObjectField/index.ts +364 -0
- package/src/components/form/ObjectField/styles.module.scss +103 -0
- package/src/components/form/index.ts +3 -0
- package/src/contexts/AppContext.ts +12 -0
- package/src/declaration.d.ts +7 -0
- package/src/extensions/HMAC.ts +25 -0
- package/src/extensions/IntegryAPIError.ts +19 -0
- package/src/features/common/AccountDropdown/index.ts +291 -0
- package/src/features/common/AccountDropdown/styles.module.scss +19 -0
- package/src/features/common/ActionForm/index.ts +1818 -0
- package/src/features/common/ActionForm/styles.module.scss +23 -0
- package/src/features/common/AppCard/index.ts +207 -0
- package/src/features/common/AppCard/styles.module.scss +117 -0
- package/src/features/common/AppCardCompact/index.ts +189 -0
- package/src/features/common/AppCardCompact/styles.module.scss +141 -0
- package/src/features/common/AuthSelector/index.ts +537 -0
- package/src/features/common/AuthSelector/styles.module.scss +161 -0
- package/src/features/common/AuthSelectorCompact/index.ts +706 -0
- package/src/features/common/AuthSelectorCompact/styles.module.scss +219 -0
- package/src/features/common/AuthSelectorDropdown/index.ts +704 -0
- package/src/features/common/AuthSelectorDropdown/styles.module.scss +361 -0
- package/src/features/common/DynamicField/index.ts +229 -0
- package/src/features/common/DynamicField/styles.module.scss +67 -0
- package/src/features/common/DynamicTypedField/index.ts +217 -0
- package/src/features/common/DynamicTypedField/styles.module.scss +67 -0
- package/src/features/common/FunctionForm/index.ts +862 -0
- package/src/features/common/FunctionForm/styles.module.scss +163 -0
- package/src/features/common/MappingUI/index.ts +649 -0
- package/src/features/common/MappingUI/styles.module.scss +121 -0
- package/src/features/common/MarketplaceAppCard/index.ts +279 -0
- package/src/features/common/MarketplaceAppCard/styles.module.scss +231 -0
- package/src/features/common/MarketplaceAppCardCompact/index.ts +283 -0
- package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +255 -0
- package/src/features/common/NewMappingUI/index.ts +515 -0
- package/src/features/common/NewMappingUI/styles.module.scss +113 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +67 -0
- package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +23 -0
- package/src/features/common/RequestAppWidget/index.ts +48 -0
- package/src/features/common/RequestAppWidget/request-app-form.ts +89 -0
- package/src/features/common/RequestAppWidget/styles.module.scss +43 -0
- package/src/features/common/SectionField/index.ts +272 -0
- package/src/features/common/SectionField/styles.module.scss +67 -0
- package/src/features/common/Step/index.ts +827 -0
- package/src/features/common/Step/styles.module.scss +12 -0
- package/src/features/common/StepNavigation/CollapsedSteps.ts +125 -0
- package/src/features/common/StepNavigation/NavItem.ts +111 -0
- package/src/features/common/StepNavigation/index.ts +257 -0
- package/src/features/common/StepNavigation/styles.module.scss +117 -0
- package/src/features/common/Steps/index.ts +1139 -0
- package/src/features/common/Steps/styles.module.scss +314 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +383 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +367 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +194 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +389 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +577 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +83 -0
- package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +212 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +45 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +1081 -0
- package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +452 -0
- package/src/features/containers/AppFlowContainer/Authentication/index.ts +610 -0
- package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +468 -0
- package/src/features/containers/AppFlowContainer/index.ts +114 -0
- package/src/features/containers/AppPageContainer/AppPage/index.tsx +262 -0
- package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +120 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +165 -0
- package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +81 -0
- package/src/features/containers/AppPageContainer/index.tsx +93 -0
- package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
- package/src/features/containers/AppsForFlows/index.ts +161 -0
- package/src/features/containers/AppsForFlows/styles.module.scss +280 -0
- package/src/features/containers/AppsForFlowsCompact/index.ts +161 -0
- package/src/features/containers/AppsForFlowsCompact/styles.module.scss +279 -0
- package/src/features/containers/AuthSetupContainer/AppSelection.ts +73 -0
- package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +67 -0
- package/src/features/containers/AuthSetupContainer/Footer.ts +32 -0
- package/src/features/containers/AuthSetupContainer/Header.ts +39 -0
- package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +27 -0
- package/src/features/containers/AuthSetupContainer/index.ts +349 -0
- package/src/features/containers/AuthSetupContainer/styles.module.scss +229 -0
- package/src/features/containers/FlowSetupContainer/index.ts +390 -0
- package/src/features/containers/FlowSetupContainer/styles.module.scss +18 -0
- package/src/features/containers/MarkeplaceApps/index.ts +574 -0
- package/src/features/containers/MarkeplaceApps/styles.module.scss +559 -0
- package/src/features/containers/MarketplaceAppsCompact/index.ts +576 -0
- package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +546 -0
- package/src/features/containers/MarketplaceAppsContainer/index.ts +83 -0
- package/src/features/containers/MarketplaceContainer/AppCard/index.ts +91 -0
- package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +66 -0
- package/src/features/containers/MarketplaceContainer/AppListing/index.ts +34 -0
- package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +10 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +132 -0
- package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +117 -0
- package/src/features/containers/MarketplaceContainer/index.ts +242 -0
- package/src/features/containers/MarketplaceContainer/styles.module.scss +84 -0
- package/src/features/containers/SDKContainer/index.ts +817 -0
- package/src/features/containers/SDKContainer/styles.module.scss +266 -0
- package/src/features/containers/SDKDebugContainer/index.ts +137 -0
- package/src/features/containers/SDKDebugContainer/styles.module.scss +37 -0
- package/src/features/containers/SDKFailedContainer/index.ts +117 -0
- package/src/features/containers/SDKFailedContainer/styles.module.scss +57 -0
- package/src/features/integrations/IntegrationRow/Icons.ts +77 -0
- package/src/features/integrations/IntegrationRow/index.ts +129 -0
- package/src/features/integrations/IntegrationRow/styles.module.scss +62 -0
- package/src/features/integrations/IntegrationsHeader/index.ts +34 -0
- package/src/features/integrations/IntegrationsHeader/styles.module.scss +47 -0
- package/src/features/integrations/IntegrationsList/index.ts +252 -0
- package/src/features/integrations/IntegrationsList/styles.module.scss +67 -0
- package/src/features/templates/Template/index.ts +295 -0
- package/src/features/templates/Template/styles.module.scss +226 -0
- package/src/features/templates/TemplatesView/index.ts +368 -0
- package/src/features/templates/TemplatesView/styles.module.scss +71 -0
- package/src/features/templates/TemplatesViewCompact/index.ts +364 -0
- package/src/features/templates/TemplatesViewCompact/styles.module.scss +141 -0
- package/src/hooks/useAutosizeTextArea.ts +22 -0
- package/src/hooks/useCustomRef.ts +13 -0
- package/src/hooks/useDebounce.ts +17 -0
- package/src/hooks/useElementResize.ts +40 -0
- package/src/hooks/useEventListener.ts +44 -0
- package/src/hooks/useHover.ts +40 -0
- package/src/hooks/useOnClickOutside.ts +32 -0
- package/src/index.ts +2051 -0
- package/src/index.umd.ts +13 -0
- package/src/interfaces/index.ts +924 -0
- package/src/modules/api/index.ts +1315 -0
- package/src/modules/api/responseHandler.ts +38 -0
- package/src/modules/event-emitter/index.ts +72 -0
- package/src/modules/event-emitter/runners/abstract.ts +21 -0
- package/src/modules/event-emitter/runners/default.ts +11 -0
- package/src/modules/event-emitter/runners/ntimes.ts +28 -0
- package/src/modules/event-emitter/types.ts +34 -0
- package/src/store/actionFunctions.ts +1573 -0
- package/src/store/index.ts +17 -0
- package/src/store/initialState.ts +58 -0
- package/src/stories/Button.stories.tsx +83 -0
- package/src/stories/Checkbox/Checkbox.stories.tsx +41 -0
- package/src/stories/Checkbox/CheckboxGroup.stories.tsx +46 -0
- package/src/stories/EditableText.stories.tsx +35 -0
- package/src/stories/Input/BaseInput.stories.tsx +48 -0
- package/src/stories/Input/DateInput.stories.tsx +28 -0
- package/src/stories/Input/Input.stories.tsx +24 -0
- package/src/stories/Input/PasswordInput.stories.tsx +26 -0
- package/src/stories/Introduction.stories.mdx +211 -0
- package/src/stories/Label.stories.tsx +27 -0
- package/src/stories/Listbox.stories.tsx +122 -0
- package/src/stories/Radio/Radio.stories.tsx +39 -0
- package/src/stories/Radio/RadioGroup.stories.tsx +46 -0
- package/src/stories/StepNavigation/NavItem.stories.tsx +31 -0
- package/src/stories/StepNavigation/StepNavigation.stories.tsx +50 -0
- package/src/stories/TabBar.stories.tsx +31 -0
- package/src/stories/TextArea.stories.tsx +23 -0
- package/src/stories/TimeInput.stories.tsx +37 -0
- package/src/stories/Toggle.stories.tsx +33 -0
- package/src/stories/assets/code-brackets.svg +1 -0
- package/src/stories/assets/colors.svg +1 -0
- package/src/stories/assets/comments.svg +1 -0
- package/src/stories/assets/direction.svg +1 -0
- package/src/stories/assets/flow.svg +1 -0
- package/src/stories/assets/plugin.svg +1 -0
- package/src/stories/assets/repo.svg +1 -0
- package/src/stories/assets/stackalt.svg +1 -0
- package/src/types/index.ts +293 -0
- package/src/types/store.ts +366 -0
- package/src/types/utils.ts +19 -0
- package/src/utils/ActivityOutputUtils.ts +163 -0
- package/src/utils/common.ts +20 -0
- package/src/utils/copyToClipboard.ts +24 -0
- package/src/utils/datetime.ts +101 -0
- package/src/utils/getUrlParam.ts +11 -0
- package/src/utils/isAuthMessage.ts +16 -0
- package/src/utils/isBrowser.ts +1 -0
- package/src/utils/jsonEncodeDecode.ts +15 -0
- package/src/utils/objectUtils.ts +116 -0
- package/src/utils/popup.ts +30 -0
- package/src/utils/searchJson.ts +51 -0
- package/src/utils/stepUtils.ts +45 -0
- package/src/utils/truncate.ts +6 -0
- package/test/setup.ts +1 -0
- package/vitest.config.ts +10 -0
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
2
|
+
import { html } from 'htm/preact';
|
|
3
|
+
import { connect } from 'unistore/preact';
|
|
4
|
+
import { useContext, useEffect, useRef, useState } from 'preact/hooks';
|
|
5
|
+
import { ActivityCustomField, TemplateField } from '@/interfaces';
|
|
6
|
+
import AppContext from '@/contexts/AppContext';
|
|
7
|
+
import { StoreType } from '@/types/store';
|
|
8
|
+
import { LargeLoader } from '@/components/LargeLoader';
|
|
9
|
+
import { actionFunctions } from '@/store';
|
|
10
|
+
import { Label } from '@/components/Label';
|
|
11
|
+
import { Tag } from '@/components/Tag';
|
|
12
|
+
import { Select } from '@/components/BasicSelect';
|
|
13
|
+
|
|
14
|
+
import styles from './styles.module.scss';
|
|
15
|
+
|
|
16
|
+
export type MappingUiProps = {
|
|
17
|
+
stepId: number;
|
|
18
|
+
templateFields: TemplateField[];
|
|
19
|
+
showStepValidation?: boolean;
|
|
20
|
+
} & StoreType;
|
|
21
|
+
|
|
22
|
+
interface DynamicDataItem {
|
|
23
|
+
fieldId: number;
|
|
24
|
+
id: string | null;
|
|
25
|
+
title: string | null;
|
|
26
|
+
type: string;
|
|
27
|
+
isDynamic?: boolean;
|
|
28
|
+
isVisible: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface FieldMappingEndpointData {
|
|
32
|
+
[key: string]: DynamicDataItem[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const NewMappingUI = (props: MappingUiProps) => {
|
|
36
|
+
const [loading, setLoading] = useState<boolean>(true);
|
|
37
|
+
const [fieldsLoading, setFieldsLoading] = useState<boolean>(true);
|
|
38
|
+
|
|
39
|
+
const [fieldsRef, setFieldsRef] = useState<number[]>([]);
|
|
40
|
+
const [dynamicItems, setDynamicItems] = useState<DynamicDataItem[]>([]);
|
|
41
|
+
const [dynamicListId, setDynamicListId] = useState('');
|
|
42
|
+
const [
|
|
43
|
+
savedMappingField,
|
|
44
|
+
setSavedMappingField,
|
|
45
|
+
] = useState<TemplateField | null>(null);
|
|
46
|
+
|
|
47
|
+
const [error, setError] = useState('');
|
|
48
|
+
const [standardFields, setStandardFields] = useState<
|
|
49
|
+
{
|
|
50
|
+
fieldId: number;
|
|
51
|
+
id: string | null;
|
|
52
|
+
title: string | null;
|
|
53
|
+
type: string;
|
|
54
|
+
isDynamic: boolean;
|
|
55
|
+
isVisible: boolean;
|
|
56
|
+
}[]
|
|
57
|
+
>([]);
|
|
58
|
+
|
|
59
|
+
const [
|
|
60
|
+
fieldMappingData,
|
|
61
|
+
setFieldMappingData,
|
|
62
|
+
] = useState<FieldMappingEndpointData>({});
|
|
63
|
+
|
|
64
|
+
const [fieldListData, setFieldListData] = useState<ActivityCustomField[]>([]);
|
|
65
|
+
|
|
66
|
+
const context = useContext(AppContext);
|
|
67
|
+
const isReadOnly = context?.isReadOnly;
|
|
68
|
+
|
|
69
|
+
const dynamicFieldIdRef = useRef('');
|
|
70
|
+
|
|
71
|
+
// This takes care of updating the mapped fields count on the bottom
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (dynamicItems.length > 0) {
|
|
74
|
+
// eslint-disable-next-line array-callback-return
|
|
75
|
+
dynamicItems.map((el, index) => {
|
|
76
|
+
const ele = props.stepDataMapping[props.stepId][el.fieldId];
|
|
77
|
+
if (!ele.isDynamic && ele.value) {
|
|
78
|
+
const parsedValue = ele.value;
|
|
79
|
+
if (parsedValue) setFieldsRef((prev) => [...prev, index]);
|
|
80
|
+
} else if (ele.isDynamic && ele.objectValue && el.id) {
|
|
81
|
+
const parsedValues = ele.objectValue || {};
|
|
82
|
+
if (parsedValues[el.id]) {
|
|
83
|
+
setFieldsRef((prev) => [...prev, index]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [dynamicItems]);
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (fieldListData.length) {
|
|
92
|
+
setFieldsLoading(false);
|
|
93
|
+
}
|
|
94
|
+
}, [fieldListData]);
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const mappingField = props.templateFields.filter(
|
|
98
|
+
(el) => el.activity_field && el.activity_field.type === 'FIELD_MAPPING',
|
|
99
|
+
)[0];
|
|
100
|
+
|
|
101
|
+
if (mappingField) {
|
|
102
|
+
setSavedMappingField(mappingField);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
// fieldListData.length &&
|
|
107
|
+
fieldMappingData !== null &&
|
|
108
|
+
fieldMappingData !== undefined &&
|
|
109
|
+
Object.keys(fieldMappingData).length > 0
|
|
110
|
+
) {
|
|
111
|
+
// both field list and mapping data has been fetched
|
|
112
|
+
setLoading(false);
|
|
113
|
+
const fieldMappingResponseKey = Object.keys(fieldMappingData)[0];
|
|
114
|
+
props.setStoreState({
|
|
115
|
+
mappingInfo: {
|
|
116
|
+
...props.mappingInfo,
|
|
117
|
+
isNewMapping: true,
|
|
118
|
+
customFieldsKey: fieldMappingResponseKey,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
if (
|
|
123
|
+
fieldMappingResponseKey &&
|
|
124
|
+
Array.isArray(fieldMappingData[fieldMappingResponseKey])
|
|
125
|
+
) {
|
|
126
|
+
setDynamicItems([
|
|
127
|
+
...standardFields,
|
|
128
|
+
...fieldMappingData[fieldMappingResponseKey].map((el) => ({
|
|
129
|
+
...el,
|
|
130
|
+
isDynamic: true,
|
|
131
|
+
isVisible: mappingField.is_visible,
|
|
132
|
+
fieldId: mappingField.id,
|
|
133
|
+
})),
|
|
134
|
+
]);
|
|
135
|
+
} else {
|
|
136
|
+
setError(
|
|
137
|
+
`fieldMappingResponseKey '${fieldMappingResponseKey}' not found, custom fields are not in a nested array under a single key`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}, [fieldMappingData]);
|
|
142
|
+
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
// fetch the mapping field
|
|
145
|
+
const mappingField = props.templateFields.filter(
|
|
146
|
+
(el) => el.activity_field && el.activity_field.type === 'FIELD_MAPPING',
|
|
147
|
+
)[0];
|
|
148
|
+
|
|
149
|
+
if (mappingField) {
|
|
150
|
+
// set our dynamic list ID
|
|
151
|
+
setDynamicListId(`${mappingField.id}`);
|
|
152
|
+
} else {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// get a list of standard (TEXT) fields that will be part of the mapping
|
|
157
|
+
const standardFieldsToRender = props.templateFields
|
|
158
|
+
.filter(
|
|
159
|
+
(el) =>
|
|
160
|
+
el.activity_field &&
|
|
161
|
+
el.activity_field.type === 'TEXTFIELD' &&
|
|
162
|
+
el.is_visible && // only show visible standard fields
|
|
163
|
+
el.added_in_mapping,
|
|
164
|
+
)
|
|
165
|
+
.map((el) => ({
|
|
166
|
+
fieldId: el.id,
|
|
167
|
+
id: el.activity_field && el.activity_field.machine_name,
|
|
168
|
+
title: el.activity_field && el.activity_field.title,
|
|
169
|
+
type: 'text',
|
|
170
|
+
isDynamic: false,
|
|
171
|
+
isVisible: el.is_visible,
|
|
172
|
+
}));
|
|
173
|
+
|
|
174
|
+
setStandardFields(standardFieldsToRender);
|
|
175
|
+
|
|
176
|
+
// grab activity output data since that is used in both cases
|
|
177
|
+
if (!fieldListData.length) {
|
|
178
|
+
if (
|
|
179
|
+
mappingField.field_mapping_source &&
|
|
180
|
+
props.fieldListMapping[mappingField.field_mapping_source]
|
|
181
|
+
) {
|
|
182
|
+
setLoading(true);
|
|
183
|
+
// eslint-disable-next-line no-use-before-define
|
|
184
|
+
fetchFieldsListData(mappingField);
|
|
185
|
+
} else {
|
|
186
|
+
console.error(
|
|
187
|
+
`Field mapping source not found, expected: ${mappingField.field_mapping_source}`,
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// if dynamic field exists, fetch the fields and show those
|
|
193
|
+
if (mappingField && mappingField.activity_field) {
|
|
194
|
+
const originalMappingField =
|
|
195
|
+
props.parentChildMapping[props.stepId][
|
|
196
|
+
mappingField.activity_field.machine_name
|
|
197
|
+
];
|
|
198
|
+
|
|
199
|
+
let valuesMapField = '';
|
|
200
|
+
if (originalMappingField) {
|
|
201
|
+
const valuesMap = originalMappingField.parentFields?.reduce(
|
|
202
|
+
(prev, next) => {
|
|
203
|
+
const parentFieldId =
|
|
204
|
+
props.parentChildMapping[props.stepId][next].fieldId;
|
|
205
|
+
return {
|
|
206
|
+
...prev,
|
|
207
|
+
[parentFieldId]:
|
|
208
|
+
props.stepDataMapping[props.stepId][parentFieldId].value,
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
{},
|
|
212
|
+
);
|
|
213
|
+
valuesMapField = JSON.stringify(valuesMap);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// in case the parent field value changes, refetch the custom fields
|
|
217
|
+
if (valuesMapField !== dynamicFieldIdRef.current) {
|
|
218
|
+
setLoading(true);
|
|
219
|
+
|
|
220
|
+
// eslint-disable-next-line no-use-before-define
|
|
221
|
+
fetchAndSaveFieldMappingData(mappingField)
|
|
222
|
+
?.then(() => {
|
|
223
|
+
setFieldsRef([]);
|
|
224
|
+
setLoading(false);
|
|
225
|
+
dynamicFieldIdRef.current = valuesMapField;
|
|
226
|
+
})
|
|
227
|
+
.catch((err) => console.error(err));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}, [props.stepDataMapping[props.stepId]]);
|
|
231
|
+
|
|
232
|
+
const getStepVisibleFieldsData = (
|
|
233
|
+
stepId: number,
|
|
234
|
+
): {
|
|
235
|
+
[machineName: string]: string;
|
|
236
|
+
} => {
|
|
237
|
+
const fields = props.stepDataMapping[stepId];
|
|
238
|
+
const requiredFieldsWithValues = Object.keys(fields)
|
|
239
|
+
.filter((el) => fields[Number(el)].value)
|
|
240
|
+
.reduce((prev, curr) => {
|
|
241
|
+
const currentItem = fields[Number(curr)];
|
|
242
|
+
return {
|
|
243
|
+
...prev,
|
|
244
|
+
[currentItem.machineName]: currentItem.value,
|
|
245
|
+
};
|
|
246
|
+
}, {});
|
|
247
|
+
return requiredFieldsWithValues;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const fetchFieldsListData = (field: TemplateField) => {
|
|
251
|
+
const { stepMapping, fieldListMapping } = props;
|
|
252
|
+
|
|
253
|
+
const fieldListActivityField =
|
|
254
|
+
fieldListMapping[field.field_mapping_source || ''];
|
|
255
|
+
|
|
256
|
+
const fieldsListStepObject =
|
|
257
|
+
stepMapping && stepMapping[fieldListActivityField.stepId];
|
|
258
|
+
|
|
259
|
+
if (fieldListActivityField) {
|
|
260
|
+
const payload = {
|
|
261
|
+
authorizationId: Number(fieldsListStepObject.selectedAuthId),
|
|
262
|
+
activityFieldId: Number(fieldListActivityField.activity_field?.id),
|
|
263
|
+
endpointData:
|
|
264
|
+
getStepVisibleFieldsData(fieldListActivityField.stepId) || {},
|
|
265
|
+
};
|
|
266
|
+
return context?.apiHandler
|
|
267
|
+
.getCustomFields(payload)
|
|
268
|
+
.then((data) => {
|
|
269
|
+
if (data)
|
|
270
|
+
setFieldListData(
|
|
271
|
+
data.map((el) => ({
|
|
272
|
+
...el,
|
|
273
|
+
// sample_data: JSON.stringify(['1', '2']), // test sample data
|
|
274
|
+
})),
|
|
275
|
+
);
|
|
276
|
+
})
|
|
277
|
+
.catch((err) => {
|
|
278
|
+
console.error(err);
|
|
279
|
+
setFieldsLoading(false);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const fetchAndSaveFieldMappingData = (templateField: TemplateField) => {
|
|
286
|
+
const { stepId, stepMapping } = props;
|
|
287
|
+
const dynamicEndpoint = `${templateField.activity_field?.dynamic_field_src}`;
|
|
288
|
+
return context?.apiHandler
|
|
289
|
+
.callDynamicDataEndpoint<FieldMappingEndpointData>(
|
|
290
|
+
new URL(dynamicEndpoint),
|
|
291
|
+
{
|
|
292
|
+
authorization_id: `${stepMapping[stepId].selectedAuthId}`,
|
|
293
|
+
...getStepVisibleFieldsData(stepId),
|
|
294
|
+
},
|
|
295
|
+
)
|
|
296
|
+
.then((data) => {
|
|
297
|
+
if (data) setFieldMappingData(data);
|
|
298
|
+
return data;
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const onMappingValueSelected = (
|
|
303
|
+
index: number,
|
|
304
|
+
item: DynamicDataItem,
|
|
305
|
+
isRequired: boolean,
|
|
306
|
+
rowIndex: number,
|
|
307
|
+
) => {
|
|
308
|
+
const fieldListObject = fieldListData[index];
|
|
309
|
+
const arrayIndex = fieldsRef.findIndex((el) => el === rowIndex);
|
|
310
|
+
if (index < 0) {
|
|
311
|
+
// unset
|
|
312
|
+
setFieldsRef((prev) => prev.filter((el) => el !== rowIndex));
|
|
313
|
+
if (!item.isDynamic) {
|
|
314
|
+
props.setStepFieldData({
|
|
315
|
+
stepId: `${props.stepId}`,
|
|
316
|
+
fieldId: `${item.fieldId}`,
|
|
317
|
+
value: '',
|
|
318
|
+
isRequired,
|
|
319
|
+
});
|
|
320
|
+
} else if (dynamicListId) {
|
|
321
|
+
props.setStepMappingData({
|
|
322
|
+
stepId: props.stepId,
|
|
323
|
+
fieldId: Number(dynamicListId),
|
|
324
|
+
id: `${item.id}`,
|
|
325
|
+
value: null,
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
} else if (fieldListObject) {
|
|
329
|
+
// value is set
|
|
330
|
+
if (arrayIndex < 0) {
|
|
331
|
+
//
|
|
332
|
+
setFieldsRef((prev) => [...prev, rowIndex]);
|
|
333
|
+
}
|
|
334
|
+
if (!item.isDynamic) {
|
|
335
|
+
props.setStepFieldData({
|
|
336
|
+
stepId: `${props.stepId}`,
|
|
337
|
+
fieldId: `${item.fieldId}`,
|
|
338
|
+
value: fieldListObject.tag,
|
|
339
|
+
isRequired,
|
|
340
|
+
});
|
|
341
|
+
} else if (dynamicListId) {
|
|
342
|
+
props.setStepMappingData({
|
|
343
|
+
stepId: props.stepId,
|
|
344
|
+
fieldId: Number(dynamicListId),
|
|
345
|
+
id: `${item.id}`,
|
|
346
|
+
value: fieldListObject.tag,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
props.verifyStepValidity(props.stepId);
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
return html`
|
|
354
|
+
<div>
|
|
355
|
+
<${Label}
|
|
356
|
+
title=${savedMappingField?.title ||
|
|
357
|
+
savedMappingField?.activity_field?.title}
|
|
358
|
+
description=${savedMappingField?.description ||
|
|
359
|
+
savedMappingField?.activity_field?.description}
|
|
360
|
+
/>
|
|
361
|
+
<div>
|
|
362
|
+
${loading
|
|
363
|
+
? html`<div class=${styles.loader}><${LargeLoader} /></div>`
|
|
364
|
+
: error
|
|
365
|
+
? html` <div>${error}</div> `
|
|
366
|
+
: html`
|
|
367
|
+
<div class=${styles.mappingWrap}>
|
|
368
|
+
<div class=${styles.mappingRow}>
|
|
369
|
+
<div class=${styles.mappingHeaderItem}>
|
|
370
|
+
<img
|
|
371
|
+
src=${props.stepMapping[props.stepId].step.activity.app
|
|
372
|
+
.icon_url}
|
|
373
|
+
/>
|
|
374
|
+
<div>
|
|
375
|
+
${`${
|
|
376
|
+
props.stepMapping[props.stepId].step.activity.app.name
|
|
377
|
+
} Field`}
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
<div class=${styles.sampleData}>Sample Data</div>
|
|
381
|
+
<div class=${styles.mappingHeaderItem}>
|
|
382
|
+
<img src=${props.genericData.brandingApp?.icon_url} />
|
|
383
|
+
<div>${props.genericData.brandingApp?.name} Field</div>
|
|
384
|
+
</div>
|
|
385
|
+
${isReadOnly &&
|
|
386
|
+
html`<div class=${styles.tagColumn}>
|
|
387
|
+
</div>`}
|
|
388
|
+
</div>
|
|
389
|
+
${dynamicItems.map((el, itemIndex) => {
|
|
390
|
+
// console.log(itemIndex);
|
|
391
|
+
// console.log({ el });
|
|
392
|
+
|
|
393
|
+
if (!el.isVisible) return html``;
|
|
394
|
+
|
|
395
|
+
const slug = el.id || '';
|
|
396
|
+
const ele = props.stepDataMapping[props.stepId][el.fieldId];
|
|
397
|
+
// console.log({ ele });
|
|
398
|
+
let selectVal = '';
|
|
399
|
+
let parsedVal: string | Record<string, string | number>;
|
|
400
|
+
if (el.isDynamic) {
|
|
401
|
+
parsedVal = ele.objectValue as Record<
|
|
402
|
+
string,
|
|
403
|
+
string | number
|
|
404
|
+
>;
|
|
405
|
+
} else {
|
|
406
|
+
parsedVal = `${ele.value}`;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// console.log({ parsedVal });
|
|
410
|
+
if (
|
|
411
|
+
el.id &&
|
|
412
|
+
el.isDynamic &&
|
|
413
|
+
ele.objectValue &&
|
|
414
|
+
(parsedVal as Record<string, string | number>)[slug]
|
|
415
|
+
) {
|
|
416
|
+
selectVal = `${
|
|
417
|
+
(parsedVal as Record<string, string | number>)[slug]
|
|
418
|
+
}`;
|
|
419
|
+
} else if (!el.isDynamic) {
|
|
420
|
+
selectVal = parsedVal as string;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
let sampleData = '';
|
|
424
|
+
const rawData =
|
|
425
|
+
fieldListData.filter((field) => field.tag === selectVal)[0]
|
|
426
|
+
?.sample_data ?? '';
|
|
427
|
+
try {
|
|
428
|
+
sampleData = JSON.parse(rawData);
|
|
429
|
+
} catch (err) {
|
|
430
|
+
sampleData = rawData;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return html`
|
|
434
|
+
<div class=${styles.mappingRow}>
|
|
435
|
+
<div class=${styles.title}>
|
|
436
|
+
${el.title}${ele?.isRequired && html`<span>*</span>`}
|
|
437
|
+
</div>
|
|
438
|
+
<div class=${styles.sampleData}>
|
|
439
|
+
${sampleData
|
|
440
|
+
? Array.isArray(sampleData)
|
|
441
|
+
? sampleData.map(
|
|
442
|
+
(sample: string | Record<string, string>) =>
|
|
443
|
+
sample ? html`<pre>${sample}</pre>` : html``,
|
|
444
|
+
)
|
|
445
|
+
: html`<pre>${sampleData}</pre>`
|
|
446
|
+
: html``}
|
|
447
|
+
</div>
|
|
448
|
+
<div class=${styles.selectBox}>
|
|
449
|
+
<${Select}
|
|
450
|
+
ariaLabel="Map a value"
|
|
451
|
+
placeholder="Please map a value"
|
|
452
|
+
options=${fieldListData.map((item) => ({
|
|
453
|
+
key: item.tag,
|
|
454
|
+
label: item.text,
|
|
455
|
+
}))}
|
|
456
|
+
value=${selectVal}
|
|
457
|
+
isRequired=${ele?.isRequired}
|
|
458
|
+
showStepValidation=${props.showStepValidation}
|
|
459
|
+
showUnselectedValue=${true}
|
|
460
|
+
unselectedText="Skip"
|
|
461
|
+
loading=${fieldsLoading}
|
|
462
|
+
onChange=${(index: number) =>
|
|
463
|
+
onMappingValueSelected(
|
|
464
|
+
index,
|
|
465
|
+
el,
|
|
466
|
+
ele?.isRequired ?? false,
|
|
467
|
+
itemIndex,
|
|
468
|
+
)}
|
|
469
|
+
isReadOnly=${isReadOnly}
|
|
470
|
+
><//>
|
|
471
|
+
</div>
|
|
472
|
+
${isReadOnly &&
|
|
473
|
+
html`<div class=${styles.tagColumn}>
|
|
474
|
+
${ele.isChanged &&
|
|
475
|
+
html`<${Tag} label="Changed"/>`}
|
|
476
|
+
</div>`}
|
|
477
|
+
</div>
|
|
478
|
+
`;
|
|
479
|
+
})}
|
|
480
|
+
<div class=${styles.mappingInfo}>
|
|
481
|
+
<div>
|
|
482
|
+
<span>Mapped</span>
|
|
483
|
+
<span
|
|
484
|
+
>${fieldsRef.length}${' '}
|
|
485
|
+
field${fieldsRef.length !== 1 ? 's' : ''}</span
|
|
486
|
+
>
|
|
487
|
+
</div>
|
|
488
|
+
<div>
|
|
489
|
+
<span>Ignored</span>
|
|
490
|
+
<span
|
|
491
|
+
>${dynamicItems.length - fieldsRef.length}${' '}
|
|
492
|
+
field${dynamicItems.length - fieldsRef.length !== 1
|
|
493
|
+
? 's'
|
|
494
|
+
: ''}</span
|
|
495
|
+
>
|
|
496
|
+
</div>
|
|
497
|
+
</div>
|
|
498
|
+
</div>
|
|
499
|
+
`}
|
|
500
|
+
</div>
|
|
501
|
+
</div>
|
|
502
|
+
`;
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
export default connect<MappingUiProps, unknown, StoreType, unknown>(
|
|
506
|
+
[
|
|
507
|
+
'stepState',
|
|
508
|
+
'genericData',
|
|
509
|
+
'stepMapping',
|
|
510
|
+
'fieldListMapping',
|
|
511
|
+
'stepDataMapping',
|
|
512
|
+
'parentChildMapping',
|
|
513
|
+
],
|
|
514
|
+
actionFunctions,
|
|
515
|
+
)(NewMappingUI);
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
.mappingWrap {
|
|
2
|
+
.mappingInfo {
|
|
3
|
+
margin-top: 20px;
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: flex-end;
|
|
6
|
+
font-size: 10px;
|
|
7
|
+
line-height: 12px;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
letter-spacing: 0.1px;
|
|
11
|
+
color: #999999;
|
|
12
|
+
& > :not(:last-child) {
|
|
13
|
+
margin-right: 20px;
|
|
14
|
+
}
|
|
15
|
+
& > div {
|
|
16
|
+
margin-right: 7px;
|
|
17
|
+
& > span:first-child {
|
|
18
|
+
color: #333333;
|
|
19
|
+
margin: 0;
|
|
20
|
+
margin-right: 3px;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
& .mappingRow:first-child {
|
|
25
|
+
padding-top: 0;
|
|
26
|
+
padding-bottom: 5px;
|
|
27
|
+
height: 60px;
|
|
28
|
+
font-style: normal;
|
|
29
|
+
font-weight: normal;
|
|
30
|
+
font-size: 14px;
|
|
31
|
+
letter-spacing: 0.1px;
|
|
32
|
+
color: #333333;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.loader {
|
|
37
|
+
margin-top: 35px;
|
|
38
|
+
margin-bottom: -60px;
|
|
39
|
+
display: flex;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.mappingRow {
|
|
44
|
+
display: flex;
|
|
45
|
+
box-sizing: content-box;
|
|
46
|
+
align-items: center;
|
|
47
|
+
justify-content: space-between;
|
|
48
|
+
background-color: #fff;
|
|
49
|
+
padding-left: 10px;
|
|
50
|
+
padding-right: 10px;
|
|
51
|
+
height: 90px;
|
|
52
|
+
.title {
|
|
53
|
+
width: 40%;
|
|
54
|
+
padding-right: 4px;
|
|
55
|
+
font-weight: 500;
|
|
56
|
+
font-size: 14px;
|
|
57
|
+
color: #333333;
|
|
58
|
+
padding-right: 10px;
|
|
59
|
+
line-height: 18px;
|
|
60
|
+
white-space: nowrap;
|
|
61
|
+
overflow: hidden;
|
|
62
|
+
text-overflow: ellipsis;
|
|
63
|
+
span {
|
|
64
|
+
color: red;
|
|
65
|
+
font-size: 16px;
|
|
66
|
+
margin-left: 2px;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
.sampleData {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
width: 40%;
|
|
73
|
+
overflow: hidden;
|
|
74
|
+
word-break: break-word;
|
|
75
|
+
padding-right: 20px;
|
|
76
|
+
}
|
|
77
|
+
.selectBox {
|
|
78
|
+
width: 40%;
|
|
79
|
+
font-size: 14px;
|
|
80
|
+
}
|
|
81
|
+
&:nth-child(even) {
|
|
82
|
+
background: #f8f8f880;
|
|
83
|
+
}
|
|
84
|
+
&:first-child {
|
|
85
|
+
color: #333333;
|
|
86
|
+
}
|
|
87
|
+
.mappingHeaderItem {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
width: 40%;
|
|
91
|
+
&:first-child {
|
|
92
|
+
padding-right: 4px;
|
|
93
|
+
}
|
|
94
|
+
img {
|
|
95
|
+
height: 25px;
|
|
96
|
+
width: 25px;
|
|
97
|
+
padding: 2px;
|
|
98
|
+
object-fit: contain;
|
|
99
|
+
border-radius: 9999px;
|
|
100
|
+
margin-right: 5px;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
pre {
|
|
104
|
+
margin: 0;
|
|
105
|
+
padding: 0;
|
|
106
|
+
color: #7d7d7d;
|
|
107
|
+
height: 20px;
|
|
108
|
+
font-size: 14px;
|
|
109
|
+
line-height: 20px;
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
text-overflow: ellipsis;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { html } from 'htm/preact';
|
|
2
|
+
import { connect } from 'unistore/preact';
|
|
3
|
+
import { useState } from 'preact/hooks';
|
|
4
|
+
import { actionFunctions } from '@/store';
|
|
5
|
+
import { StoreType } from '@/types/store';
|
|
6
|
+
import { Modal } from '@/components/Modal';
|
|
7
|
+
import { SuccessPopUp } from '@/components/PopUp/SuccessPopUp';
|
|
8
|
+
import RequestAppForm from '../request-app-form';
|
|
9
|
+
import styles from './styles.module.scss';
|
|
10
|
+
|
|
11
|
+
type RequestAppModalProps = StoreType
|
|
12
|
+
|
|
13
|
+
const RequestAppModal = (props: RequestAppModalProps) => {
|
|
14
|
+
const [showSuccessPopUp, setShowSuccessPopUp] = useState(false);
|
|
15
|
+
|
|
16
|
+
const handleCloseRequestAppModal = () => {
|
|
17
|
+
props.setStoreState({
|
|
18
|
+
showRequestAppModal: false,
|
|
19
|
+
requestAppFormData: {},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const handleSuccess = () => {
|
|
24
|
+
props.setStoreState({
|
|
25
|
+
showRequestAppModal: false,
|
|
26
|
+
requestAppFormData: {},
|
|
27
|
+
});
|
|
28
|
+
setShowSuccessPopUp(true);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const handleClosePopUp = () => {
|
|
32
|
+
setShowSuccessPopUp(false);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return html`
|
|
36
|
+
<${Modal}
|
|
37
|
+
isOpen=${props.showRequestAppModal}
|
|
38
|
+
onClose=${handleCloseRequestAppModal}
|
|
39
|
+
className="request-app-modal"
|
|
40
|
+
>
|
|
41
|
+
<div class="${styles.modalSetup} ${'integry-container__request-app-modal'}">
|
|
42
|
+
<div class=${styles.modalHeader}>
|
|
43
|
+
<div class="${styles.modalTitle}">${'Tell us more'}</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="${styles.modalContentWrap}">
|
|
46
|
+
<${RequestAppForm} onSuccess=${handleSuccess} />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<//>
|
|
50
|
+
${showSuccessPopUp && html`
|
|
51
|
+
<${SuccessPopUp}
|
|
52
|
+
isOpen=${showSuccessPopUp}
|
|
53
|
+
title="Request Sent"
|
|
54
|
+
description="We will work hard to make this app available in our marketplace. Thanks for your suggestion!"
|
|
55
|
+
buttonLabel="OK"
|
|
56
|
+
handleButtonClick=${handleClosePopUp}
|
|
57
|
+
/>
|
|
58
|
+
`
|
|
59
|
+
}`;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default connect<RequestAppModalProps, unknown, StoreType, unknown>(
|
|
63
|
+
[
|
|
64
|
+
'showRequestAppModal',
|
|
65
|
+
],
|
|
66
|
+
actionFunctions,
|
|
67
|
+
)(RequestAppModal);
|