= (\r\n props,\r\n defaultRender\r\n ) => {\r\n if (!props) {\r\n return null;\r\n }\r\n const onRenderColumnHeaderTooltip: IRenderFunction<\r\n IDetailsColumnRenderTooltipProps\r\n > = (tooltipHostProps) => ;\r\n return (\r\n \r\n {defaultRender!({\r\n ...props,\r\n onRenderColumnHeaderTooltip,\r\n })}\r\n \r\n );\r\n };\r\n\r\n const loadTargetFieldList = (layout: ILayout[]) => {\r\n let items: any = []\r\n\r\n items = Object.entries(MapOutputSurrogateField).map((item) => {\r\n return { text: item[0], key: item[1] as string };\r\n });\r\n\r\n if (props.eventType.trim() === EventType.OnClick) {\r\n items = items.concat(\r\n layout.map((item) => {\r\n return { text: item.Label, key: item.Id };\r\n })\r\n );\r\n }\r\n\r\n let identifierKeyTypes: { text: string; key: string; disabled: boolean }[] = [];\r\n Object.entries(IdentifierKeyType).forEach((item) => {\r\n const listValue = getValues(\"mapOutputMapPropsList\").find((item: any) => item.TargetField.key === IdentifierKeyType.Identifier1)\r\n if ((item[0] as string) === IdentifierKeyType.Identifier1) {\r\n identifierKeyTypes.push({ text: item[0], key: item[1] as string, disabled: listValue === undefined ? false : true })\r\n setSelectedIdentifierKeyName((currentValue: SelectedIdentifierKeyName) => {\r\n return { ...currentValue, IdentifierKeyName1: listValue === undefined ? false : true }\r\n })\r\n }\r\n });\r\n\r\n items = items.concat(identifierKeyTypes)\r\n\r\n setTargetFieldList(items);\r\n };\r\n\r\n const resetIdentifierKeyName = (id: any) => {\r\n setValue(id, \"\")\r\n }\r\n\r\n const hasIdentifierSelected = (index: number, newValue?: string): boolean => {\r\n let rows = getValues(\"mapOutputMapPropsList\")\r\n\r\n let isValidTheOneAlreadyExisted = false;\r\n\r\n rows.forEach((element: any) => {\r\n if ((element.TargetField.key === IdentifierKeyType.Identifier1 ||\r\n element.TargetField.key === IdentifierKeyType.Identifier2 ||\r\n element.TargetField.key === IdentifierKeyType.Identifier3) &&\r\n element.IdentifierKeyName.length > 0) {\r\n isValidTheOneAlreadyExisted = true;\r\n }\r\n });\r\n\r\n if (isValidTheOneAlreadyExisted) {\r\n return isValidTheOneAlreadyExisted;\r\n } else {\r\n if ((rows[index].TargetField.key === IdentifierKeyType.Identifier1 ||\r\n rows[index].TargetField.key === IdentifierKeyType.Identifier2 ||\r\n rows[index].TargetField.key === IdentifierKeyType.Identifier3)) {\r\n\r\n const identifierKeyName = newValue !== undefined ? newValue : rows[index].IdentifierKeyName\r\n if (identifierKeyName.length > 0) {\r\n return true\r\n } else {\r\n return false\r\n }\r\n } else {\r\n return true\r\n }\r\n }\r\n }\r\n\r\n return (\r\n \r\n \r\n item)}\r\n columns={[\r\n {\r\n key: \"Path\",\r\n name: \"Path\",\r\n fieldName: \"Path\",\r\n minWidth: 100,\r\n maxWidth: 200,\r\n isResizable: true,\r\n onRender: (item, index, column) => {\r\n return (\r\n , newValue: string) => {\r\n if (index === mapOutputMapPropsList.fields.length - 1 &&\r\n newValue.length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== undefined &&\r\n getValues(\"mapOutputMapPropsList\")[index].Index.toString().length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== undefined &&\r\n hasIdentifierSelected(index)) {\r\n mapOutputMapPropsList.append(Const_MapProps);\r\n }\r\n }}\r\n />\r\n );\r\n },\r\n },\r\n {\r\n key: \"ValueType\",\r\n name: \"Value Type\",\r\n fieldName: \"ValueType\",\r\n minWidth: 50,\r\n maxWidth: 100,\r\n isResizable: true,\r\n onRender: (item, index, column) => {\r\n return (\r\n {\r\n return {\r\n text: item[0],\r\n key: item[1],\r\n };\r\n })}\r\n disabled={props.isConfigurationTemplateReadMode ? true : false}\r\n title=\"Select param type.\"\r\n control={control}\r\n setValue={setValue}\r\n getValues={getValues}\r\n trigger={trigger}\r\n onCallback={(event: React.FormEvent, option?: | IDropdownOption | undefined, dropdownIndex?: number | undefined) => {\r\n if (index === mapOutputMapPropsList.fields.length - 1 &&\r\n getValues(\"mapOutputMapPropsList\")[index].Path.length > 0 &&\r\n option !== undefined &&\r\n getValues(\"mapOutputMapPropsList\")[index].Index.toString().length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== undefined &&\r\n hasIdentifierSelected(index)) {\r\n mapOutputMapPropsList.append(Const_MapProps);\r\n }\r\n }}\r\n />\r\n );\r\n },\r\n },\r\n {\r\n key: \"Index\",\r\n name: \"Index\",\r\n fieldName: \"Index\",\r\n minWidth: 25,\r\n maxWidth: 50,\r\n isResizable: true,\r\n onRender: (item, index, column) => {\r\n return (\r\n , newValue: string) => {\r\n if (index === mapOutputMapPropsList.fields.length - 1 &&\r\n getValues(\"mapOutputMapPropsList\")[index].Path.length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== undefined &&\r\n newValue.length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== undefined &&\r\n hasIdentifierSelected(index)) {\r\n mapOutputMapPropsList.append(Const_MapProps);\r\n }\r\n }}\r\n />\r\n );\r\n },\r\n },\r\n // {\r\n // key: 'TargetField',\r\n // name: 'TargetField',\r\n // fieldName: 'TargetField',\r\n // minWidth: 100,\r\n // maxWidth: 200,\r\n // isResizable: false,\r\n // onRender: (item, index, column) => {\r\n // return , newValue: string) => {\r\n // if (index === mapOutputMapPropsList.fields.length - 1 && getValues(\"mapOutputMapPropsList\")[index].Path.length > 0 && getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== undefined && getValues(\"mapOutputMapPropsList\")[index].Index.toString().length > 0 && newValue.length > 0) {\r\n // mapOutputMapPropsList.append(Const_MapProps)\r\n // }\r\n // }}\r\n // />\r\n // }\r\n // },\r\n {\r\n key: \"TargetField\",\r\n name: \"TargetField\",\r\n fieldName: \"Target Field\",\r\n minWidth: 80,\r\n maxWidth: 150,\r\n isResizable: true,\r\n onRender: (item, index, column) => {\r\n return (\r\n , option?: | IDropdownOption | undefined, dropdownIndex?: number | undefined) => {\r\n if (index === mapOutputMapPropsList.fields.length - 1 &&\r\n getValues(\"mapOutputMapPropsList\")[index].Path.length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== undefined &&\r\n getValues(\"mapOutputMapPropsList\")[index].Index.toString().length > 0 &&\r\n option !== undefined &&\r\n hasIdentifierSelected(index)) {\r\n mapOutputMapPropsList.append(Const_MapProps);\r\n }\r\n\r\n if (option?.key === IdentifierKeyType.Identifier1) {\r\n setSelectedIdentifierKeyName((currentValue: SelectedIdentifierKeyName) => {\r\n return { ...currentValue, IdentifierKeyName1: !currentValue.IdentifierKeyName1 }\r\n })\r\n } else {\r\n setSelectedIdentifierKeyName((currentValue: SelectedIdentifierKeyName) => {\r\n return getValues(\"mapOutputMapPropsList\").reduce((prev: SelectedIdentifierKeyName, current: any) => {\r\n if (current.TargetField.key === IdentifierKeyType.Identifier1) {\r\n return { ...prev, IdentifierKeyName1: true }\r\n }\r\n return prev\r\n }, defualtValue)\r\n\r\n\r\n\r\n\r\n })\r\n }\r\n\r\n\r\n\r\n /*setTargetFieldList((targetFieldList: any) => {\r\n return targetFieldList.map((item: any) => {\r\n if ( item.text === IdentifierKeyType.IdentifierKeyName1) {\r\n return { ...item, disabled: selectedIdentifierKeyName.IdentifierKeyName1 }\r\n }\r\n return item\r\n })\r\n })*/\r\n resetIdentifierKeyName(`mapOutputMapPropsList.${index}.IdentifierKeyName`)\r\n setUpdateIdentifierKeyNameColumn(!updateIdentifierKeyNameColumn)\r\n\r\n }}\r\n />\r\n );\r\n },\r\n },\r\n {\r\n key: 'IsHeader',\r\n name: 'Use Header',\r\n fieldName: 'IsHeader',\r\n minWidth: 61,\r\n maxWidth: 61,\r\n isResizable: true,\r\n onRender: (item, index, column) => {\r\n return \r\n }\r\n },\r\n // {\r\n // key: 'Output',\r\n // name: 'Output',\r\n // fieldName: 'Output',\r\n // minWidth: 25,\r\n // maxWidth: 50,\r\n // isResizable: false,\r\n // onRender: (item, index, column) => {\r\n // return \r\n // }\r\n // },\r\n {\r\n key: 'identifierKeyName',\r\n name: 'IdentifierKeyName',\r\n fieldName: 'IdentifierKeyName',\r\n minWidth: 125, maxWidth: 125,\r\n isResizable: true,\r\n onRender: (item, index, column) => {\r\n const id: any = `mapOutputMapPropsList.${index}.TargetField`\r\n if (getValues(id) !== \"\" && (getValues(id).key === IdentifierKeyType.Identifier1 || getValues(id).key === IdentifierKeyType.Identifier2 || getValues(id).key === IdentifierKeyType.Identifier3)) {\r\n return , newValue: string) => {\r\n if (index === mapOutputMapPropsList.fields.length - 1 &&\r\n getValues(\"mapOutputMapPropsList\")[index].Path.length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].ValueType.key !== undefined &&\r\n getValues(\"mapOutputMapPropsList\")[index].Index.toString().length > 0 &&\r\n getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== \"\" && getValues(\"mapOutputMapPropsList\")[index].TargetField.key !== undefined &&\r\n\r\n hasIdentifierSelected(index, newValue)) {\r\n //newValue !== \"\") {\r\n mapOutputMapPropsList.append(Const_MapProps);\r\n }\r\n }}\r\n />\r\n } else {\r\n return null\r\n }\r\n }\r\n },\r\n {\r\n key: \"actions\",\r\n name: \"Actions\",\r\n onRender: (item?: any, index?: number) => {\r\n return (\r\n {\r\n mapOutputMapPropsList.remove(index!);\r\n if ((index === 0 && mapOutputMapPropsList.fields.length - 1 === 0) ||\r\n index === mapOutputMapPropsList.fields.length - 1) {\r\n mapOutputMapPropsList.append(Const_MapProps);\r\n }\r\n }}\r\n iconProps={{ iconName: \"Delete\" }}\r\n title=\"Delete\"\r\n ariaLabel=\"Delete\"\r\n />\r\n );\r\n },\r\n minWidth: 60,\r\n maxWidth: 60,\r\n isResizable: false,\r\n },\r\n ]}\r\n selectionMode={SelectionMode.none}\r\n dragDropEvents={dragDropEvents}\r\n ariaLabelForSelectionColumn=\"Toggle selection\"\r\n ariaLabelForSelectAllCheckbox=\"Toggle selection for all items\"\r\n checkButtonAriaLabel=\"select row\"\r\n />\r\n \r\n
\r\n );\r\n};\r\n","import React from \"react\";\r\nimport { useFormContext } from \"react-hook-form\";\r\nimport { Pivot, PivotItem } from \"@fluentui/react\";\r\nimport { RHFTextBoxAreaControl } from \"../../../RHFControls/RHFTextBoxAreaControl\";\r\nimport { RHFChoiceGroupControl } from \"../../../RHFControls/RHFChoiceGroupControl\";\r\nimport { MapOutputResponseType } from \"../../Models/Enums\";\r\nimport { MapOutputMapPropsList } from \"./MapOutputMapPropsList\";\r\n\r\nexport interface MapOutputProps {\r\n templateId: number;\r\n eventType: string;\r\n isConfigurationTemplateReadMode?: boolean;\r\n}\r\n\r\nexport const MapOutput = (props: MapOutputProps) => {\r\n const { getValues, control, setValue, trigger } = useFormContext();\r\n\r\n return (\r\n <>\r\n {\r\n return { text: item[0], key: item[1], styles: { field: { marginRight: \"10px\" } } }\r\n })}\r\n control={control}\r\n setValue={setValue}\r\n getValues={getValues}\r\n trigger={trigger}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n >\r\n );\r\n};","import React, { useEffect, useState } from \"react\";\r\nimport { ConstrainMode, DetailsList, DetailsListLayoutMode, IconButton, IDetailsColumnRenderTooltipProps, IDetailsHeaderProps, IDragDropEvents, IDropdownOption, IRenderFunction, ScrollablePane, ScrollbarVisibility, SelectionMode, Sticky, StickyPositionType, TooltipHost } from \"@fluentui/react\";\r\nimport { useFieldArray, useFormContext } from \"react-hook-form\";\r\nimport { RHFTextBoxControl } from \"../../../RHFControls/RHFTextBoxControl\";\r\nimport { Const_SurrogateFilter } from \"../../Models/Consts\";\r\nimport { RHFDropDownListSingleSelectControl } from \"../../../RHFControls/RHFDropDownListSingleSelectControl\";\r\nimport Helper from \"../../../../Helpers/Helper\";\r\nimport OutboundServices from \"../../Services/OutboundServices\";\r\nimport _ from \"lodash\";\r\nimport { RHFCheckBoxControl } from \"../../../RHFControls/RHFChekBoxControl\";\r\nimport { useBoolean } from \"@fluentui/react-hooks\";\r\n\r\nexport interface SurrogateFilters {\r\n templateId: number;\r\n outboundIntegrationId: number;\r\n isConfigurationTemplateReadMode?: boolean;\r\n}\r\n\r\nexport const SurrogateFilters = (props: SurrogateFilters) => {\r\n const { control, setValue, getValues, trigger, register, resetField, unregister } = useFormContext();\r\n const [outboundIntegrations, setOutboundIntegrations] = useState([])\r\n const [isMapInputKeyNameHidden, { setTrue: hideMapInputKeyName, setFalse: showMapInputKeyName }] = useBoolean(true);\r\n const surrogateFiltersList = useFieldArray({ control, name: \"surrogateFiltersList\" });\r\n\r\n useEffect(() => {\r\n loadIntegrations()\r\n }, [])\r\n\r\n useEffect(() => {\r\n if (getValues(\"MapInputUseParentSurrogateSubrecord\") === undefined) {\r\n hideMapInputKeyName()\r\n } else {\r\n getValues(\"MapInputUseParentSurrogateSubrecord\") ? showMapInputKeyName() : hideMapInputKeyName()\r\n }\r\n }, [isMapInputKeyNameHidden])\r\n\r\n useEffect(() => {\r\n\r\n }, [surrogateFiltersList.fields])\r\n\r\n const loadIntegrations = async () => {\r\n let path = await Helper.getSite()\r\n OutboundServices.GetEvents({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n TemplateId: props.templateId,\r\n UserName: Helper.getUsername(),\r\n }).then(res => {\r\n if (res.length > 0) {\r\n let tempOutboundIntegrations: IDropdownOption[] = [];\r\n res.forEach(event => {\r\n event.Integrations.forEach(integration => {\r\n tempOutboundIntegrations.push({\r\n key: integration.Id!.toString(),\r\n text: `(${event.Name}) ${integration.Name!} (${integration.Description})`\r\n })\r\n })\r\n })\r\n setOutboundIntegrations(tempOutboundIntegrations)\r\n } else {\r\n setOutboundIntegrations([])\r\n }\r\n })\r\n }\r\n\r\n const getDragDropEvents = () => {\r\n return {\r\n canDrop: (dropContext: any, dragContext?: any) => {\r\n return true;\r\n },\r\n canDrag: (item?: any) => {\r\n return true;\r\n },\r\n onDrop: (item?: any, event?: DragEvent) => {\r\n if (draggedItem) {\r\n\r\n insertBeforeItem(item);\r\n }\r\n },\r\n onDragStart: (\r\n item?: any,\r\n itemIndex?: number,\r\n selectedItems?: any[],\r\n event?: MouseEvent\r\n ) => {\r\n if (typeof item.startIndex === \"undefined\") {\r\n // skip group item\r\n draggedItem = item;\r\n draggedIndex = itemIndex!;\r\n }\r\n },\r\n onDragEnd: (item?: any, event?: DragEvent) => {\r\n draggedItem = undefined;\r\n draggedIndex = -1;\r\n }\r\n };\r\n };\r\n\r\n const dragDropEvents: IDragDropEvents = getDragDropEvents();\r\n let draggedItem: any | undefined;\r\n let draggedIndex: number = -1;\r\n\r\n const insertBeforeItem = (item: any): void => {\r\n surrogateFiltersList.move(draggedIndex, surrogateFiltersList.fields.indexOf(item))\r\n };\r\n\r\n const onRenderDetailsHeader: IRenderFunction = (props, defaultRender) => {\r\n if (!props) {\r\n return null;\r\n }\r\n const onRenderColumnHeaderTooltip: IRenderFunction = tooltipHostProps => (\r\n \r\n );\r\n return (\r\n \r\n {defaultRender!({\r\n ...props,\r\n onRenderColumnHeaderTooltip,\r\n })}\r\n \r\n );\r\n };\r\n\r\n const onMapInputUseParentSurrogateSubrecordChange = (ev?: React.FormEvent | undefined, checked?: boolean | undefined): void => {\r\n if (checked) {\r\n resetField(\"MapInputFilterKeyName\")\r\n register(\"MapInputFilterKeyName\", { required: \"Key Name is required.\" })\r\n showMapInputKeyName()\r\n } else {\r\n resetField(\"MapInputFilterKeyName\")\r\n unregister(\"MapInputFilterKeyName\")\r\n hideMapInputKeyName()\r\n }\r\n };\r\n\r\n return (\r\n <>\r\n \r\n {isMapInputKeyNameHidden ? null :\r\n }\r\n \r\n \r\n item)}\r\n columns={[\r\n {\r\n key: 'FilterName',\r\n name: 'Name',\r\n fieldName: 'FilterName',\r\n minWidth: 250,\r\n maxWidth: 250,\r\n isResizable: false,\r\n onRender: (item, index, column) => {\r\n return , newValue: string) => {\r\n if (index === surrogateFiltersList.fields.length - 1 && newValue.length > 0 && getValues(\"surrogateFiltersList\")[index].IntegrationId.key !== undefined) {\r\n surrogateFiltersList.append(Const_SurrogateFilter)\r\n }\r\n }}\r\n />\r\n }\r\n },\r\n {\r\n key: 'IntegrationId',\r\n name: 'Integration',\r\n fieldName: 'IntegrationId',\r\n minWidth: 400,\r\n maxWidth: 400,\r\n isResizable: false,\r\n onRender: (item, index, column) => {\r\n return , option?: IDropdownOption | undefined, dropdownIndex?: number | undefined) => {\r\n if (index === surrogateFiltersList.fields.length - 1 && getValues(\"surrogateFiltersList\")[index].FilterName.length > 0 && option !== undefined) {\r\n surrogateFiltersList.append(Const_SurrogateFilter)\r\n }\r\n }}\r\n />\r\n }\r\n },\r\n /*{\r\n key: 'SortOrder',\r\n name: 'SortOrder',\r\n fieldName: 'SortOrder',\r\n minWidth: 100, maxWidth: 200,\r\n isResizable: false,\r\n onRender: (item, index, column) => {\r\n return , newValue: string) => {\r\n if (index === surrogateFiltersList.fields.length - 1 && getValues(\"surrogateFiltersList\")[index].Key.length > 0 && newValue.length >= 0) {\r\n surrogateFiltersList.append(Const_SurrogateFilter)\r\n }\r\n }}\r\n id={`mapInputVariableList.${index}.SortOrder`}\r\n disabled={false}\r\n title=\"Enter variable value.\"\r\n control={control}\r\n setValue={setValue}\r\n getValues={getValues}\r\n trigger={trigger}\r\n defaultValue={\"\"}\r\n />\r\n }\r\n },\r\n {\r\n key: 'RecordFilter',\r\n name: 'RecordFilter',\r\n fieldName: 'RecordFilter',\r\n minWidth: 100, maxWidth: 200,\r\n isResizable: false,\r\n onRender: (item, index, column) => {\r\n return , newValue: string) => {\r\n if (index === surrogateFiltersList.fields.length - 1 && getValues(\"surrogateFiltersList\")[index].Key.length > 0 && newValue.length >= 0) {\r\n surrogateFiltersList.append(Const_SurrogateFilter)\r\n }\r\n }}\r\n id={`mapInputVariableList.${index}.RecordFilter`}\r\n disabled={false}\r\n title=\"Enter variable value.\"\r\n control={control}\r\n setValue={setValue}\r\n getValues={getValues}\r\n trigger={trigger}\r\n defaultValue={\"\"}\r\n />\r\n }\r\n },\r\n {\r\n key: 'SourceRecordId',\r\n name: 'SourceRecordId',\r\n fieldName: 'SourceRecordId',\r\n minWidth: 100, maxWidth: 200,\r\n isResizable: false,\r\n onRender: (item, index, column) => {\r\n return , newValue: string) => {\r\n if (index === surrogateFiltersList.fields.length - 1 && getValues(\"surrogateFiltersList\")[index].Key.length > 0 && newValue.length >= 0) {\r\n surrogateFiltersList.append(Const_SurrogateFilter)\r\n }\r\n }}\r\n id={`mapInputVariableList.${index}.SourceRecordId`}\r\n disabled={false}\r\n title=\"Enter variable value.\"\r\n control={control}\r\n setValue={setValue}\r\n getValues={getValues}\r\n trigger={trigger}\r\n defaultValue={\"\"}\r\n />\r\n }\r\n },*/\r\n {\r\n key: 'actions',\r\n name: 'Actions',\r\n onRender: (item?: any, index?: number) => {\r\n return {\r\n surrogateFiltersList.remove(index!)\r\n if ((index === 0 && surrogateFiltersList.fields.length - 1 === 0) || index === surrogateFiltersList.fields.length - 1) {\r\n surrogateFiltersList.append(Const_SurrogateFilter)\r\n }\r\n }} iconProps={{ iconName: 'Delete' }} title=\"Delete\" ariaLabel=\"Delete\" />\r\n },\r\n minWidth: 100,\r\n maxWidth: 100,\r\n isResizable: false\r\n }\r\n ]}\r\n selectionMode={SelectionMode.none}\r\n dragDropEvents={dragDropEvents}\r\n ariaLabelForSelectionColumn=\"Toggle selection\"\r\n ariaLabelForSelectAllCheckbox=\"Toggle selection for all items\"\r\n checkButtonAriaLabel=\"select row\"\r\n />\r\n \r\n
\r\n >\r\n );\r\n};","import { ConstrainMode, DetailsList, DetailsListLayoutMode, IconButton, IDetailsColumnRenderTooltipProps, IDetailsHeaderProps, IDragDropEvents, IRenderFunction, ScrollablePane, ScrollbarVisibility, SelectionMode, Sticky, StickyPositionType, TooltipHost } from '@fluentui/react';\r\nimport React, { useEffect } from 'react';\r\nimport { useFieldArray, useFormContext } from 'react-hook-form';\r\nimport { RHFTextBoxControl } from '../../../RHFControls/RHFTextBoxControl';\r\nimport { Const_Header } from '../../Models/Consts';\r\n\r\nexport interface MapInputVariableListProps {\r\n isConfigurationTemplateReadMode?: boolean;\r\n}\r\n\r\nfunction MapInputVariableList(props: MapInputVariableListProps) {\r\n const { control, setValue, getValues, trigger } = useFormContext();\r\n const mapInputVariableList = useFieldArray(\r\n {\r\n control,\r\n name: \"mapInputVariableList\"\r\n }\r\n );\r\n\r\n useEffect(() => {\r\n\r\n }, [mapInputVariableList.fields])\r\n\r\n const getDragDropEvents = () => {\r\n return {\r\n canDrop: (dropContext: any, dragContext?: any) => {\r\n return true;\r\n },\r\n canDrag: (item?: any) => {\r\n return true;\r\n },\r\n onDrop: (item?: any, event?: DragEvent) => {\r\n if (draggedItem) {\r\n\r\n insertBeforeItem(item);\r\n }\r\n },\r\n onDragStart: (\r\n item?: any,\r\n itemIndex?: number,\r\n selectedItems?: any[],\r\n event?: MouseEvent\r\n ) => {\r\n if (typeof item.startIndex === \"undefined\") {\r\n // skip group item\r\n draggedItem = item;\r\n draggedIndex = itemIndex!;\r\n }\r\n },\r\n onDragEnd: (item?: any, event?: DragEvent) => {\r\n draggedItem = undefined;\r\n draggedIndex = -1;\r\n }\r\n };\r\n };\r\n\r\n const dragDropEvents: IDragDropEvents = getDragDropEvents();\r\n let draggedItem: any | undefined;\r\n let draggedIndex: number = -1;\r\n\r\n const insertBeforeItem = (item: any): void => {\r\n mapInputVariableList.move(draggedIndex, mapInputVariableList.fields.indexOf(item))\r\n };\r\n\r\n const onRenderDetailsHeader: IRenderFunction = (props, defaultRender) => {\r\n if (!props) {\r\n return null;\r\n }\r\n const onRenderColumnHeaderTooltip: IRenderFunction = tooltipHostProps => (\r\n \r\n );\r\n return (\r\n \r\n {defaultRender!({\r\n ...props,\r\n onRenderColumnHeaderTooltip,\r\n })}\r\n \r\n );\r\n };\r\n\r\n return (\r\n \r\n \r\n item)}\r\n columns={[\r\n {\r\n key: 'key',\r\n name: 'Name',\r\n fieldName: 'Key',\r\n minWidth: 100,\r\n maxWidth: 200,\r\n isResizable: false,\r\n onRender: (item, index, column) => {\r\n return , newValue: string) => {\r\n if (index === mapInputVariableList.fields.length - 1 && newValue.length > 0 && getValues(\"mapInputVariableList\")[index].Value.length >= 0) {\r\n mapInputVariableList.append(Const_Header)\r\n }\r\n }}\r\n />\r\n }\r\n },\r\n {\r\n key: 'value',\r\n name: 'Value',\r\n fieldName: 'Value',\r\n minWidth: 100, maxWidth: 200,\r\n isResizable: false,\r\n onRender: (item, index, column) => {\r\n return , newValue: string) => {\r\n if (index === mapInputVariableList.fields.length - 1 && getValues(\"mapInputVariableList\")[index].Key.length > 0 && newValue.length >= 0) {\r\n mapInputVariableList.append(Const_Header)\r\n }\r\n }}\r\n id={`mapInputVariableList.${index}.Value`}\r\n disabled={props.isConfigurationTemplateReadMode ? true : false}\r\n title=\"Enter variable value.\"\r\n control={control}\r\n setValue={setValue}\r\n getValues={getValues}\r\n trigger={trigger}\r\n defaultValue={\"\"}\r\n />\r\n }\r\n },\r\n {\r\n key: 'actions',\r\n name: 'Actions',\r\n onRender: (item?: any, index?: number) => {\r\n return {\r\n mapInputVariableList.remove(index!)\r\n if ((index === 0 && mapInputVariableList.fields.length - 1 === 0) || index === mapInputVariableList.fields.length - 1) {\r\n mapInputVariableList.append(Const_Header)\r\n }\r\n }} iconProps={{ iconName: 'Delete' }} title=\"Delete\" ariaLabel=\"Delete\" />\r\n },\r\n minWidth: 100,\r\n maxWidth: 100,\r\n isResizable: false\r\n }\r\n ]}\r\n selectionMode={SelectionMode.none}\r\n dragDropEvents={dragDropEvents}\r\n ariaLabelForSelectionColumn=\"Toggle selection\"\r\n ariaLabelForSelectAllCheckbox=\"Toggle selection for all items\"\r\n checkButtonAriaLabel=\"select row\"\r\n />\r\n \r\n
\r\n )\r\n}\r\n\r\nexport default MapInputVariableList","import { Pivot, PivotItem } from \"@fluentui/react/lib/Pivot\";\r\nimport React, { useEffect, useState } from \"react\";\r\nimport MapInputVariableList from \"../Body/MapInputVariableList\";\r\nimport { ActionButton, Spinner, SpinnerSize, Stack } from \"@fluentui/react\";\r\nimport OutboundService from \"../../../../services/outbound\";\r\nimport { useBoolean } from \"@fluentui/react-hooks\";\r\nimport TestIntegrationModal from \"../../TestIntegrationModal\";\r\nimport { useFormContext } from \"react-hook-form\";\r\nimport { RHFCheckBoxControl } from \"../../../RHFControls/RHFChekBoxControl\";\r\nimport { CreateOutboundIntegration, MapInputHeader, OutboundIntegrationModel, UpdateOutboundIntegration } from \"../../Models/OutboundIntegrationModel\";\r\nimport { IExternalControl } from \"../../../../interfaces/IOutbound\";\r\n\r\ninterface TestReleaseProps {\r\n TemplateId: number;\r\n IntegrationId: number;\r\n onChangeApprovedStatus: (ev?: React.FormEvent | undefined, checked?: boolean | undefined) => Promise;\r\n getUpdatedOutboundIntegration: () => Promise;\r\n showErrorMessageIntegration: (message: string) => void;\r\n ApproveStatus: boolean;\r\n callApprovedStatus: (checked: boolean) => Promise;\r\n loadOutboundIntegrationValues: (testOutboundIntegration?: OutboundIntegrationModel) => void;\r\n isConfigurationTemplateReadMode?: boolean;\r\n}\r\n\r\nconst TestRelease = (props: TestReleaseProps) => {\r\n const { TemplateId, IntegrationId, onChangeApprovedStatus, getUpdatedOutboundIntegration, showErrorMessageIntegration, ApproveStatus, callApprovedStatus } = props;\r\n const [modalContent, setModalContent] = useState(null);\r\n const [isLoadingTest, setIsLoadingTest] = useState(false);\r\n const [isDisableApprove, setIsDisableApprove] = useState(true);\r\n const [resetCheckbox, setResetCheckbox] = useState(false);\r\n const { control, setValue, getValues, trigger, handleSubmit } =\r\n useFormContext();\r\n const [\r\n isIntegrationTestModalOpen,\r\n {\r\n setTrue: showIntegrationTestModal,\r\n setFalse: hideIntegrationTestModal,\r\n },\r\n ] = useBoolean(false);\r\n\r\n const getVariables = (): IExternalControl[] => {\r\n let mapInputVariableList: MapInputHeader[] = [];\r\n let externalControls: IExternalControl[] = [];\r\n mapInputVariableList = getValues(\"mapInputVariableList\");\r\n mapInputVariableList.forEach((variable) => {\r\n if (variable.Key !== \"\") {\r\n externalControls = [\r\n ...externalControls,\r\n {\r\n ContentControl: variable.Key.replace(/\\[/g, \"\")\r\n .replace(/\\]/g, \"\")\r\n .replace(/\\$/g, \"\"),\r\n Value: variable.Value,\r\n },\r\n ];\r\n }\r\n });\r\n return externalControls;\r\n };\r\n\r\n const execute = () => {\r\n setIsLoadingTest(true);\r\n handleSubmit(\r\n async (data) => {\r\n const hola = await getUpdatedOutboundIntegration();\r\n OutboundService.UpdateIntegration(\r\n hola//await getUpdatedOutboundIntegration()\r\n ).then(({ data }) => {\r\n if (\r\n data.Success !== undefined &&\r\n data.Success !== null &&\r\n data.Success === true\r\n ) {\r\n OutboundService.ExecuteIntegration({\r\n IntegrationId,\r\n TemplateId,\r\n ExternalControls: getVariables(),\r\n }).then(({ data }) => {\r\n showIntegrationTestModal();\r\n setModalContent(data);\r\n setIsLoadingTest(false);\r\n });\r\n } else {\r\n let errorMessage =\r\n data.ExceptionMessage !== undefined &&\r\n data.ExceptionMessage !== \"\"\r\n ? data.ExceptionMessage\r\n : \"Something unexpected happened.\";\r\n showErrorMessageIntegration(\"Error: \" + errorMessage);\r\n setIsLoadingTest(false);\r\n }\r\n\r\n props.loadOutboundIntegrationValues(hola.Integration)\r\n });\r\n },\r\n (errors) => {\r\n setIsLoadingTest(false);\r\n showErrorMessageIntegration(\r\n `Error: ${Object.values(errors)\r\n .map((item: any) => item.message)\r\n .join(\"|\")}`\r\n );\r\n }\r\n )();\r\n };\r\n\r\n const handleCheckboxInput = (\r\n ev?: React.FormEvent | undefined,\r\n checked?: boolean | undefined\r\n ) => {\r\n onChangeApprovedStatus(ev, checked);\r\n setIsDisableApprove(!checked);\r\n };\r\n\r\n const fromModal = (isDisable: boolean) => {\r\n setResetCheckbox(true);\r\n setIsDisableApprove(isDisable);\r\n setValue(\"ApprovedStatus\", !isDisable);\r\n callApprovedStatus(!isDisable);\r\n setTimeout(() => {\r\n setResetCheckbox(false);\r\n }, 200);\r\n };\r\n\r\n useEffect(() => {\r\n if (ApproveStatus) {\r\n setIsDisableApprove(false);\r\n }\r\n }, [ApproveStatus]);\r\n\r\n return (\r\n <>\r\n {!isLoadingTest ? (\r\n \r\n \r\n \r\n \r\n \r\n Test\r\n \r\n \r\n {!resetCheckbox ? (\r\n \r\n ) : null}\r\n \r\n \r\n \r\n \r\n \r\n \r\n ) : (\r\n \r\n \r\n \r\n \r\n \r\n \r\n )}\r\n\r\n \r\n >\r\n );\r\n};\r\n\r\nexport default TestRelease;\r\n","import { Modal, Stack, FontWeights, getTheme, mergeStyleSets, PrimaryButton, IconButton, Pivot, PivotItem, Separator, IDropdownOption, MessageBar, IMessageBarStyles, Link, TeachingBubble, DirectionalHint } from \"@fluentui/react\";\r\nimport React, { MutableRefObject, useEffect, useState } from \"react\";\r\nimport { useForm, FormProvider } from \"react-hook-form\";\r\nimport Helper from \"../../Helpers/Helper\";\r\nimport { RHFDropDownListSingleSelectControl } from \"../RHFControls/RHFDropDownListSingleSelectControl\";\r\nimport { RHFTextBoxControl } from \"../RHFControls/RHFTextBoxControl\";\r\nimport { Body } from \"./Tabs/Body/Body\";\r\nimport { Test } from \"./Tabs/Body/Test\";\r\nimport HeaderList from \"./Tabs/HeaderList\";\r\nimport { BodyFields, Const_FormDataParam, Const_Header, Const_MapProps, Const_SurrogateFilter, Const_UrlParam } from \"./Models/Consts\";\r\nimport { AuthenticationType, BodyType, IdentifierKeyType, MethodType, OAuth20Type, ParamType, ParamValueType, PivotOutbound, SourceType, TypeType } from \"./Models/Enums\";\r\nimport { AuthenticationProperties, BodyTargetNode, MapInputHeader, MapProps, ParamsBodyParams, ParamsURL_Form_Param, OutboundIntegrationModel, SurrogateFilter, CreateOutboundIntegration, UpdateOutboundIntegration } from \"./Models/OutboundIntegrationModel\";\r\nimport Security from \"./Tabs/Security/Security\";\r\nimport OutboundServices from \"./Services/OutboundServices\";\r\nimport UrlParamsList from \"./Tabs/UrlParamsList\";\r\nimport { MapOutput } from \"./Tabs/MapOutput/MapOutput\";\r\nimport { SurrogateFilters } from \"./Tabs/Body/SurrogateFilters\";\r\nimport ConfirmationModal from \"../../Helpers/Modals/ConfirmationModal\";\r\nimport TestRelease from \"./Tabs/TestRelease/TestRelease\";\r\nimport { decode } from \"base64-arraybuffer\";\r\nimport { EventModel, EventType } from \"./Models/EventModel\";\r\nimport { useBoolean } from \"@fluentui/react-hooks\";\r\nimport { ConfigurationTemplateModel } from \"./Models/ConfigurationTemplateModel\";\r\nimport {useBranding} from \"../../hooks/useBranding\";\r\n//https://codesandbox.io/s/nelec?file=/src/StyleList.tsx\r\n\r\nexport interface OutboundIntegrationProps {\r\n templateId: number;\r\n event: MutableRefObject;\r\n outboundIntegration: OutboundIntegrationModel;\r\n outboundIntegrations: OutboundIntegrationModel[];\r\n hideOutboundIntegrationModal: () => void;\r\n isOutboundIntegrationOpen: boolean;\r\n loadEvents: () => void;\r\n showSuccessMessage: (message: string) => void;\r\n configurationTemplate?: React.MutableRefObject\r\n isConfigurationTemplateReadMode?: boolean;\r\n setConfigurationTemplateEditMode?: () => void;\r\n}\r\n\r\nconst theme = getTheme();\r\nconst iconButtonStyles = {\r\n root: {\r\n marginLeft: \"auto\",\r\n marginTop: \"4px\",\r\n marginRight: \"2px\",\r\n },\r\n \r\n};\r\nconst messageBarSuccessStyles: IMessageBarStyles = {\r\n root: {\r\n backgroundColor: \"#acffac\",\r\n },\r\n};\r\nconst messageBarFailedStyles: IMessageBarStyles = {\r\n root: {\r\n backgroundColor: \"#ffd5d5\",\r\n },\r\n};\r\n\r\nfunction OutboundIntegration(props: OutboundIntegrationProps) {\r\n const { branding } = useBranding()\r\n const [showInternalErrorMessage, setShowInternalErrorMessage] = useState(false);\r\n const [showInternalSuccessMessage, setShowInternalSuccessMessage] = useState(false);\r\n const [internalMessage, setInternalMessage] = useState(\"\");\r\n const [selectedPivot, setSelectedPivot] = useState(PivotOutbound.Security);\r\n\r\n const [showDeactivatedIntegrationModal, setShowDeactivatedIntegrationModal] = useState(false);\r\n const [configurationTemplateInstructionsVisible, { toggle: toggleConfigurationTemplateInstructions }] = useBoolean(false);\r\n\r\n const contentStyles = mergeStyleSets({\r\n container: {\r\n display: \"flex\",\r\n flexFlow: \"column nowrap\",\r\n alignItems: \"stretch\",\r\n },\r\n header: [\r\n theme.fonts.xLargePlus,\r\n {\r\n flex: \"1 1 auto\",\r\n borderTop: `4px solid ${branding.theme.palette.themePrimary}`,\r\n color: theme.palette.black,\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n fontWeight: FontWeights.semibold,\r\n padding: \"12px 12px 14px 24px\",\r\n },\r\n ],\r\n body: {\r\n flex: \"4 4 auto\",\r\n padding: \"0 24px 24px 24px\",\r\n overflowY: \"hidden\",\r\n selectors: {\r\n p: { margin: \"14px 0\" },\r\n \"p:first-child\": { marginTop: 0 },\r\n \"p:last-child\": { marginBottom: 0 },\r\n },\r\n },\r\n });\r\n\r\n\r\n const outboundIntegrationForm = useForm({\r\n reValidateMode: \"onSubmit\",\r\n mode: \"all\",\r\n defaultValues: {\r\n headerList: [Const_Header],\r\n urlParamsList: [Const_UrlParam],\r\n formDataParamsList: [Const_FormDataParam],\r\n mapInputVariableList: [Const_Header],\r\n mapOutputMapPropsList: [Const_MapProps],\r\n surrogateFiltersList: [Const_SurrogateFilter]\r\n },\r\n shouldUnregister: false\r\n });\r\n\r\n useEffect(() => {\r\n outboundIntegrationForm.register(\"Name\", { required: \"Name is required.\" });\r\n outboundIntegrationForm.register(\"Description\", { required: \"Description is required.\" });\r\n outboundIntegrationForm.register(\"Method\", { required: \"Method is required.\" });\r\n outboundIntegrationForm.register(\"ServiceUrl\", { required: \"Url is required.\" });\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (props.outboundIntegration !== undefined) {\r\n loadOutboundIntegrationValues();\r\n }\r\n }, [props.outboundIntegration]);\r\n\r\n const showSuccessMessageIntegration = (message: string) => {\r\n setShowInternalSuccessMessage(true);\r\n setInternalMessage(message);\r\n setTimeout(function () {\r\n setShowInternalSuccessMessage(false);\r\n }, 5000);\r\n };\r\n\r\n const showErrorMessageIntegration = (message: string) => {\r\n setShowInternalErrorMessage(true);\r\n setInternalMessage(message);\r\n setTimeout(function () {\r\n setShowInternalErrorMessage(false);\r\n }, 5000);\r\n };\r\n\r\n const hideOutboundIntegrationModal = (reloadIntegrations: boolean) => {\r\n outboundIntegrationForm.reset();\r\n props.event.current = undefined;\r\n if(props.configurationTemplate !== undefined) {\r\n props.configurationTemplate!.current = undefined;\r\n }\r\n \r\n props.hideOutboundIntegrationModal();\r\n if(reloadIntegrations) {\r\n props.loadEvents();\r\n }\r\n \r\n if (props.setConfigurationTemplateEditMode !== undefined) {\r\n props.setConfigurationTemplateEditMode();\r\n }\r\n };\r\n\r\n const loadAssertionContent = (file: File) => {\r\n let readerContent = new FileReader();\r\n readerContent.readAsText(file);\r\n readerContent.onload = function () {\r\n outboundIntegrationForm.setValue(\"AssertionContent\", readerContent.result);\r\n outboundIntegrationForm.trigger(\"AssertionFile\");\r\n };\r\n };\r\n\r\n const loadAssertionFile = (base64: string, filename: string): File[] => {\r\n const myBlob = new Blob([decode(base64)], {\r\n type: filename.endsWith(\".txt\")\r\n ? \"text/plain\"\r\n : \"application/x-pem-file\",\r\n });\r\n const file = new File([myBlob], filename);\r\n loadAssertionContent(file);\r\n return [file];\r\n };\r\n\r\n const loadOutboundIntegrationValues = (testOutboundIntegration?: OutboundIntegrationModel) => {\r\n const outboundIntegration = testOutboundIntegration === undefined ? props.outboundIntegration : testOutboundIntegration\r\n outboundIntegrationForm.setValue(\"Name\", outboundIntegration.Name);\r\n outboundIntegrationForm.setValue(\"Description\", outboundIntegration.Description);\r\n if (outboundIntegration.ObjectMapInput.MapInput.Params.Method === \"\") {\r\n outboundIntegrationForm.setValue(\"Method\", undefined);\r\n }\r\n else {\r\n outboundIntegrationForm.setValue(\"Method\", {\r\n text: outboundIntegration.ObjectMapInput.MapInput.Params.Method,\r\n key: outboundIntegration.ObjectMapInput.MapInput.Params.Method,\r\n });\r\n }\r\n\r\n outboundIntegrationForm.setValue(\"Synchronous\", outboundIntegration.ObjectMapInput.MapInput.Params.Synchronous);\r\n\r\n outboundIntegrationForm.setValue(\"IncludeXMLPayload\", outboundIntegration.IncludeXMLPayload);\r\n outboundIntegrationForm.setValue(\"IncludeAttachments\", outboundIntegration.IncludeAttachments);\r\n outboundIntegrationForm.setValue(\"IncludeCaseDocument\", outboundIntegration.IncludeCaseDocument);\r\n\r\n if (outboundIntegration.IncludeXMLPayload ||\r\n outboundIntegration.IncludeAttachments ||\r\n outboundIntegration.IncludeCaseDocument) {\r\n outboundIntegrationForm.setValue(\"BodyType\", { text: BodyType.KimBaseMessage, key: BodyType.KimBaseMessage, styles: { field: { marginRight: \"10px\" } } });\r\n }\r\n if (outboundIntegration.ObjectMapInput.MapInput.Params.URL_Form_Params.filter((item) => item.ParamType === ParamType.FORM).length > 0) {\r\n outboundIntegrationForm.setValue(\"BodyType\", { text: BodyType.FormData, key: BodyType.FormData, styles: { field: { marginRight: \"10px\" } } });\r\n }\r\n if (outboundIntegration.ObjectMapInput.MapInput.Params.BodyParams.BodyValue.length > 0) {\r\n outboundIntegrationForm.setValue(\"BodyType\", { text: BodyType.Raw, key: BodyType.Raw, styles: { field: { marginRight: \"10px\" } } });\r\n }\r\n if (outboundIntegration.ObjectBodyTargetNode.ScriptVariables.length > 0) {\r\n outboundIntegrationForm.setValue(\"BodyType\", { text: BodyType.MapInput, key: BodyType.MapInput, styles: { field: { marginRight: \"10px\" } } });\r\n }\r\n\r\n if (outboundIntegration.IncludeCaseDocument) {\r\n outboundIntegrationForm.setValue(\"DocumentType\", { text: outboundIntegration.ObjectMapInput.MapInput.Params.BodyParams.BodyValue, key: outboundIntegration.ObjectMapInput.MapInput.Params.BodyParams.BodyValue });\r\n }\r\n\r\n outboundIntegrationForm.setValue(\"ServiceUrl\", outboundIntegration.ServiceURL);\r\n\r\n if (outboundIntegration.AuthenticationType === \"\") {\r\n outboundIntegrationForm.setValue(\"AuthenticationType\", undefined);\r\n } else {\r\n outboundIntegrationForm.setValue(\"AuthenticationType\", { text: outboundIntegration.AuthenticationType, key: outboundIntegration.AuthenticationType });\r\n }\r\n\r\n outboundIntegrationForm.setValue(\"BearerToken\", outboundIntegration.ObjectAuthenticationProperties.BearerToken);\r\n outboundIntegrationForm.setValue(\"Username\", outboundIntegration.ObjectAuthenticationProperties.ObjectBasicToken.Username);\r\n outboundIntegrationForm.setValue(\"Password\", outboundIntegration.ObjectAuthenticationProperties.ObjectBasicToken.Password);\r\n outboundIntegrationForm.setValue(\"TokenUrl\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.TokenUrl);\r\n outboundIntegrationForm.setValue(\"ClientId\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.ClientId);\r\n outboundIntegrationForm.setValue(\"ClientSecret\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.ClientSecret);\r\n outboundIntegrationForm.setValue(\"AccessToken\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.AccessToken);\r\n outboundIntegrationForm.setValue(\"RefreshToken\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.RefreshToken);\r\n outboundIntegrationForm.setValue(\"GrantType\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.GrantType);\r\n outboundIntegrationForm.setValue(\"Scope\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.Scope);\r\n outboundIntegrationForm.setValue(\"ScopeRequired\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.ScopeRequired);\r\n outboundIntegrationForm.setValue(\"RedirectURI\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.RedirectURI);\r\n outboundIntegrationForm.setValue(\"AuthUrl\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.AuthUrl);\r\n outboundIntegrationForm.setValue(\"ResponseType\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.ResponseType);\r\n outboundIntegrationForm.setValue(\"Code\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.code);\r\n outboundIntegrationForm.setValue(\"ClientAssertionType\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.client_assertion_type);\r\n outboundIntegrationForm.setValue(\"Assertion\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.Assertion);\r\n if (outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.oAuth20Type === OAuth20Type.ServerToServerFlowAssertion) {\r\n outboundIntegrationForm.setValue(\"AssertionFile\",\r\n loadAssertionFile(\r\n outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.Assertion,\r\n outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.AssertionFileName\r\n )\r\n );\r\n }\r\n outboundIntegrationForm.setValue(\"AssertionCertPassword\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.AssertionCertPassword);\r\n outboundIntegrationForm.setValue(\"AssertionFileName\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.AssertionFileName);\r\n outboundIntegrationForm.setValue(\"CompanyId\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.company_id);\r\n outboundIntegrationForm.setValue(\"CodeVerifier\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.code_verifier);\r\n outboundIntegrationForm.setValue(\"AssertionKeyName\", outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.assertion_keyname);\r\n outboundIntegrationForm.setValue(\"AuthorizationHeader\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.AuthorizationHeader);\r\n if (outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.oAuth20Type === null ||\r\n outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.oAuth20Type === undefined) {\r\n outboundIntegrationForm.setValue(\"OAuth20Type\", { text: OAuth20Type.RefreshTokenFlow, key: OAuth20Type.RefreshTokenFlow });\r\n } else {\r\n outboundIntegrationForm.setValue(\"OAuth20Type\", {\r\n text: outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.oAuth20Type,\r\n key: outboundIntegration.ObjectAuthenticationProperties?.OAuth20Prop.oAuth20Type\r\n });\r\n }\r\n\r\n outboundIntegrationForm.setValue(\"SSFCCUsername\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.Username);\r\n outboundIntegrationForm.setValue(\"SSFCCPassword\", outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.Password);\r\n if (outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.ServiceProvider !== null &&\r\n outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.ServiceProvider.length > 0) {\r\n outboundIntegrationForm.setValue(\"ServiceProvider\", {\r\n text: outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.ServiceProvider,\r\n key: outboundIntegration.ObjectAuthenticationProperties.OAuth20Prop.ServiceProvider\r\n });\r\n }\r\n\r\n let tempHeaders = outboundIntegration.ObjectMapInput.MapInput.Headers;\r\n tempHeaders!.push(Const_Header);\r\n tempHeaders!.forEach((value: MapInputHeader, index: number, array: MapInputHeader[]) => {\r\n /*if (value.Key.toLowerCase() === ContentType && SendAsTypeList[value.Value] !== undefined) {\r\n outboundIntegrationForm.setValue(\"SendAs\", { text: SendAsTypeList[value.Value], key: SendAsTypeList[value.Value] })\r\n }\r\n if (value.Key.toLowerCase() === AcceptType) {\r\n if (EncodeRequestTypeList[value.Value] === undefined && SendAsTypeList[value.Value] !== undefined) {\r\n outboundIntegrationForm.setValue(\"EncodeRequest\", { text: EncodeRequestType.SendAsSelected, key: EncodeRequestType.SendAsSelected })\r\n } else if (EncodeRequestTypeList[value.Value] !== undefined) {\r\n outboundIntegrationForm.setValue(\"EncodeRequest\", { text: EncodeRequestTypeList[value.Value], key: EncodeRequestTypeList[value.Value] })\r\n }\r\n }*/\r\n outboundIntegrationForm.setValue(`headerList.${index!}.Key`, value.Key);\r\n outboundIntegrationForm.setValue(`headerList.${index!}.Value`, value.Value);\r\n });\r\n\r\n let tempUrlParams = outboundIntegration.ObjectMapInput.MapInput.Params.URL_Form_Params.filter((item) => item.ParamType === ParamType.URL);\r\n tempUrlParams!.push(Const_UrlParam);\r\n tempUrlParams!.forEach((value: ParamsURL_Form_Param, index: number, array: ParamsURL_Form_Param[]) => {\r\n outboundIntegrationForm.setValue(`urlParamsList.${index!}.ParamName`, value.ParamName);\r\n outboundIntegrationForm.setValue(`urlParamsList.${index!}.ParamValueType`, { text: value.ParamValueType, key: value.ParamValueType });\r\n if (value.ParamValueType === ParamValueType.Document) {\r\n outboundIntegrationForm.setValue(`urlParamsList.${index!}.ParamValueSource`, { text: value.ParamValueSource, key: value.ParamValueSource });\r\n } else {\r\n outboundIntegrationForm.setValue(`urlParamsList.${index!}.ParamValueSource`, value.ParamValueSource);\r\n }\r\n });\r\n\r\n let tempFormParams = outboundIntegration.ObjectMapInput.MapInput.Params.URL_Form_Params.filter((item) => item.ParamType === ParamType.FORM);\r\n tempFormParams!.push(Const_FormDataParam);\r\n tempFormParams!.forEach((value: ParamsURL_Form_Param, index: number, array: ParamsURL_Form_Param[]) => {\r\n outboundIntegrationForm.setValue(`formDataParamsList.${index!}.ParamName`, value.ParamName);\r\n outboundIntegrationForm.setValue(`formDataParamsList.${index!}.ParamValueType`, { text: value.ParamValueType, key: value.ParamValueType });\r\n outboundIntegrationForm.setValue(`formDataParamsList.${index!}.InlineAttachment`, value.InlineAttachment);\r\n if (value.ParamValueType === ParamValueType.Document) {\r\n outboundIntegrationForm.setValue(`formDataParamsList.${index!}.ParamValueSource`, { text: value.ParamValueSource, key: value.ParamValueSource });\r\n } else {\r\n outboundIntegrationForm.setValue(`formDataParamsList.${index!}.ParamValueSource`, value.ParamValueSource);\r\n }\r\n });\r\n\r\n outboundIntegrationForm.setValue(\"Raw\", outboundIntegration.ObjectMapInput.MapInput.Params.BodyParams.BodyValue);\r\n\r\n outboundIntegrationForm.setValue(\"MapInputPayload\", outboundIntegration.ObjectBodyTargetNode.Payload);\r\n outboundIntegrationForm.setValue(\"MapInputScript\", outboundIntegration.ObjectBodyTargetNode.Script);\r\n\r\n let tempScriptVariables = outboundIntegration.ObjectBodyTargetNode.ScriptVariables.split(\";\");\r\n tempScriptVariables.push('=\"\"');\r\n tempScriptVariables.forEach((value: string, index: number, array: string[]) => {\r\n if (value.length > 0) {\r\n let item: MapInputHeader = {\r\n Key: value.split(\"=\")[0],\r\n Value: value.split(\"=\")[1].substring(1, value.split(\"=\")[1].length - 1)\r\n };\r\n outboundIntegrationForm.setValue(`mapInputVariableList.${index!}.Key`, item.Key);\r\n outboundIntegrationForm.setValue(`mapInputVariableList.${index!}.Value`, item.Value);\r\n }\r\n });\r\n outboundIntegrationForm.setValue(\"MapInputUseParentSurrogateSubrecord\", outboundIntegration.ObjectMapInput.MapInput.Params.ObjectIdentifierFilter.UseParentFilter);\r\n outboundIntegrationForm.setValue(\"MapInputFilterKeyName\", outboundIntegration.ObjectMapInput.MapInput.Params.ObjectIdentifierFilter.FilterKeyName);\r\n\r\n let tempSurrogateFilters = outboundIntegration.ObjectMapInput.MapInput.Params.ObjectSurrogateFilter;\r\n tempSurrogateFilters!.push(Const_SurrogateFilter);\r\n tempSurrogateFilters!.forEach((value: SurrogateFilter, index: number, array: SurrogateFilter[]) => {\r\n outboundIntegrationForm.setValue(`surrogateFiltersList.${index!}.FilterName`, value.FilterName);\r\n outboundIntegrationForm.setValue(`surrogateFiltersList.${index!}.IntegrationId`, { text: getIntegrationName(value.IntegrationId), key: value.IntegrationId.toString() });\r\n });\r\n\r\n outboundIntegrationForm.setValue(\"MapOutputResponseType\", {\r\n text: outboundIntegration.ObjectMapOutput.ResponseType,\r\n key: outboundIntegration.ObjectMapOutput.ResponseType,\r\n });\r\n outboundIntegrationForm.setValue(\"MapOutputScript\", outboundIntegration.ObjectMapOutput.Script);\r\n let tempMapOutputMapProps = outboundIntegration.ObjectMapOutput.MapProps;\r\n tempMapOutputMapProps!.push(Const_MapProps);\r\n tempMapOutputMapProps!.forEach((value: MapProps, index: number, array: MapProps[]) => {\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.Path`, value.Path);\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.ValueType`, { text: value.ValueType, key: value.ValueType });\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.Index`, value.Index);\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.TargetField`, { text: value.TargetField, key: value.TargetField });\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.IsHeader`, value.IsHeader);\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.Output`, value.Output);\r\n if (value.TargetField === IdentifierKeyType.Identifier1)\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.IdentifierKeyName`, outboundIntegration.ObjectMapOutput.IdentifierKeyName1);\r\n if (value.TargetField === IdentifierKeyType.Identifier2)\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.IdentifierKeyName`, outboundIntegration.ObjectMapOutput.IdentifierKeyName2);\r\n if (value.TargetField === IdentifierKeyType.Identifier3)\r\n outboundIntegrationForm.setValue(`mapOutputMapPropsList.${index!}.IdentifierKeyName`, outboundIntegration.ObjectMapOutput.IdentifierKeyName3);\r\n });\r\n\r\n outboundIntegrationForm.setValue(`ApprovedStatus`, outboundIntegration.ObjectApprovedStatus);\r\n };\r\n\r\n const getIntegrationName = (integrationId: number) => {\r\n let integration: OutboundIntegrationModel =\r\n props.outboundIntegrations.find((f) => f.Id === integrationId)!;\r\n if (integration === undefined) {\r\n return \"\";\r\n } else {\r\n return `${integration.Name!} (${integration.Description})`;\r\n }\r\n };\r\n\r\n const getAuthenticationProperties = (authenticationType: AuthenticationType, oAuth20Type: OAuth20Type): AuthenticationProperties => {\r\n let authenticationProperties: AuthenticationProperties = {\r\n ObjectBasicToken: {\r\n Password: \"\",\r\n Username: \"\",\r\n },\r\n BearerToken: \"\",\r\n OAuth20Prop: {\r\n oAuth20Type: \"\",\r\n AccessToken: \"\",\r\n ClientId: \"\",\r\n ClientSecret: \"\",\r\n GrantType: \"\",\r\n RedirectURI: \"\",\r\n RefreshToken: \"\",\r\n Scope: \"\",\r\n TokenUrl: \"\",\r\n AuthUrl: \"\",\r\n ResponseType: \"\",\r\n Assertion: \"\",\r\n AssertionCertPassword: \"\",\r\n assertion_keyname: \"\",\r\n AssertionFileName: \"\",\r\n client_assertion_type: \"\",\r\n code: \"\",\r\n code_verifier: \"\",\r\n company_id: \"\",\r\n new_token: \"\",\r\n Password: \"\",\r\n State: \"\",\r\n Username: \"\",\r\n ScopeRequired: false,\r\n ServiceProvider: \"\",\r\n AuthorizationHeader: \"\",\r\n },\r\n BasicToken: \"\",\r\n };\r\n switch (authenticationType) {\r\n case AuthenticationType.Basic: {\r\n authenticationProperties.ObjectBasicToken = {\r\n Username: outboundIntegrationForm.getValues(\"Username\"),\r\n Password: outboundIntegrationForm.getValues(\"Password\"),\r\n };\r\n break;\r\n }\r\n case AuthenticationType.Bearer: {\r\n authenticationProperties.BearerToken = outboundIntegrationForm.getValues(\"BearerToken\");\r\n break;\r\n }\r\n case AuthenticationType.OAuth20: {\r\n authenticationProperties.OAuth20Prop = {\r\n AccessToken: [OAuth20Type.RefreshTokenFlow].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"AccessToken\") : \"\",\r\n RefreshToken: [OAuth20Type.RefreshTokenFlow].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"RefreshToken\") : \"\",\r\n AuthUrl: [OAuth20Type.RefreshTokenFlow].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"AuthUrl\") : \"\",\r\n ResponseType: [OAuth20Type.RefreshTokenFlow].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"ResponseType\") : \"\",\r\n TokenUrl: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowCC, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"TokenUrl\") : \"\",\r\n GrantType: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowCC, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"GrantType\") : \"\",\r\n ClientId: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowCC, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"ClientId\") : \"\",\r\n ClientSecret: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowCC].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"ClientSecret\") : \"\",\r\n RedirectURI: [OAuth20Type.RefreshTokenFlow].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"RedirectURI\") : \"\",\r\n Scope: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowCC, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"Scope\") : \"\",\r\n Username: [OAuth20Type.ServerToServerFlowCC].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"SSFCCUsername\") : \"\",\r\n Password: [OAuth20Type.ServerToServerFlowCC].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"SSFCCPassword\") : \"\",\r\n code: [OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"Code\") : \"\",\r\n client_assertion_type: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"ClientAssertionType\") : \"\",\r\n Assertion: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"Assertion\") : \"\",\r\n AssertionCertPassword: [OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"AssertionCertPassword\") : \"\",\r\n company_id: [OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"CompanyId\") : \"\",\r\n code_verifier: [OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"CodeVerifier\") : \"\",\r\n assertion_keyname: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"AssertionKeyName\") : \"\",\r\n AssertionFileName: [OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"AssertionFileName\") : \"\",\r\n new_token: \"\",\r\n oAuth20Type: oAuth20Type === OAuth20Type.Custom ? \"\" : oAuth20Type,\r\n State: \"\",\r\n ScopeRequired: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowCC, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"ScopeRequired\") : false,\r\n ServiceProvider: [OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"ServiceProvider\").key.toString() : \"\",\r\n AuthorizationHeader: [OAuth20Type.RefreshTokenFlow, OAuth20Type.ServerToServerFlowCC, OAuth20Type.ServerToServerFlowAssertion].includes(oAuth20Type) ? outboundIntegrationForm.getValues(\"AuthorizationHeader\") : \"\",\r\n };\r\n break;\r\n }\r\n default: {\r\n authenticationProperties.ObjectBasicToken = {\r\n Username: \"\",\r\n Password: \"\"\r\n };\r\n authenticationProperties.BearerToken = \"\";\r\n authenticationProperties.OAuth20Prop = {\r\n AccessToken: \"\",\r\n RefreshToken: \"\",\r\n AuthUrl: \"\",\r\n ResponseType: \"\",\r\n TokenUrl: \"\",\r\n GrantType: \"\",\r\n ClientId: \"\",\r\n ClientSecret: \"\",\r\n RedirectURI: \"\",\r\n Scope: \"\",\r\n Username: \"\",\r\n Password: \"\",\r\n code: \"\",\r\n client_assertion_type: \"\",\r\n Assertion: \"\",\r\n AssertionCertPassword: \"\",\r\n company_id: \"\",\r\n code_verifier: \"\",\r\n assertion_keyname: \"\",\r\n AssertionFileName: \"\",\r\n new_token: \"\",\r\n oAuth20Type: \"\",\r\n State: \"\",\r\n ScopeRequired: false,\r\n ServiceProvider: \"\",\r\n AuthorizationHeader: \"\",\r\n };\r\n break;\r\n }\r\n }\r\n return authenticationProperties;\r\n };\r\n\r\n const getHeaders = (): MapInputHeader[] => {\r\n let headerList: MapInputHeader[] = [];\r\n headerList = outboundIntegrationForm.getValues(\"headerList\");\r\n\r\n /*let tempSendAs = outboundIntegrationForm.getValues(\"SendAs\") as IChoiceGroupOption;\r\n if (tempSendAs !== undefined) {\r\n headerList.push({ Key: \"Content-Type\", Value: SendAsTypeList[tempSendAs.key] })\r\n }\r\n let tempEncodeRequest = outboundIntegrationForm.getValues(\"EncodeRequest\") as IChoiceGroupOption;\r\n if (tempEncodeRequest !== undefined && tempEncodeRequest.key.length > 0) {\r\n headerList.push({ Key: \"Accept\", Value: EncodeRequestTypeList[tempEncodeRequest.key] })\r\n }*/\r\n return headerList.filter(\r\n (item) => item.Key.length > 0 && item.Value.length >= 0\r\n );\r\n };\r\n\r\n const getURL_Form_Params = (): ParamsURL_Form_Param[] => {\r\n let urlParamsList: ParamsURL_Form_Param[] = [];\r\n let formDataParamsList: ParamsURL_Form_Param[] = [];\r\n\r\n urlParamsList = outboundIntegrationForm.getValues(\"urlParamsList\");\r\n urlParamsList.forEach((item) => {\r\n const tempParamValueType: any = item.ParamValueType;\r\n item.ParamType = ParamType.URL;\r\n if (tempParamValueType !== \"\") {\r\n item.ParamValueType = (\r\n tempParamValueType as IDropdownOption\r\n ).key.toString();\r\n }\r\n if (tempParamValueType.key === ParamValueType.Document) {\r\n const tempParamValueSource: IDropdownOption = item.ParamValueSource as any;\r\n item.ParamValueSource = tempParamValueSource.key.toString();\r\n }\r\n if (tempParamValueType.key === ParamValueType.Payload) {\r\n item.ParamValueSource = \"\";\r\n }\r\n });\r\n\r\n formDataParamsList = outboundIntegrationForm.getValues(\"formDataParamsList\");\r\n formDataParamsList.forEach((item) => {\r\n const tempParamValueType: any = item.ParamValueType;\r\n item.ParamType = ParamType.FORM;\r\n if (tempParamValueType !== \"\") {\r\n try {\r\n item.ParamValueType = (tempParamValueType as IDropdownOption).key.toString();\r\n } catch (error) {\r\n item.ParamValueType = tempParamValueType;\r\n }\r\n }\r\n try {\r\n if (tempParamValueType.key === ParamValueType.Document) {\r\n const tempParamValueSource: IDropdownOption = item.ParamValueSource as any;\r\n item.ParamValueSource = tempParamValueSource.key.toString();\r\n }\r\n if (tempParamValueType.key === ParamValueType.Payload) {\r\n item.ParamValueSource = \"\";\r\n }\r\n } catch (error) { }\r\n });\r\n return urlParamsList\r\n .concat(formDataParamsList)\r\n .filter(\r\n (item) =>\r\n item.ParamName.length > 0 &&\r\n item.ParamType.length > 0 &&\r\n item.ParamValueType.length > 0 &&\r\n item.ParamValueSource.length >= 0\r\n );\r\n };\r\n\r\n const getSurrogateFilters = (): SurrogateFilter[] => {\r\n let surrogateFilterList: SurrogateFilter[] = [];\r\n\r\n surrogateFilterList = outboundIntegrationForm.getValues(\"surrogateFiltersList\");\r\n surrogateFilterList.forEach((item) => {\r\n const tempParamValueType: any = item.IntegrationId;\r\n if (tempParamValueType !== -1) {\r\n item.IntegrationId = +(tempParamValueType as IDropdownOption).key.toString();\r\n }\r\n item.RecordFilter = \"\";\r\n item.SortOrder = \"\";\r\n item.SourceRecordId = -1;\r\n item.TemplateId = props.templateId;\r\n });\r\n\r\n return surrogateFilterList.filter(\r\n (item) =>\r\n item.FilterName.length > 0 &&\r\n item.IntegrationId.toString().length > 0 &&\r\n item.TemplateId > 0\r\n );\r\n };\r\n\r\n const getType = (): string => {\r\n const method = outboundIntegrationForm.getValues(\"Method\") !== undefined ? outboundIntegrationForm.getValues(\"Method\").key : \"\";\r\n const formDataParamsList = outboundIntegrationForm.getValues(\"formDataParamsList\") !== undefined ? (outboundIntegrationForm.getValues(\"formDataParamsList\") as ParamsURL_Form_Param[]) : [];\r\n //Body type Form is only send if form data inside the body is fill, for everything send \"Body\"\r\n if (method === MethodType.GET) {\r\n return TypeType.None;\r\n } else if (formDataParamsList.length > 0 && formDataParamsList[0].ParamName !== \"\") {\r\n return TypeType.Form;\r\n } else {\r\n return TypeType.Body;\r\n }\r\n };\r\n\r\n const getBodyParams = (): ParamsBodyParams => {\r\n const raw = outboundIntegrationForm.getValues(\"Raw\") !== undefined ? outboundIntegrationForm.getValues(\"Raw\") : \"\";\r\n const includeXMLPayload = outboundIntegrationForm.getValues(\"IncludeXMLPayload\") !== undefined ? outboundIntegrationForm.getValues(\"IncludeXMLPayload\") : false;\r\n const includeAttachments = outboundIntegrationForm.getValues(\"IncludeAttachments\") !== undefined ? outboundIntegrationForm.getValues(\"IncludeAttachments\") : false;\r\n const includeCaseDocument = outboundIntegrationForm.getValues(\"IncludeCaseDocument\") !== undefined ? outboundIntegrationForm.getValues(\"IncludeCaseDocument\") : false;\r\n const documentType = outboundIntegrationForm.getValues(\"DocumentType\") !== undefined ? outboundIntegrationForm.getValues(\"DocumentType\").key : \"\";\r\n\r\n let paramsBodyParams: ParamsBodyParams = {\r\n BodyValue: \"\",\r\n Source: \"\",\r\n };\r\n if (raw.length > 0) {\r\n paramsBodyParams.Source = SourceType.Fixed;\r\n paramsBodyParams.BodyValue = raw;\r\n }\r\n if (includeXMLPayload || includeAttachments) {\r\n paramsBodyParams.Source = SourceType.DocumentData;\r\n paramsBodyParams.BodyValue = \"\";\r\n }\r\n if (includeCaseDocument) {\r\n paramsBodyParams.Source = SourceType.DocumentData;\r\n paramsBodyParams.BodyValue = documentType;\r\n }\r\n return paramsBodyParams;\r\n };\r\n\r\n const create = () => {\r\n outboundIntegrationForm.handleSubmit(\r\n async (data) => {\r\n if (props.outboundIntegrations.filter((f) => f.Active).length === 3) {\r\n setShowDeactivatedIntegrationModal(true);\r\n } else {\r\n callbackDeactivatedIntegrationConfirmation();\r\n }\r\n },\r\n (errors) => {\r\n showErrorMessageIntegration(\r\n `Error: ${Object.values(errors)\r\n .map((item: any) => item.message)\r\n .join(\"|\")}`\r\n );\r\n }\r\n )();\r\n };\r\n\r\n const updateIntegration = () => {\r\n outboundIntegrationForm.handleSubmit(\r\n async (data) => {\r\n OutboundServices.UpdateIntegration(await getUpdatedOutboundIntegration()).then((res) => {\r\n if (res.Success !== undefined &&\r\n res.Success !== null &&\r\n res.Success === true) {\r\n props.showSuccessMessage(\r\n \"Integration has been updated successfully.\"\r\n );\r\n hideOutboundIntegrationModal(true);\r\n } else {\r\n let errorMessage =\r\n res.ExceptionMessage !== undefined &&\r\n res.ExceptionMessage !== \"\"\r\n ? res.ExceptionMessage\r\n : \"Something unexpected happened.\";\r\n showErrorMessageIntegration(\"Error: \" + errorMessage);\r\n }\r\n });\r\n },\r\n (errors) => {\r\n showErrorMessageIntegration(\r\n `Error: ${Object.values(errors)\r\n .map((item: any) => item.message)\r\n .join(\"|\")}`\r\n );\r\n }\r\n )();\r\n };\r\n\r\n const getUpdatedOutboundIntegration = async (): Promise => {\r\n return {\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n EventId: props.event.current !== undefined ? props.event.current!.Id : 0,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n Integration: {\r\n Id: props.outboundIntegration !== undefined ? props.outboundIntegration.Id : 0,\r\n Active: props.outboundIntegration !== undefined ? props.outboundIntegration.Active : false,\r\n\r\n Name: outboundIntegrationForm.getValues(\"Name\"),\r\n Description: outboundIntegrationForm.getValues(\"Description\"),\r\n ServiceURL: outboundIntegrationForm.getValues(\"ServiceUrl\"),\r\n\r\n AuthenticationType: outboundIntegrationForm.getValues(\"AuthenticationType\") !== undefined ? outboundIntegrationForm.getValues(\"AuthenticationType\").key : \"\",\r\n ObjectAuthenticationProperties: getAuthenticationProperties(\r\n outboundIntegrationForm.getValues(\"AuthenticationType\") === undefined ? AuthenticationType.Custom : outboundIntegrationForm.getValues(\"AuthenticationType\").key as AuthenticationType,\r\n outboundIntegrationForm.getValues(\"OAuth20Type\") === undefined ? OAuth20Type.Custom : (outboundIntegrationForm.getValues(\"OAuth20Type\").key as OAuth20Type)\r\n ),\r\n\r\n ObjectMapInput: {\r\n MapInput: {\r\n Params: {\r\n Method: outboundIntegrationForm.getValues(\"Method\") === undefined ? \"\" : outboundIntegrationForm.getValues(\"Method\").key,\r\n BodyParams: getBodyParams(),\r\n Synchronous: outboundIntegrationForm.getValues(\"Synchronous\"),\r\n Type: getType(),\r\n URL_Form_Params: getURL_Form_Params(),\r\n ObjectSurrogateFilter: getSurrogateFilters(),\r\n ObjectIdentifierFilter: {\r\n UseParentFilter: outboundIntegrationForm.getValues(\"MapInputUseParentSurrogateSubrecord\"),\r\n FilterKeyName: outboundIntegrationForm.getValues(\"MapInputFilterKeyName\")\r\n }\r\n },\r\n Headers: getHeaders(),\r\n },\r\n },\r\n IncludeAttachments: outboundIntegrationForm.getValues(\"IncludeAttachments\"),\r\n IncludeCaseDocument: outboundIntegrationForm.getValues(\"IncludeCaseDocument\"),\r\n IncludeXMLPayload: outboundIntegrationForm.getValues(\"IncludeXMLPayload\"),\r\n\r\n AttachmentTargetsNode: \"\",\r\n ObjectBodyTargetNode: getObjectBodyTargetNode(),\r\n CaseDocumentTargetNode: \"\",\r\n CertAuthenticationProperties: \"\",\r\n\r\n ObjectMapOutput: {\r\n MapProps: getMapProps(),\r\n ResponseType: outboundIntegrationForm.getValues(\"MapOutputResponseType\") !== undefined && outboundIntegrationForm.getValues(\"MapOutputResponseType\") !== \"\" ? outboundIntegrationForm.getValues(\"MapOutputResponseType\").key.toString() : \"\",\r\n Script: outboundIntegrationForm.getValues(\"MapOutputScript\") !== undefined ? outboundIntegrationForm.getValues(\"MapOutputScript\") : \"\",\r\n IdentifierKeyName1: getIdentifierKeyName(IdentifierKeyType.Identifier1),\r\n IdentifierKeyName2: getIdentifierKeyName(IdentifierKeyType.Identifier2),\r\n IdentifierKeyName3: getIdentifierKeyName(IdentifierKeyType.Identifier3)\r\n },\r\n Order: props.outboundIntegration !== undefined ? props.outboundIntegration.Order : props.outboundIntegrations.length + 1,\r\n Surrogate1OutputMapReferenceAttribute: \"\",\r\n Surrogate2OutputMapReferenceAttribute: \"\",\r\n Surrogate3OutputMapReferenceAttribute: \"\",\r\n TargetIntegrationPlatform: \"\",\r\n TargetIntegrationProperties: \"\",\r\n TemplateId: props.templateId,\r\n UniqueId: \"\",\r\n ObjectApprovedStatus: outboundIntegrationForm.getValues(\"ApprovedStatus\")\r\n },\r\n };\r\n };\r\n\r\n const getIdentifierKeyName = (identifierType: IdentifierKeyType): string => {\r\n const currentMapOutputProp: MapProps = outboundIntegrationForm.getValues(\"mapOutputMapPropsList\").find((element: MapProps) => element.TargetField === identifierType)\r\n if (currentMapOutputProp !== undefined) {\r\n return currentMapOutputProp.IdentifierKeyName!\r\n } else {\r\n return \"\";\r\n }\r\n };\r\n\r\n const getMapProps = (): MapProps[] => {\r\n let mapOutputMapPropsList: MapProps[] = [];\r\n mapOutputMapPropsList = outboundIntegrationForm.getValues(\"mapOutputMapPropsList\");\r\n\r\n mapOutputMapPropsList.forEach((item) => {\r\n const tempValueType: any = item.ValueType;\r\n if (tempValueType !== \"\") {\r\n try {\r\n item.ValueType = (\r\n tempValueType as IDropdownOption\r\n ).key.toString();\r\n } catch (error) {\r\n item.ValueType = tempValueType;\r\n }\r\n }\r\n\r\n const tempTargetField: any = item.TargetField;\r\n if (tempTargetField !== \"\") {\r\n try {\r\n item.TargetField = (\r\n tempTargetField as IDropdownOption\r\n ).key.toString();\r\n } catch (error) {\r\n item.TargetField = tempTargetField;\r\n }\r\n }\r\n\r\n item.Index = item.Index.toString();\r\n });\r\n\r\n return mapOutputMapPropsList.filter((item) =>\r\n item.Index.toString().length > 0 &&\r\n item.Path.length > 0 &&\r\n item.TargetField.length > 0 &&\r\n item.ValueType.length > 0\r\n );\r\n };\r\n\r\n const getObjectBodyTargetNode = (): BodyTargetNode => {\r\n let mapInputVariableList: MapInputHeader[] = [];\r\n mapInputVariableList = outboundIntegrationForm.getValues(\"mapInputVariableList\");\r\n let objectBodyTargetNode: BodyTargetNode = {\r\n Payload: outboundIntegrationForm.getValues(\"MapInputPayload\") !== undefined ? outboundIntegrationForm.getValues(\"MapInputPayload\") : \"\",\r\n Script: outboundIntegrationForm.getValues(\"MapInputScript\") !== undefined ? outboundIntegrationForm.getValues(\"MapInputScript\") : \"\",\r\n ScriptVariables: mapInputVariableList.filter((item) => item.Key.length > 0 && item.Value.length >= 0).map((item) => {\r\n return `${item.Key}=\"${item.Value}\"`;\r\n }).join(\";\") + \";\",\r\n };\r\n return objectBodyTargetNode;\r\n };\r\n\r\n const onPivotLinkClick = (item?: PivotItem, ev?: React.MouseEvent) => {\r\n if (item?.props.itemKey === PivotOutbound.Security ||\r\n selectedPivot === PivotOutbound.Security) {\r\n outboundIntegrationForm.handleSubmit(\r\n async (data) => {\r\n setSelectedPivot(item?.props.itemKey as PivotOutbound);\r\n },\r\n (errors) => {\r\n showErrorMessageIntegration(`Error: ${Object.values(errors).map((item: any) => item.message).join(\"|\")}`);\r\n }\r\n )();\r\n } else {\r\n setSelectedPivot(item?.props.itemKey as PivotOutbound);\r\n }\r\n };\r\n\r\n const callApprovedStatus = async (checked: boolean) => {\r\n OutboundServices.ApprovedStatus({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n SessionKey: Helper.getSessionKey(),\r\n Id: props.outboundIntegration.Id,\r\n IsApproved: checked!,\r\n }).then((res) => {\r\n if (res.Success !== undefined &&\r\n res.Success !== null &&\r\n res.Success === true) {\r\n showSuccessMessageIntegration(`Integration has been ${checked ? `approved` : `unapproved`}.`);\r\n props.loadEvents();\r\n } else {\r\n let errorMessage =\r\n res.ExceptionMessage !== undefined &&\r\n res.ExceptionMessage !== \"\"\r\n ? res.ExceptionMessage\r\n : \"Something unexpected happened.\";\r\n showErrorMessageIntegration(\"Error: \" + errorMessage);\r\n }\r\n });\r\n };\r\n\r\n const onChangeApprovedStatus = async (ev?: React.FormEvent | undefined, checked?: boolean | undefined) => {\r\n callApprovedStatus(checked!);\r\n };\r\n\r\n const callbackDeactivatedIntegrationConfirmation = async () => {\r\n let tempOutboundIntegration = await getUpdatedOutboundIntegration();\r\n tempOutboundIntegration.Integration.Active = props.outboundIntegrations.filter((f) => f.Active).length <= 2 ? true : false;\r\n OutboundServices.CreateIntegration(tempOutboundIntegration as CreateOutboundIntegration).then((res) => {\r\n if (res.Success !== undefined &&\r\n res.Success !== null &&\r\n res.Success === true) {\r\n props.showSuccessMessage(\"Integration has been created successfully.\");\r\n hideOutboundIntegrationModal(true);\r\n } else {\r\n let errorMessage =\r\n res.ExceptionMessage !== undefined &&\r\n res.ExceptionMessage !== \"\"\r\n ? res.ExceptionMessage\r\n : \"Something unexpected happened.\";\r\n showErrorMessageIntegration(\"Error: \" + errorMessage);\r\n }\r\n });\r\n setShowDeactivatedIntegrationModal(false);\r\n };\r\n\r\n const updateConfigurationTemplate = async () => {\r\n let tempConfigurationTemplate = props.configurationTemplate!.current!;\r\n let tempIntegration = await getUpdatedOutboundIntegration()\r\n\r\n let integrationIndex = tempConfigurationTemplate.ObjectIntegrationConfig.Integrations.findIndex(integration => integration.Id === tempIntegration.Integration.Id)\r\n tempConfigurationTemplate.ObjectIntegrationConfig.Integrations[integrationIndex] = tempIntegration.Integration\r\n tempConfigurationTemplate.ObjectIntegrationConfig.Integrations[integrationIndex].ObjectAuthenticationProperties = {\r\n ObjectBasicToken: {\r\n Password: \"\",\r\n Username: \"\",\r\n },\r\n BearerToken: \"\",\r\n OAuth20Prop: {\r\n oAuth20Type: \"\",\r\n AccessToken: \"\",\r\n ClientId: \"\",\r\n ClientSecret: \"\",\r\n GrantType: \"\",\r\n RedirectURI: tempConfigurationTemplate.ObjectIntegrationConfig.Integrations[integrationIndex].ObjectAuthenticationProperties.OAuth20Prop.RedirectURI,\r\n RefreshToken: \"\",\r\n Scope: \"\",\r\n TokenUrl: \"\",\r\n AuthUrl: \"\",\r\n ResponseType: \"\",\r\n Assertion: \"\",\r\n AssertionCertPassword: \"\",\r\n assertion_keyname: \"\",\r\n AssertionFileName: \"\",\r\n client_assertion_type: \"\",\r\n code: \"\",\r\n code_verifier: \"\",\r\n company_id: \"\",\r\n new_token: \"\",\r\n Password: \"\",\r\n State: \"\",\r\n Username: \"\",\r\n ScopeRequired: false,\r\n ServiceProvider: \"\",\r\n AuthorizationHeader: \"\",\r\n },\r\n BasicToken: \"\",\r\n }\r\n\r\n tempConfigurationTemplate.ObjectIntegrationConfig.Integrations[integrationIndex].ObjectMapInput.MapInput.Params.ObjectSurrogateFilter.forEach(surrogate => {\r\n surrogate.IntegrationId = 0\r\n })\r\n\r\n OutboundServices.UpdateConfigurationTemplate({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n ConfigurationTemplate: tempConfigurationTemplate!,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n }).then(res => {\r\n if (res.Success !== undefined && res.Success !== null && res.Success === true) {\r\n props.showSuccessMessage(\"Configuration Template has been updated successfully.\");\r\n hideOutboundIntegrationModal(true);\r\n } else {\r\n loadOutboundIntegrationValues(tempIntegration.Integration)\r\n let errorMessage = res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\" ? res.ExceptionMessage : \"Something unexpected happened.\";\r\n showErrorMessageIntegration(\"Error: \" + errorMessage)\r\n }\r\n })\r\n };\r\n\r\n return (\r\n <>\r\n hideOutboundIntegrationModal(false)}\r\n isBlocking={true}\r\n containerClassName={contentStyles.container}\r\n styles={{ main: { width: \"55%\", height: \"760px\" } }}\r\n >\r\n \r\n \r\n
Outbound Integration
\r\n
hideOutboundIntegrationModal(false)} />\r\n \r\n \r\n
\r\n {props.configurationTemplate !== undefined ?
Instructions : null}\r\n {configurationTemplateInstructionsVisible ?\r\n
\r\n {}\r\n\r\n : null}\r\n
\r\n
\r\n \r\n
\r\n {showInternalErrorMessage ? (\r\n \r\n {internalMessage}\r\n \r\n ) : null}\r\n {showInternalSuccessMessage ? (\r\n \r\n {internalMessage}\r\n \r\n ) : null}\r\n
\r\n
\r\n \r\n
\r\n \r\n 0) || props.isConfigurationTemplateReadMode ? true : false}\r\n title=\"Enter outbound integration name.\"\r\n control={outboundIntegrationForm.control}\r\n setValue={outboundIntegrationForm.setValue}\r\n getValues={outboundIntegrationForm.getValues}\r\n trigger={outboundIntegrationForm.trigger}\r\n defaultValue={\"\"}\r\n required={true}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {\r\n return {\r\n text: item[0],\r\n key: item[1],\r\n };\r\n })}\r\n required={true}\r\n disabled={props.isConfigurationTemplateReadMode ? true : false}\r\n title=\"Select method type.\"\r\n control={outboundIntegrationForm.control}\r\n setValue={outboundIntegrationForm.setValue}\r\n getValues={outboundIntegrationForm.getValues}\r\n trigger={outboundIntegrationForm.trigger}\r\n onCallback={(event: React.FormEvent, option?: IDropdownOption | undefined, index?: number | undefined) => {\r\n BodyFields.forEach((field) => {\r\n outboundIntegrationForm.resetField(field);\r\n });\r\n outboundIntegrationForm.resetField(\"BodyType\");\r\n setSelectedPivot(PivotOutbound.Security)\r\n }}\r\n defaultValue={\"\"}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n }\r\n test={}\r\n isConfigurationTemplateReadMode={props.isConfigurationTemplateReadMode}\r\n />\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {props.configurationTemplate !== undefined ?\r\n :\r\n props.outboundIntegration !== undefined ?\r\n \r\n \r\n :\r\n \r\n \r\n }\r\n \r\n \r\n
\r\n \r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default OutboundIntegration;","import { Modal, Stack, FontWeights, getTheme, mergeStyleSets, IconButton, IIconProps, PrimaryButton, MessageBar } from '@fluentui/react';\r\nimport { useBoolean, useId } from '@fluentui/react-hooks';\r\nimport React, { MutableRefObject, useEffect, useState } from 'react';\r\nimport { FormProvider, useForm } from 'react-hook-form';\r\nimport Helper from '../../Helpers/Helper';\r\nimport { RHFDropDownListSingleSelectControl } from '../RHFControls/RHFDropDownListSingleSelectControl';\r\nimport { RHFTextBoxControl } from '../RHFControls/RHFTextBoxControl';\r\nimport { EventModel, EventState, EventType } from './Models/EventModel';\r\nimport { EventTypeValidation } from './Models/OutboundIntegrationModel';\r\nimport OutboundServices from './Services/OutboundServices';\r\nimport { ConfigurationTemplateModel } from './Models/ConfigurationTemplateModel';\r\nimport {useBranding} from \"../../hooks/useBranding\";\r\n\r\n//https://codesandbox.io/s/nelec?file=/src/StyleList.tsx\r\nexport interface IntegrationEventProps {\r\n event: MutableRefObject,\r\n isEventOpen: boolean,\r\n templateId: number,\r\n hideEventModal: () => void,\r\n loadEvents: () => void,\r\n showSuccessMessage: (message: string) => void,\r\n\r\n configurationTemplate?: React.MutableRefObject\r\n}\r\n\r\nfunction IntegrationEvent(props: IntegrationEventProps) {\r\n const { branding } = useBranding()\r\n const integrationEventForm = useForm({\r\n reValidateMode: \"onSubmit\",\r\n mode: \"all\"\r\n });\r\n const [eventTypeValidation, setEventTypeValidation] = useState()\r\n const [isErrorMessageEventVisible, { setTrue: showErrorEvent, setFalse: hideErrorEvent }] = useBoolean(false);\r\n const [message, setMessage] = useState(\"\");\r\n\r\n useEffect(() => {\r\n loadEventValidations()\r\n }, [props.isEventOpen])\r\n\r\n useEffect(() => {\r\n if (props.event.current !== undefined) {\r\n integrationEventForm.setValue(\"Name\", props.event.current!.Name)\r\n integrationEventForm.setValue(\"Description\", props.event.current!.Description)\r\n integrationEventForm.setValue(\"Event\", {\r\n text: getEventType(),\r\n key: getEventType()\r\n })\r\n } else {\r\n integrationEventForm.reset()\r\n }\r\n }, [props.event.current])\r\n\r\n const getEventType = () => {\r\n if ((props.event.current!.EventState !== null && props.event.current!.EventState !== undefined) && props.event.current!.EventState.trim() === EventState.Initial) {\r\n return EventType.OnManualInitial;\r\n } else if ((props.event.current!.EventState !== null && props.event.current!.EventState !== undefined) && props.event.current!.EventState.trim() === EventState.Subsequent) {\r\n return EventType.OnManualSubsequent;\r\n } else {\r\n return props.event.current!.EventType?.trim()\r\n }\r\n }\r\n\r\n const showErrorMessageEvent = (message: string) => {\r\n showErrorEvent()\r\n setMessage(message)\r\n setTimeout(function () {\r\n hideErrorEvent()\r\n }, 5000);\r\n }\r\n\r\n const titleId = useId('title');\r\n const theme = getTheme();\r\n const contentStyles = mergeStyleSets({\r\n container: {\r\n display: 'flex',\r\n flexFlow: 'column nowrap',\r\n alignItems: 'stretch',\r\n },\r\n header: [\r\n theme.fonts.xLargePlus,\r\n {\r\n flex: '1 1 auto',\r\n borderTop: `4px solid ${branding.theme.palette.themePrimary}`,\r\n color: theme.palette.black,\r\n display: 'flex',\r\n alignItems: 'center',\r\n fontWeight: FontWeights.semibold,\r\n padding: '12px 12px 14px 24px',\r\n },\r\n ],\r\n body: {\r\n flex: '4 4 auto',\r\n padding: '0 24px 24px 24px',\r\n overflowY: 'hidden',\r\n selectors: {\r\n p: { margin: '14px 0' },\r\n 'p:first-child': { marginTop: 0 },\r\n 'p:last-child': { marginBottom: 0 },\r\n },\r\n },\r\n });\r\n const iconButtonStyles = {\r\n root: {\r\n marginLeft: 'auto',\r\n marginTop: '4px',\r\n marginRight: '2px',\r\n },\r\n \r\n };\r\n const cancelIcon: IIconProps = { iconName: 'Cancel' };\r\n\r\n const create = () => {\r\n integrationEventForm.handleSubmit(\r\n async (data) => {\r\n let path = await Helper.getSite()\r\n OutboundServices.CreateEvent({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Description: data.Description,\r\n EventType: data.Event.key === EventType.OnManualInitial || data.Event.key === EventType.OnManualSubsequent ? \"Manual\" : data.Event.key,\r\n EventState: data.Event.key === EventType.OnManualInitial ? \"Initial\" : data.Event.key === EventType.OnManualSubsequent ? \"Subsequent\" : \"\",\r\n ForDisplay: false,\r\n Name: data.Name,\r\n Order: 1,\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n TemplateId: props.templateId,\r\n UserName: Helper.getUsername()\r\n }).then(res => {\r\n if (props.event !== undefined) {\r\n props.event.current?.Integrations.forEach(integration => {\r\n integration.Id = 0;\r\n integration.TemplateId = props.templateId\r\n OutboundServices.CreateIntegration({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n EventId: +res.Id,\r\n Integration: integration,\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n\r\n }).then((res) => {\r\n if (res.Success !== undefined && res.Success !== null && res.Success === true) {\r\n props.showSuccessMessage(\"Integration Event has been created successfully.\")\r\n props.loadEvents()\r\n hideModal(true)\r\n }\r\n else {\r\n let errorMessage = (res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\") ? res.ExceptionMessage : \"Something unexpected happened.\"\r\n showErrorMessageEvent(\"Error: \" + errorMessage)\r\n }\r\n });\r\n })\r\n\r\n }\r\n\r\n if (res.Success !== undefined && res.Success !== null && res.Success === true) {\r\n props.showSuccessMessage(\"Integration Event has been created successfully.\")\r\n hideModal(true)\r\n }\r\n else {\r\n let errorMessage = (res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\") ? res.ExceptionMessage : \"Something unexpected happened.\"\r\n showErrorMessageEvent(\"Error: \" + errorMessage)\r\n }\r\n })\r\n },\r\n (error) => {\r\n showErrorMessageEvent(\"Error: \" + error)\r\n }\r\n )();\r\n }\r\n\r\n const updateEvent = () => {\r\n integrationEventForm.handleSubmit(\r\n async (data) => {\r\n let path = await Helper.getSite()\r\n OutboundServices.UpdateEvent({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Description: data.Description,\r\n ForDisplay: props.event.current!.ForDisplay,\r\n Id: props.event.current!.Id,\r\n Name: data.Name,\r\n Order: props.event.current!.Order,\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n TemplateId: props.templateId,\r\n UserName: Helper.getUsername(),\r\n }).then(res => {\r\n if (res.Success !== undefined && res.Success !== null && res.Success === true) {\r\n props.showSuccessMessage(\"Integration Event has been updated successfully.\")\r\n props.loadEvents()\r\n hideModal(true)\r\n }\r\n else {\r\n let errorMessage = (res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\") ? res.ExceptionMessage : \"Something unexpected happened.\"\r\n showErrorMessageEvent(\"Error: \" + errorMessage)\r\n }\r\n })\r\n },\r\n (error) => {\r\n showErrorMessageEvent(\"Error: \" + error)\r\n }\r\n )();\r\n }\r\n\r\n const updateConfigurationTemplateEvent = async () => {\r\n let tempConfigurationTemplate = props.configurationTemplate!.current!;\r\n tempConfigurationTemplate.ObjectIntegrationConfig.Description = integrationEventForm.getValues(\"Description\")\r\n tempConfigurationTemplate.ObjectIntegrationConfig.Name = integrationEventForm.getValues(\"Name\")\r\n\r\n OutboundServices.UpdateConfigurationTemplate({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n ConfigurationTemplate: tempConfigurationTemplate!,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n }).then(res => {\r\n if (res.Success !== undefined && res.Success !== null && res.Success === true) {\r\n props.showSuccessMessage(\"Configuration Template has been updated successfully.\");\r\n hideModal(true);\r\n } else {\r\n let errorMessage = (res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\") ? res.ExceptionMessage : \"Something unexpected happened.\"\r\n showErrorMessageEvent(\"Error: \" + errorMessage)\r\n }\r\n })\r\n };\r\n\r\n const hideModal = (reloadEvents: boolean) => {\r\n integrationEventForm.reset()\r\n props.event.current = undefined\r\n\r\n if(props.configurationTemplate !== undefined) {\r\n props.configurationTemplate!.current = undefined;\r\n }\r\n\r\n props.hideEventModal()\r\n if(reloadEvents) {\r\n props.loadEvents()\r\n }\r\n }\r\n\r\n const loadEventValidations = async () => {\r\n let path = await Helper.getSite()\r\n OutboundServices.GetEvents({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n TemplateId: props.templateId\r\n }).then(res => {\r\n if (res.length > 0) {\r\n setEventTypeValidation({\r\n HasOnCloseEvent: res.filter(f => f.EventType.trim() === EventType.OnClose).length === 1,\r\n HasOnCreateEvent: res.filter(f => f.EventType.trim() === EventType.OnCreate).length === 1,\r\n HasOnUpdateEvent: res.filter(f => f.EventType.trim() === EventType.OnUpdate).length === 1\r\n });\r\n } else {\r\n setEventTypeValidation({\r\n HasOnCloseEvent: false,\r\n HasOnCreateEvent: false,\r\n HasOnUpdateEvent: false\r\n })\r\n }\r\n })\r\n }\r\n\r\n return (\r\n <>\r\n hideModal(false)}\r\n isBlocking={true}\r\n containerClassName={contentStyles.container}\r\n styles={{ main: { width: \"700px\" } }}\r\n >\r\n\r\n \r\n \r\n Outbound Integration\r\n hideModal(false)}\r\n />\r\n
\r\n \r\n
\r\n \r\n {isErrorMessageEventVisible ? (\r\n \r\n {message}\r\n \r\n ) : null}\r\n \r\n \r\n
\r\n \r\n \r\n Select the event that is required for your needs.
\r\n \r\n \r\n - OnCreate - executes when {branding.appName} creates a record. There can be 1 OnCreate event.
\r\n - OnUpdate- executes when {branding.appName} updates a record. There can be 1 OnUpdate event.
\r\n - OnClose - executes when close has been selected from Record -{'>'} Action -{'>'} Manage -{'>'} Close. There can be 1 OnClose event.
\r\n - OnClick - provides capability to build services that are linked to {branding.appName} Wizard for configuring service integration buttons to get data and map back to the {branding.appName} form and document. There can be many OnClick events.
\r\n - OnManual Initial - provides capability to build an integration menu under the Records -{'>'} Action -{'>'} Integration menu for members of the application audience to manually execute. There can be many OnManual events. The OnManual Initial command will be available if there is no indication that this event as been previously executed.
\r\n - OnManual Subsequent - provides capability to build an integration menu under the Records -{'>'} Action -{'>'} Integration menu for members of the application audience to manually execute. There can be many OnManual events. The OnManual Subsequent command will be available if there is an indication that an OnManual Initial event has been executed by referencing the SurrogateId.
\r\n
\r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n filter[0] !== EventType.None).map(item => {\r\n return {\r\n text: item[0], key: item[1], disabled: (eventTypeValidation !== undefined && ((eventTypeValidation.HasOnCloseEvent && item[0] === EventType.OnClose) ||\r\n (eventTypeValidation.HasOnCreateEvent && item[0] === EventType.OnCreate) || (eventTypeValidation.HasOnUpdateEvent && item[0] === EventType.OnUpdate))) ? true : false\r\n };\r\n })}\r\n required={true}\r\n disabled={(props.event.current !== undefined && props.event.current!.Id !== undefined && props.event.current!.Id) || props.configurationTemplate !== undefined ? true : false}\r\n title=\"Select method type.\"\r\n control={integrationEventForm.control}\r\n setValue={integrationEventForm.setValue}\r\n getValues={integrationEventForm.getValues}\r\n trigger={integrationEventForm.trigger}\r\n {...integrationEventForm.register(\"Event\", { required: \"Event is required.\" })}\r\n />\r\n \r\n \r\n
\r\n \r\n \r\n {\r\n props.configurationTemplate !== undefined && props.event.current!.Name !== \"\" && props.event.current!.Description !== \"\" ? :\r\n props.event.current !== undefined && props.event.current!.Id !== undefined && props.event.current!.Id > 0 ?\r\n \r\n :\r\n \r\n }\r\n \r\n \r\n \r\n \r\n >\r\n )\r\n}\r\n\r\nexport default IntegrationEvent","import { Modal, Stack, FontWeights, getTheme, mergeStyleSets, PrimaryButton, IconButton, Label, SpinnerSize, Spinner } from \"@fluentui/react\";\r\nimport React, { useEffect, useState } from \"react\";\r\nimport { useForm, FormProvider, Controller } from \"react-hook-form\";\r\nimport Helper from \"../../Helpers/Helper\";\r\nimport { RHFTextBoxControl } from \"../RHFControls/RHFTextBoxControl\";\r\nimport OutboundServices from \"./Services/OutboundServices\";\r\nimport { ConfigurationTemplateModel, CreateUpdateConfigurationTemplate } from \"./Models/ConfigurationTemplateModel\";\r\nimport RichTextEditor, { EditorValue } from \"react-rte\";\r\nimport { DEFAULT_RICHTOOLBAR } from \"../../Helpers/Utils\";\r\nimport { EventModel } from \"./Models/EventModel\";\r\nimport { useBoolean } from \"@fluentui/react-hooks\";\r\nimport {useBranding} from \"../../hooks/useBranding\";\r\n//https://codesandbox.io/s/nelec?file=/src/StyleList.tsx\r\n\r\ninterface ConfigurationTemplateProps {\r\n event: React.MutableRefObject\r\n hideConfigurationTemplateModal: () => void;\r\n showSuccessMessage: (message: string) => void;\r\n showErrorMessage: (message: string) => void;\r\n configurationTemplateToUpdate?: React.MutableRefObject | undefined;\r\n reloadConfigurationTemplates?: () => Promise\r\n}\r\n\r\nconst theme = getTheme();\r\nconst iconButtonStyles = {\r\n root: {\r\n marginLeft: \"auto\",\r\n marginTop: \"4px\",\r\n marginRight: \"2px\",\r\n },\r\n \r\n};\r\n\r\nfunction ConfigurationTemplate(props: ConfigurationTemplateProps) {\r\n const { branding } = useBranding()\r\n const [editorState, setEditorState] = useState(EditorValue.createEmpty())\r\n const [isLoadingVisible, { setTrue: showLoading, setFalse: hideLoading }] = useBoolean(false);\r\n const [loadingMessage, setLoadingMessage] = useState(\"\");\r\n\r\n const contentStyles = mergeStyleSets({\r\n container: {\r\n display: \"flex\",\r\n flexFlow: \"column nowrap\",\r\n alignItems: \"stretch\",\r\n },\r\n header: [\r\n theme.fonts.xLargePlus,\r\n {\r\n flex: \"1 1 auto\",\r\n borderTop: `4px solid ${branding.theme.palette.themePrimary}`,\r\n color: theme.palette.black,\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n fontWeight: FontWeights.semibold,\r\n padding: \"12px 12px 14px 24px\",\r\n },\r\n ],\r\n body: {\r\n flex: \"4 4 auto\",\r\n padding: \"0 24px 24px 24px\",\r\n overflowY: \"hidden\",\r\n selectors: {\r\n p: { margin: \"14px 0\" },\r\n \"p:first-child\": { marginTop: 0 },\r\n \"p:last-child\": { marginBottom: 0 },\r\n },\r\n },\r\n });\r\n\r\n const configurationTemplateForm = useForm({\r\n reValidateMode: \"onSubmit\",\r\n mode: \"all\",\r\n defaultValues: {},\r\n shouldUnregister: false,\r\n });\r\n\r\n useEffect(() => {\r\n configurationTemplateForm.register(\"Name\", { required: \"Name is required.\" });\r\n configurationTemplateForm.register(\"Description\", { required: \"Description is required.\" });\r\n configurationTemplateForm.register(\"Category\", { required: \"Category is required.\" });\r\n configurationTemplateForm.register(\"Instructions\", { required: \"Instructions are required.\" });\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (props.configurationTemplateToUpdate !== undefined && props.configurationTemplateToUpdate!.current !== undefined) {\r\n loadConfigurationTempalteValues();\r\n }\r\n }, [props.configurationTemplateToUpdate]);\r\n\r\n const showLoadingMessage = (message: string) => {\r\n setLoadingMessage(message)\r\n showLoading()\r\n }\r\n\r\n const loadConfigurationTempalteValues = () => {\r\n configurationTemplateForm.setValue(\"Name\", props.configurationTemplateToUpdate!.current!.Name);\r\n configurationTemplateForm.setValue(\"Description\", props.configurationTemplateToUpdate!.current!.Description);\r\n configurationTemplateForm.setValue(\"Category\", props.configurationTemplateToUpdate!.current!.Category);\r\n\r\n setEditorState(() => {\r\n return EditorValue.createFromString(props.configurationTemplateToUpdate!.current!.Instructions, 'html')\r\n })\r\n configurationTemplateForm.setValue('Instructions', props.configurationTemplateToUpdate!.current!.Instructions)\r\n };\r\n\r\n const hideConfigurationTemplateModal = () => {\r\n configurationTemplateForm.reset()\r\n props.hideConfigurationTemplateModal()\r\n if (props.configurationTemplateToUpdate !== undefined && props.configurationTemplateToUpdate!.current !== undefined) {\r\n props.configurationTemplateToUpdate!.current = undefined\r\n }\r\n\r\n props.event!.current = undefined\r\n };\r\n\r\n const CreateConfigurationTemplate = () => {\r\n showLoadingMessage(\"Creating Configuration Template\")\r\n configurationTemplateForm.handleSubmit(\r\n async (data) => {\r\n let currentEvent = props.event!.current;\r\n currentEvent!.TemplateId = 0;\r\n currentEvent?.Integrations.forEach(item => {\r\n item.TemplateId = 0;\r\n item.ObjectAuthenticationProperties.ObjectBasicToken.Password = \"\";\r\n item.ObjectAuthenticationProperties.ObjectBasicToken.Username = \"\";\r\n item.ObjectAuthenticationProperties.BearerToken = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.AccessToken = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.ClientId = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.ClientSecret = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.RefreshToken = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.AssertionCertPassword = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.AssertionFileName = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.new_token = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.Password = \"\";\r\n item.ObjectAuthenticationProperties.OAuth20Prop.Username = \"\";\r\n item.ObjectAuthenticationProperties.BasicToken = \"\";\r\n item.ObjectMapInput.MapInput.Params.ObjectSurrogateFilter.forEach(surrogate => {\r\n surrogate.IntegrationId = 0;\r\n surrogate.TemplateId = 0;\r\n })\r\n })\r\n\r\n const configurationTemplate: CreateUpdateConfigurationTemplate = {\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n ConfigurationTemplate: {\r\n Active: true,\r\n Category: configurationTemplateForm.getValues(\"Category\"),\r\n Description: configurationTemplateForm.getValues(\"Description\"),\r\n Id: 1,\r\n Instructions: configurationTemplateForm.getValues(\"Instructions\"),\r\n IntegrationConfig: \"\",\r\n ObjectIntegrationConfig: currentEvent!,\r\n Name: configurationTemplateForm.getValues(\"Name\")\r\n },\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n }\r\n OutboundServices.CreateConfigurationTemplate(configurationTemplate).then((res) => {\r\n if (res.Success !== undefined && res.Success !== null && res.Success === true) {\r\n props.showSuccessMessage(\"Configuration Template has been saved successfully.\");\r\n hideConfigurationTemplateModal();\r\n } else {\r\n let errorMessage = res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\" ? res.ExceptionMessage : \"Something unexpected happened.\";\r\n props.showErrorMessage(\"Error: \" + errorMessage);\r\n }\r\n hideLoading()\r\n })\r\n },\r\n (errors) => {\r\n props.showErrorMessage(`Error: ${Object.values(errors).map((item: any) => item.message).join(\"|\")}`);\r\n hideLoading()\r\n }\r\n )();\r\n };\r\n\r\n const UpdateConfigurationTemplate = () => {\r\n showLoadingMessage(\"Updating Configuration Template\")\r\n configurationTemplateForm.handleSubmit(\r\n async (data) => {\r\n OutboundServices.GetConfigurationTemplateById({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Id: props.configurationTemplateToUpdate!.current!.Id,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n }).then(async (res) => {\r\n const configurationTemplate: CreateUpdateConfigurationTemplate = {\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n ConfigurationTemplate: {\r\n Active: true,\r\n Category: configurationTemplateForm.getValues(\"Category\"),\r\n Description: configurationTemplateForm.getValues(\"Description\"),\r\n Id: props.configurationTemplateToUpdate!.current!.Id,\r\n Instructions: configurationTemplateForm.getValues(\"Instructions\"),\r\n IntegrationConfig: \"\",\r\n ObjectIntegrationConfig: res[0].ObjectIntegrationConfig,\r\n Name: configurationTemplateForm.getValues(\"Name\")\r\n },\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n }\r\n OutboundServices.UpdateConfigurationTemplate(configurationTemplate).then((res) => {\r\n if (res.Success !== undefined && res.Success !== null && res.Success === true) {\r\n props.showSuccessMessage(\"Configuration Template has been updated successfully.\");\r\n hideConfigurationTemplateModal();\r\n if (props.reloadConfigurationTemplates !== undefined)\r\n props.reloadConfigurationTemplates();\r\n\r\n } else {\r\n let errorMessage = res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\" ? res.ExceptionMessage : \"Something unexpected happened.\";\r\n props.showErrorMessage(\"Error: \" + errorMessage);\r\n }\r\n hideLoading()\r\n })\r\n })\r\n },\r\n (errors) => {\r\n props.showErrorMessage(`Error: ${Object.values(errors).map((item: any) => item.message).join(\"|\")}`);\r\n hideLoading()\r\n }\r\n )();\r\n };\r\n\r\n const handleRichTextChange = (value: EditorValue) => {\r\n configurationTemplateForm.setValue('Instructions', value.toString('html'))\r\n setEditorState(value)\r\n }\r\n\r\n return (\r\n <>\r\n \r\n \r\n \r\n
Save Configuration as Template
\r\n
\r\n
\r\n {isLoadingVisible ?\r\n :\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n {\r\n return ()\r\n }} />\r\n {configurationTemplateForm.formState.errors !== undefined && configurationTemplateForm.formState.errors[\"Instructions\"] !== undefined && configurationTemplateForm.formState.errors[\"Instructions\"]!.message!.toString().length > 0 ?\r\n {configurationTemplateForm.formState.errors[\"Instructions\"]!.message}\r\n : null\r\n }\r\n \r\n \r\n
\r\n \r\n \r\n {\r\n props.configurationTemplateToUpdate?.current !== undefined ?\r\n :\r\n \r\n }\r\n \r\n \r\n \r\n
\r\n }\r\n \r\n \r\n >\r\n );\r\n}\r\n\r\nexport default ConfigurationTemplate;","import { Text, Modal, Stack, FontWeights, getTheme, mergeStyleSets, IconButton, SelectionMode, IContextualMenuProps, IContextualMenuItem, TextField, DetailsList, DetailsListLayoutMode, ConstrainMode, IRenderFunction, IDetailsGroupDividerProps, IGroupDividerProps, MessageBar, Spinner, SpinnerSize } from \"@fluentui/react\";\r\nimport React, { useEffect, useRef, useState } from \"react\";\r\nimport { IGroup } from 'office-ui-fabric-react/lib/GroupedList';\r\nimport { DetailsRow } from 'office-ui-fabric-react/lib/DetailsList';\r\nimport Helper from \"../../Helpers/Helper\";\r\nimport OutboundServices from \"./Services/OutboundServices\";\r\nimport { ConfigurationTemplateModel } from \"./Models/ConfigurationTemplateModel\";\r\nimport { OutboundIntegrationModel } from \"./Models/OutboundIntegrationModel\";\r\nimport { EventModel, EventType } from \"./Models/EventModel\";\r\nimport { useBoolean } from \"@fluentui/react-hooks\";\r\nimport ConfigurationTemplate from \"./ConfigurationTemplate\";\r\nimport IntegrationEvent from \"./IntegrationEvent\";\r\nimport OutboundIntegration from \"./OutboundIntegration\";\r\nimport InfiniteScroll from \"react-infinite-scroll-component\";\r\nimport {useBranding} from \"../../hooks/useBranding\";\r\n//https://codesandbox.io/s/nelec?file=/src/StyleList.tsx\r\n\r\ninterface ConfigurationTemplateProps {\r\n clientEvents: IGroup[];\r\n isConfigurationTemplateListModaOpen: boolean;\r\n isAdminMenu: boolean;\r\n hideConfigurationTemplateListModal: () => void;\r\n loadEvents: () => Promise;\r\n templateId: number;\r\n}\r\n\r\nconst theme = getTheme();\r\nconst iconButtonStyles = {\r\n root: {\r\n marginLeft: \"auto\",\r\n marginTop: \"4px\",\r\n marginRight: \"2px\",\r\n },\r\n \r\n};\r\n\r\nfunction ConfigurationTemplateList(props: ConfigurationTemplateProps) {\r\n const { branding } = useBranding()\r\n const [configurationTemplateList, setConfigurationTemplateList] = useState([])\r\n const [filteredConfigurationTemplateList, setFilteredConfigurationTemplateList] = useState([])\r\n const [outboundIntegrations, setOutboundIntegrations] = useState([]);\r\n\r\n const [isConfigurationTemplateModalOpen, { setTrue: showConfigurationTemplateModal, setFalse: hideConfigurationTemplateModal }] = useBoolean(false);\r\n const [isEventOpen, { setTrue: showEventModal, setFalse: hideEventModal }] = useBoolean(false);\r\n const event = useRef();\r\n const configurationTemplate = useRef();\r\n const [isErrorMessageCTLVisible, { setTrue: showErrorCTL, setFalse: hideErrorCTL }] = useBoolean(false);\r\n const [isSuccessMessageCTLVisible, { setTrue: showSuccessCTL, setFalse: hideSuccessCTL }] = useBoolean(false);\r\n const [message, setMessage] = useState(\"\");\r\n\r\n const [isOutboundIntegrationOpen, { setTrue: showOutboundIntegrationModal, setFalse: hideOutboundIntegrationModal }] = useBoolean(false);\r\n const outboundIntegration = useRef();\r\n const [isConfigurationTemplateReadMode, { setTrue: setConfigurationTemplateReadMode, setFalse: setConfigurationTemplateEditMode }] = useBoolean(false);\r\n const [isLoadingVisible, { setTrue: showLoading, setFalse: hideLoading }] = useBoolean(false);\r\n const [loadingMessage, setLoadingMessage] = useState(\"\");\r\n\r\n const [pageCount, setPageCount] = useState(1);\r\n const [hasMore, setHasMore] = useState(true);\r\n const [isScrolling, setIsScrolling] = useState(false);\r\n const searchContent = useRef(\"\")\r\n let startIndexIntegration = useRef(0);\r\n const recordsPerPage = 10;\r\n\r\n const contentStyles = mergeStyleSets({\r\n container: {\r\n display: \"flex\",\r\n flexFlow: \"column nowrap\",\r\n alignItems: \"stretch\",\r\n },\r\n header: [\r\n theme.fonts.xLargePlus,\r\n {\r\n flex: \"1 1 auto\",\r\n borderTop: `4px solid ${branding.theme.palette.themePrimary}`,\r\n color: theme.palette.black,\r\n display: \"flex\",\r\n alignItems: \"center\",\r\n fontWeight: FontWeights.semibold,\r\n padding: \"12px 12px 14px 24px\",\r\n },\r\n ],\r\n body: {\r\n flex: \"4 4 auto\",\r\n padding: \"0 24px 24px 24px\",\r\n overflowY: \"hidden\",\r\n selectors: {\r\n p: { margin: \"14px 0\" },\r\n \"p:first-child\": { marginTop: 0 },\r\n \"p:last-child\": { marginBottom: 0 },\r\n },\r\n },\r\n });\r\n\r\n\r\n useEffect(() => {\r\n getConfigurationTemplates()\r\n }, []);\r\n\r\n const hideModal = () => {\r\n props.hideConfigurationTemplateListModal()\r\n }\r\n\r\n const showErrorMessageCTL = (message: string) => {\r\n showErrorCTL()\r\n setMessage(message)\r\n setTimeout(function () {\r\n hideErrorCTL()\r\n }, 5000);\r\n }\r\n\r\n const showSuccessMessageCTL = (message: string) => {\r\n showSuccessCTL()\r\n setMessage(message)\r\n setTimeout(function () {\r\n hideSuccessCTL()\r\n }, 5000);\r\n }\r\n\r\n const showLoadingMessage = (message: string) => {\r\n setLoadingMessage(message)\r\n showLoading()\r\n }\r\n\r\n const hideEventModalCustom = () => {\r\n setPageCount(1);\r\n setHasMore(true);\r\n setIsScrolling(false);\r\n searchContent.current = \"\"\r\n startIndexIntegration.current = 0\r\n hideEventModal()\r\n }\r\n\r\n const getAdminMenu = (groupProps: IDetailsGroupDividerProps | undefined): IContextualMenuItem[] => {\r\n if (groupProps!.group!.key.indexOf(\"ConfigurationTemplate_\") >= 0) {\r\n return [\r\n {\r\n key: \"editConfigurationTemplate\",\r\n text: \"Edit Information\",\r\n title: \"Edit Information.\",\r\n onClick: () => {\r\n configurationTemplate!.current = groupProps!.group?.data as ConfigurationTemplateModel\r\n showConfigurationTemplateModal()\r\n }\r\n },\r\n {\r\n key: \"delete\",\r\n text: \"Delete\",\r\n title: \"Delete Configuration Template.\",\r\n onClick: async () => {\r\n showLoadingMessage(\"Deleting Configuration Template\")\r\n OutboundServices.GetConfigurationTemplateById({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Id: groupProps!.group?.data.Id,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n }).then(async (res: ConfigurationTemplateModel[]) => {\r\n OutboundServices.DeleteConfigurationTemplate({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n ConfigurationTemplate: res[0],\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n SessionKey: Helper.getSessionKey()\r\n }).then(res => {\r\n if (res.Success) {\r\n showSuccessMessageCTL(res.Description)\r\n } else {\r\n showErrorMessageCTL(`${res.Description} | ${res.ExceptionMessage}`)\r\n }\r\n getConfigurationTemplates()\r\n hideLoading()\r\n })\r\n })\r\n }\r\n },\r\n {\r\n key: \"activate\",\r\n text: groupProps!.group?.data.Active ? \"Deactivate\" : \"Activate\",\r\n title: groupProps!.group?.data.Active ? \"Deactivate Configuration Template.\" : \"Activate Configuration Template.\",\r\n onClick: async () => {\r\n showLoadingMessage(`${groupProps!.group?.data.Active ? \"Deactivating\" : \"Activating\"} Configuration Template`)\r\n OutboundServices.GetConfigurationTemplateById({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Id: groupProps!.group?.data.Id,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername()\r\n }).then(async (res: ConfigurationTemplateModel[]) => {\r\n let tempItem = res[0];\r\n tempItem.Active = !tempItem.Active\r\n OutboundServices.UpdateConfigurationTemplate({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n ConfigurationTemplate: tempItem,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n SessionKey: Helper.getSessionKey()\r\n }).then(res => {\r\n if (res.Success) {\r\n showSuccessMessageCTL(res.Description)\r\n } else {\r\n showErrorMessageCTL(`${res.Description} | ${res.ExceptionMessage}`)\r\n }\r\n getConfigurationTemplates()\r\n hideLoading()\r\n })\r\n })\r\n }\r\n }\r\n ]\r\n }\r\n\r\n if (groupProps!.group!.key.indexOf(\"Event_\") >= 0) {\r\n return [\r\n {\r\n key: \"viewConfigurationTemplateEvent\",\r\n text: \"View Event Read Mode\",\r\n title: \"View Event Read Mode.\",\r\n onClick: (ev?: | React.MouseEvent | React.KeyboardEvent, item?: IContextualMenuItem) => {\r\n configurationTemplate.current = undefined\r\n event.current = groupProps!.group!.data as EventModel;\r\n showEventModal();\r\n }\r\n },\r\n {\r\n key: \"edit\",\r\n text: \"Edit Event\",\r\n title: \"Edit Event.\",\r\n onClick: (ev?: | React.MouseEvent | React.KeyboardEvent, item?: IContextualMenuItem) => {\r\n event.current = groupProps!.group!.data as EventModel;\r\n configurationTemplate!.current = configurationTemplateList.find(confTemplate => (confTemplate.data as ConfigurationTemplateModel).ObjectIntegrationConfig.Id === (groupProps!.group!.data as EventModel).Id)?.data as ConfigurationTemplateModel\r\n showEventModal();\r\n }\r\n }\r\n ]\r\n }\r\n return []\r\n }\r\n\r\n const loadUseTemplateEvent = async (currentConfigurationTemplate: ConfigurationTemplateModel) => {\r\n currentConfigurationTemplate.ObjectIntegrationConfig.Name = \"\";\r\n currentConfigurationTemplate.ObjectIntegrationConfig.Description = \"\";\r\n currentConfigurationTemplate.ObjectIntegrationConfig.Id = 0;\r\n currentConfigurationTemplate.ObjectIntegrationConfig.TemplateId = props.templateId\r\n currentConfigurationTemplate.ObjectIntegrationConfig.Integrations.forEach(integration => {\r\n integration.ObjectMapInput.MapInput.Params.ObjectSurrogateFilter.forEach(surrogate => {\r\n surrogate.TemplateId = props.templateId\r\n })\r\n })\r\n event.current = currentConfigurationTemplate.ObjectIntegrationConfig\r\n showEventModal()\r\n }\r\n\r\n const getClientMenu = (groupProps: IDetailsGroupDividerProps | undefined): IContextualMenuItem[] => {\r\n if (groupProps!.group!.key.indexOf(\"ConfigurationTemplate_\") >= 0) {\r\n return [\r\n {\r\n key: \"useConfigurationTemplate\",\r\n text: \"Use Configuration Template\",\r\n title: props.clientEvents.filter(clientEvent => {\r\n const event = clientEvent.data as EventModel;\r\n const configurationTemplateEvent = groupProps!.group?.data as ConfigurationTemplateModel;\r\n return event.EventType.trim() === configurationTemplateEvent.ObjectIntegrationConfig.EventType.trim()\r\n }).length > 0 && (\r\n (groupProps!.group?.data as ConfigurationTemplateModel).ObjectIntegrationConfig.EventType.trim() === EventType.OnCreate ||\r\n (groupProps!.group?.data as ConfigurationTemplateModel).ObjectIntegrationConfig.EventType.trim() === EventType.OnClose ||\r\n (groupProps!.group?.data as ConfigurationTemplateModel).ObjectIntegrationConfig.EventType.trim() === EventType.OnUpdate) ? \"You already have one event of this type\" : \"Use Configuration Template\",\r\n disabled: props.clientEvents.filter(clientEvent => {\r\n const event = clientEvent.data as EventModel;\r\n const configurationTemplateEvent = groupProps!.group?.data as ConfigurationTemplateModel;\r\n return event.EventType.trim() === configurationTemplateEvent.ObjectIntegrationConfig.EventType.trim()\r\n }).length > 0 && (\r\n (groupProps!.group?.data as ConfigurationTemplateModel).ObjectIntegrationConfig.EventType.trim() === EventType.OnCreate ||\r\n (groupProps!.group?.data as ConfigurationTemplateModel).ObjectIntegrationConfig.EventType.trim() === EventType.OnClose ||\r\n (groupProps!.group?.data as ConfigurationTemplateModel).ObjectIntegrationConfig.EventType.trim() === EventType.OnUpdate),\r\n onClick: () => {\r\n configurationTemplate!.current = groupProps!.group?.data;\r\n loadUseTemplateEvent(groupProps!.group?.data)\r\n }\r\n }\r\n ]\r\n }\r\n if (groupProps!.group!.key.indexOf(\"Event_\") >= 0) {\r\n return [\r\n {\r\n key: \"viewConfigurationTemplateEvent\",\r\n text: \"View Event Read Mode\",\r\n title: \"View Event Read Mode.\",\r\n onClick: (ev?: | React.MouseEvent | React.KeyboardEvent, item?: IContextualMenuItem) => {\r\n configurationTemplate.current = undefined\r\n event.current = groupProps!.group!.data as EventModel;\r\n showEventModal();\r\n }\r\n }\r\n ]\r\n }\r\n return []\r\n }\r\n\r\n const getConfigurationTemplateMenu = (groupProps: IDetailsGroupDividerProps | undefined): IContextualMenuProps => {\r\n return {\r\n shouldFocusOnMount: true,\r\n items: props.isAdminMenu ? getAdminMenu(groupProps) : getClientMenu(groupProps)\r\n };\r\n }\r\n\r\n const getIntegrationEventsMenu = (item: OutboundIntegrationModel): IContextualMenuProps => {\r\n let adminMenu = [\r\n {\r\n key: \"edit\",\r\n text: \"View Service Read Mode\",\r\n title: \"View Service Read Mode.\",\r\n onClick: () => {\r\n configurationTemplate!.current = configurationTemplateList.find(confTemplate => (confTemplate.data as ConfigurationTemplateModel).ObjectIntegrationConfig.Integrations.find(integration => integration.Id === item.Id) !== undefined)?.data\r\n event.current = configurationTemplate!.current?.ObjectIntegrationConfig\r\n outboundIntegration.current = item;\r\n showOutboundIntegrationModal();\r\n setConfigurationTemplateReadMode();\r\n }\r\n },\r\n {\r\n key: \"editConfigurationTemplateIntegration\",\r\n text: \"Edit Service\",\r\n title: \"Edit Service.\",\r\n onClick: () => {\r\n configurationTemplate!.current = configurationTemplateList.find(confTemplate => (confTemplate.data as ConfigurationTemplateModel).ObjectIntegrationConfig.Integrations.find(integration => integration.Id === item.Id) !== undefined)?.data\r\n event.current = configurationTemplate!.current?.ObjectIntegrationConfig\r\n outboundIntegration.current = item;\r\n showOutboundIntegrationModal();\r\n setConfigurationTemplateEditMode();\r\n }\r\n },\r\n ]\r\n\r\n let clientMenu = [\r\n {\r\n key: \"edit\",\r\n text: \"View Service Read Mode\",\r\n title: \"View Service Read Mode.\",\r\n onClick: () => {\r\n configurationTemplate!.current = configurationTemplateList.find(confTemplate => (confTemplate.data as ConfigurationTemplateModel).ObjectIntegrationConfig.Integrations.find(integration => integration.Id === item.Id) !== undefined)?.data\r\n event.current = configurationTemplate!.current?.ObjectIntegrationConfig\r\n outboundIntegration.current = item;\r\n showOutboundIntegrationModal();\r\n setConfigurationTemplateReadMode();\r\n }\r\n }\r\n ]\r\n\r\n return {\r\n shouldFocusOnMount: true,\r\n items: props.isAdminMenu ? adminMenu : clientMenu\r\n };\r\n };\r\n\r\n const getConfigurationTemplates = async () => {\r\n showLoadingMessage(\"Loading Configuration Templates\")\r\n OutboundServices.GetConfigurationTemplateList({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Content: searchContent.current,\r\n PageNo: 1,\r\n Path: await Helper.getSite(),\r\n RecordsPerPage: recordsPerPage,\r\n SessionKey: Helper.getSessionKey(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n }).then(res => {\r\n\r\n let tempConfigurationTemplates: IGroup[] = [];\r\n let tempOutboundIntegrations: OutboundIntegrationModel[] = [];\r\n let _startIndexConfigurationTemplate: number = 0;\r\n res.forEach(item => {\r\n tempConfigurationTemplates.push({\r\n key: \"ConfigurationTemplate_\" + item.Id.toString(),\r\n name: item.Name,\r\n startIndex: _startIndexConfigurationTemplate,\r\n count: 1,\r\n level: 0,\r\n data: item,\r\n isDropEnabled: false,\r\n isCollapsed: true,\r\n isShowingAll: false,\r\n hasMoreData: false,\r\n children: [{\r\n key: \"Event_\" + item.ObjectIntegrationConfig.Id.toString(),\r\n name: item.ObjectIntegrationConfig.Name,\r\n startIndex: startIndexIntegration.current,\r\n count: item.ObjectIntegrationConfig.Integrations.length,\r\n level: 1,\r\n data: item.ObjectIntegrationConfig,\r\n isDropEnabled: false,\r\n isCollapsed: true,\r\n isShowingAll: false,\r\n hasMoreData: false,\r\n children: []\r\n }]\r\n })\r\n tempOutboundIntegrations.push(...item.ObjectIntegrationConfig.Integrations)\r\n startIndexIntegration.current += item.ObjectIntegrationConfig.Integrations.length;\r\n })\r\n\r\n setOutboundIntegrations(tempOutboundIntegrations);\r\n\r\n if (props.isAdminMenu) {\r\n setConfigurationTemplateList(tempConfigurationTemplates)\r\n setFilteredConfigurationTemplateList(tempConfigurationTemplates)\r\n } else {\r\n setConfigurationTemplateList(tempConfigurationTemplates.filter(f => f.data.Active))\r\n setFilteredConfigurationTemplateList(tempConfigurationTemplates.filter(f => f.data.Active))\r\n }\r\n hideLoading()\r\n })\r\n }\r\n\r\n const onFilter = (ev: React.FormEvent, text?: string): void => {\r\n setPageCount(1)\r\n searchContent.current = text !== undefined ? text : \"\"\r\n if (text !== undefined && text.length === 0) {\r\n setIsScrolling(false)\r\n setHasMore(true)\r\n }\r\n setTimeout(function () {\r\n getConfigurationTemplates()\r\n }, 1000);\r\n }\r\n\r\n const onRenderGroupHeader: IRenderFunction = (groupProps) => {\r\n if (groupProps) {\r\n return (\r\n {\r\n return (\r\n {\r\n onToggleCollapse(groupProps);\r\n }}\r\n />\r\n );\r\n },\r\n isResizable: false,\r\n styles: {\r\n root: { paddingLeft: 2, paddingRight: 0 },\r\n },\r\n },\r\n {\r\n key: \"name\",\r\n name: \"Name \",\r\n fieldName: \"Name\",\r\n minWidth: 300,\r\n maxWidth: 300,\r\n onRender: (item) => {\r\n return (\r\n \r\n {groupProps.group!.data.Name}\r\n
\r\n );\r\n },\r\n isResizable: false,\r\n styles: {\r\n root: { paddingLeft: 0, paddingRight: 0 },\r\n }\r\n },\r\n {\r\n key: \"description\",\r\n name: \"Description\",\r\n fieldName: \"Description\",\r\n minWidth: 450,\r\n maxWidth: 450,\r\n onRender: (item) => {\r\n return (\r\n \r\n {groupProps.group!.data.Description}\r\n
\r\n );\r\n },\r\n isResizable: true\r\n },\r\n {\r\n key: \"eventType\",\r\n name: \"Event Type\",\r\n fieldName: \"EventType\",\r\n minWidth: 120,\r\n maxWidth: 120,\r\n onRender: (item) => {\r\n return (\r\n\r\n \r\n {\r\n groupProps!.group!.key.indexOf(\"Event_\") >= 0 ?\r\n groupProps.group!.data.EventType : \"\"}\r\n
\r\n );\r\n },\r\n isResizable: true\r\n },\r\n {\r\n key: \"method\",\r\n name: \"Method\",\r\n fieldName: \"Method\",\r\n minWidth: 60,\r\n maxWidth: 60,\r\n onRender: (item) => {\r\n return ;\r\n },\r\n isResizable: true\r\n },\r\n {\r\n key: \"authoirzation\",\r\n name: \"Authorization\",\r\n minWidth: 100,\r\n maxWidth: 100,\r\n onRender: (item) => {\r\n return ;\r\n },\r\n isResizable: true\r\n },\r\n {\r\n key: \"actions\",\r\n name: \"Actions\",\r\n onRender: (item: any) => {\r\n\r\n return (\r\n = 0 ? \"25px\" : \"40px\", display: \"block\", textAlign: \"right\" }}>\r\n \r\n
\r\n );\r\n },\r\n minWidth: 100,\r\n maxWidth: 100,\r\n isResizable: true\r\n },\r\n ]}\r\n selectionMode={SelectionMode.none}\r\n item={groupProps.group!.data}\r\n itemIndex={0}\r\n cellStyleProps={{\r\n cellExtraRightPadding: 0,\r\n cellLeftPadding: 2,\r\n cellRightPadding: 2\r\n }}\r\n />\r\n );\r\n }\r\n return null;\r\n }\r\n\r\n const onToggleCollapse = (props: IGroupDividerProps): void => {\r\n props.onToggleCollapse!(props.group!);\r\n }\r\n\r\n const fetchMoreData = () => {\r\n setIsScrolling(true)\r\n const page = pageCount + 1\r\n\r\n OutboundServices.GetConfigurationTemplateList({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Content: searchContent.current,\r\n PageNo: page,\r\n Path: window.sessionStorage.getItem(\"site\")!,\r\n RecordsPerPage: recordsPerPage,\r\n SessionKey: Helper.getSessionKey(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n }).then(res => {\r\n let tempConfigurationTemplates: IGroup[] = [];\r\n let tempOutboundIntegrations: OutboundIntegrationModel[] = [];\r\n let _startIndexConfigurationTemplate: number = 0;\r\n res.forEach(item => {\r\n tempConfigurationTemplates.push({\r\n key: \"ConfigurationTemplate_\" + item.Id.toString(),\r\n name: item.Name,\r\n startIndex: _startIndexConfigurationTemplate,\r\n count: 1,\r\n level: 0,\r\n data: item,\r\n isDropEnabled: false,\r\n isCollapsed: true,\r\n isShowingAll: false,\r\n hasMoreData: false,\r\n children: [{\r\n key: \"Event_\" + item.ObjectIntegrationConfig.Id.toString(),\r\n name: item.ObjectIntegrationConfig.Name,\r\n startIndex: startIndexIntegration.current,\r\n count: item.ObjectIntegrationConfig.Integrations.length,\r\n level: 1,\r\n data: item.ObjectIntegrationConfig,\r\n isDropEnabled: false,\r\n isCollapsed: true,\r\n isShowingAll: false,\r\n hasMoreData: false,\r\n children: []\r\n\r\n }]\r\n })\r\n tempOutboundIntegrations.push(...item.ObjectIntegrationConfig.Integrations)\r\n startIndexIntegration.current += item.ObjectIntegrationConfig.Integrations.length;\r\n })\r\n setOutboundIntegrations((prev) => [...prev, ...tempOutboundIntegrations]);\r\n setPageCount(prev => prev + 1 )\r\n if (tempConfigurationTemplates.length < recordsPerPage) {\r\n setHasMore(false)\r\n }\r\n\r\n if (props.isAdminMenu) {\r\n setConfigurationTemplateList((prev) => [...prev, ...tempConfigurationTemplates])\r\n setFilteredConfigurationTemplateList((prev) => [...prev, ...tempConfigurationTemplates])\r\n } else {\r\n setConfigurationTemplateList((prev) => [...prev, ...tempConfigurationTemplates.filter(f => f.data.Active)])\r\n setFilteredConfigurationTemplateList((prev) => [...prev, ...tempConfigurationTemplates.filter(f => f.data.Active)])\r\n }\r\n setIsScrolling(false)\r\n\r\n })\r\n }\r\n\r\n const customHideOutboundIntegrationModal = () => {\r\n setPageCount(1);\r\n setHasMore(true);\r\n setIsScrolling(false);\r\n searchContent.current = \"\"\r\n startIndexIntegration.current = 0\r\n hideOutboundIntegrationModal()\r\n }\r\n\r\n return (\r\n <>\r\n \r\n \r\n
Configuration Template
\r\n
\r\n
\r\n\r\n \r\n {props.isAdminMenu ? null :
\r\n \r\n \r\n Choose any of the preconfigured outbound integrations from the list below by selecting “Use Configuration Template” from the first-level context menu. If you’d like to know more about service before making a selection, expand the first-level menu and then select “View Event Read Mode” from the context menu and explore the properties.\r\n \r\n \r\n }\r\n
\r\n \r\n {isErrorMessageCTLVisible ? (\r\n \r\n {message}\r\n \r\n ) : null}\r\n {isSuccessMessageCTLVisible ? (\r\n \r\n {message}\r\n \r\n ) : null}\r\n \r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n {isLoadingVisible ?\r\n :\r\n \r\n }\r\n \r\n \r\n
\r\n\r\n\r\n \r\n {isConfigurationTemplateModalOpen ?\r\n \r\n : null}\r\n\r\n {isEventOpen ? (\r\n ) : null}\r\n\r\n {isOutboundIntegrationOpen ? (\r\n \r\n ) : null}\r\n\r\n\r\n >\r\n );\r\n}\r\n\r\nexport default ConfigurationTemplateList;","import { Text, ConstrainMode, DetailsList, DetailsListLayoutMode, IconButton, IContextualMenuProps, IDetailsListStyles, IGroup, SelectionMode, Separator, IDragDropEvents, IDetailsGroupDividerProps, IRenderFunction, IGroupDividerProps, DetailsRow, IColumn, IContextualMenuItem, PrimaryButton, Link, Stack, GroupHeader, ScrollablePane, ScrollbarVisibility } from \"@fluentui/react\";\r\nimport React, { useEffect, useRef, useState } from \"react\";\r\nimport _ from \"lodash\";\r\nimport { DragAndDropModel, OutboundIntegrationModel, UpdateOutboundIntegration } from \"./Models/OutboundIntegrationModel\";\r\nimport OutboundIntegration from \"./OutboundIntegration\";\r\nimport { useBoolean } from \"@fluentui/react-hooks\";\r\nimport Helper, { IBaseRequest } from \"../../Helpers/Helper\";\r\nimport OutboundServices from \"./Services/OutboundServices\";\r\nimport Confirmation from \"../Settings/Confirmation\";\r\nimport { isMobile } from \"react-device-detect\";\r\nimport IntegrationEvent from \"./IntegrationEvent\";\r\nimport { EventModel, EventType } from \"./Models/EventModel\";\r\nimport { move } from \"../../Helpers/Utils\";\r\nimport ConfirmationModal from \"../../Helpers/Modals/ConfirmationModal\";\r\nimport ConfigurationTemplateList from \"./ConfigurationTemplateList\";\r\nimport ConfigurationTemplate from \"./ConfigurationTemplate\";\r\nimport {useBranding} from \"../../hooks/useBranding\";\r\nimport UserService, {IGetuserprofileRequest} from \"../../services/User\";\r\n//https://codesandbox.io/s/nelec?file=/src/StyleList.tsx\r\n\r\nexport interface OutboundIntegrationListProps {\r\n templateId: string;\r\n showSuccessMessage: (message: string) => void;\r\n showErrorMessage: (message: string) => void;\r\n}\r\n\r\nfunction getWindowSize() {\r\n const { innerWidth, innerHeight } = window;\r\n return { innerWidth, innerHeight };\r\n}\r\n\r\nfunction OutboundIntegrationList(props: OutboundIntegrationListProps) {\r\n const { branding } = useBranding()\r\n const [events, setEvents] = useState([]);\r\n\r\n const [outboundIntegrations, setOutboundIntegrations] = useState([]);\r\n const outboundIntegration = useRef();\r\n const event = useRef();\r\n\r\n const [isOutboundIntegrationOpen, { setTrue: showOutboundIntegrationModal, setFalse: hideOutboundIntegrationModal }] = useBoolean(false);\r\n const [isEventOpen, { setTrue: showEventModal, setFalse: hideEventModal }] = useBoolean(false);\r\n\r\n const [confirmationModalTitle, setConfirmationModalTitle] = useState(\"\");\r\n const [isDeleteModalOpen, { setTrue: showDeleteModal, setFalse: hideDeleteModal }] = useBoolean(false);\r\n const [layoutLoaded, setLayoutLoaded] = useState(false);\r\n const [actionText, setActionText] = useState(\"\");\r\n const [deleteId, setDeleteId] = useState(\"\");\r\n const [deleteMessage, setDeleteMessage] = useState(\"\");\r\n const [spinnerText, setSpinnerText] = useState(\"\");\r\n const isIntegration = useRef(false);\r\n const [showDeactivatedIntegrationModal, setShowDeactivatedIntegrationModal] = useState(false);\r\n const [windowSize, setWindowSize] = useState(getWindowSize());\r\n\r\n const [isConfigurationTemplateListModaOpen, { setTrue: showConfigurationTemplateListModal, setFalse: hideConfigurationTemplateListModal }] = useBoolean(false);\r\n const [isConfigurationTemplateAdminMenu, { setTrue: setConfigurationTemplateAdminMenu, setFalse: setConfigurationTemplateClientMenu }] = useBoolean(false);\r\n const [isConfigurationTemplateModalOpen, { setTrue: showConfigurationTemplateModal, setFalse: hideConfigurationTemplateModal }] = useBoolean(false);\r\n const [profile, setProfile] = useState()\r\n\r\n let dragAndDrop: DragAndDropModel = {\r\n SourceGroupIndex: -1,\r\n SourceItemIndex: -1,\r\n SourceGroup: undefined,\r\n SourceItem: undefined,\r\n };\r\n\r\n const getDragDropEvents = () => {\r\n return {\r\n canDrop: (dropContext: any, dragContext?: any) => {\r\n return true;\r\n },\r\n canDrag: (item?: any) => {\r\n return true;\r\n },\r\n onDrop: (target?: any, event?: DragEvent) => {\r\n if (dragAndDrop) {\r\n insertBeforeItem(target!);\r\n }\r\n },\r\n onDragStart: (item?: any, itemIndex?: number, selectedItems?: any[], event?: MouseEvent) => {\r\n if (item.data) {\r\n dragAndDrop.SourceGroupIndex = itemIndex!;\r\n dragAndDrop.SourceGroup = item!;\r\n } else {\r\n dragAndDrop.SourceItemIndex = itemIndex!;\r\n dragAndDrop.SourceItem = item!;\r\n }\r\n },\r\n onDragEnd: (item?: any, event?: DragEvent) => {\r\n dragAndDrop.SourceGroupIndex = -1;\r\n dragAndDrop.SourceItemIndex = -1;\r\n dragAndDrop.SourceGroup = undefined;\r\n dragAndDrop.SourceItem = undefined;\r\n },\r\n canDragGroups: false,\r\n };\r\n };\r\n\r\n const dragDropEvents: IDragDropEvents = getDragDropEvents();\r\n const insertBeforeItem = (target: any): void => {\r\n if (\r\n dragAndDrop.SourceGroup !== undefined ||\r\n dragAndDrop.SourceItem !== undefined) {\r\n if (target.Id &&\r\n dragAndDrop.SourceGroup.data.Integrations.find((currentItem: any) => currentItem.Id === target.Id) !== undefined\r\n ) {\r\n const orderedIntegrations = _.sortBy(\r\n dragAndDrop.SourceGroup.data.Integrations,\r\n [\r\n (item: EventModel) => {\r\n return item.Order;\r\n },\r\n ]\r\n );\r\n const newIndex = orderedIntegrations.indexOf(target);\r\n const oldIndex = orderedIntegrations.indexOf(dragAndDrop.SourceItem);\r\n const newEventIntegrations = move(orderedIntegrations, oldIndex, newIndex);\r\n const newOutboundIntegrations = move(outboundIntegrations, outboundIntegrations.indexOf(dragAndDrop.SourceItem), outboundIntegrations.indexOf(target));\r\n\r\n newEventIntegrations.forEach(\r\n async (item: OutboundIntegrationModel, index: number, array: OutboundIntegrationModel[]) => {\r\n let tempOutboundIntegration: UpdateOutboundIntegration =\r\n {\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Integration: item,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n };\r\n tempOutboundIntegration.Integration.Order = index + 1;\r\n OutboundServices.UpdateIntegration(tempOutboundIntegration).then((res) => {\r\n if (res.Success !== undefined &&\r\n res.Success !== null &&\r\n res.Success === true) {\r\n props.showSuccessMessage(\"Integration has been updated successfully.\");\r\n } else {\r\n let errorMessage =\r\n res.ExceptionMessage !== undefined &&\r\n res.ExceptionMessage !== \"\" ? res.ExceptionMessage : \"Something unexpected happened.\";\r\n props.showErrorMessage(\"Error: \" + errorMessage);\r\n }\r\n });\r\n newOutboundIntegrations.forEach((fe) => {\r\n if (fe.Id === item.Id) {\r\n fe.Order = tempOutboundIntegration.Integration.Order;\r\n }\r\n });\r\n }\r\n );\r\n setOutboundIntegrations([...newOutboundIntegrations]);\r\n }\r\n }\r\n };\r\n\r\n useEffect(() => {\r\n loadEvents();\r\n function handleWindowResize() {\r\n setWindowSize(getWindowSize());\r\n }\r\n\r\n window.addEventListener(\"resize\", handleWindowResize);\r\n\r\n return () => {\r\n window.removeEventListener(\"resize\", handleWindowResize);\r\n };\r\n }, []);\r\n\r\n const loadEvents = async () => {\r\n\r\n let path = await Helper.getSite();\r\n \r\n const request: IGetuserprofileRequest = {\r\n UserName: Helper.getUsername(),\r\n Profile: Helper.getUsername()\r\n }\r\n UserService.GetUserProfile(request)\r\n .then((data) => {\r\n setProfile(data);\r\n OutboundServices.GetEvents({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n TemplateId: +props.templateId,\r\n }).then((res) => {\r\n if (res.length > 0) {\r\n let tempEvents: IGroup[] = [];\r\n let tempOutboundIntegrations: OutboundIntegrationModel[] = [];\r\n let _startIndex: number = 0;\r\n _.sortBy(res, [\r\n (item: EventModel) => {\r\n return item.Order;\r\n },\r\n ]).forEach((item: EventModel, index: number) => {\r\n tempEvents.push({\r\n key: item.Id.toString(),\r\n name: item.Name,\r\n startIndex: _startIndex,\r\n count: item.Integrations.length,\r\n level: 0,\r\n data: item,\r\n isDropEnabled: true,\r\n });\r\n tempOutboundIntegrations.push(\r\n ..._.sortBy(item.Integrations, [\r\n (item: OutboundIntegrationModel) => {\r\n return item.Order;\r\n },\r\n ])\r\n );\r\n _startIndex += item.Integrations.length;\r\n });\r\n setOutboundIntegrations(tempOutboundIntegrations);\r\n setEvents(tempEvents);\r\n } else {\r\n setOutboundIntegrations([]);\r\n setEvents([]);\r\n }\r\n });\r\n })\r\n .catch()\r\n .finally()\r\n \r\n };\r\n\r\n const getIntegrationEventsMenu = (item: OutboundIntegrationModel): IContextualMenuProps => {\r\n return {\r\n shouldFocusOnMount: true,\r\n items: [\r\n {\r\n key: \"edit\",\r\n text: \"Edit\",\r\n title: \"Edit Outbound Integration.\",\r\n onClick: () => {\r\n outboundIntegration.current = item;\r\n event.current = events.find(eventGroup => eventGroup.data.Integrations.find((integration: OutboundIntegrationModel) => integration.Id === item.Id) !== undefined)!.data;\r\n showOutboundIntegrationModal();\r\n }\r\n },\r\n {\r\n key: \"delete\",\r\n text: \"Delete\",\r\n title: \"Delete Outbound Integration.\",\r\n onClick: () => {\r\n onIntegrationDelete(item);\r\n }\r\n },\r\n {\r\n key: \"activate\",\r\n text: item.Active ? \"Deactivate\" : \"Activate\",\r\n title: item.Active ? \"Deactivate Outbound Integration.\" : \"Activate Outbound Integration.\",\r\n onClick: async () => {\r\n outboundIntegration.current = item;\r\n if (events.find((event) => event.data.Integrations.some((integration: any) => integration.Id === item.Id))!.data.Integrations.filter((f: any) => f.Active).length === 3 &&\r\n item.Active === false) {\r\n setShowDeactivatedIntegrationModal(true);\r\n } else {\r\n callbackDeactivatedIntegrationConfirmation();\r\n }\r\n }\r\n }\r\n ],\r\n };\r\n };\r\n\r\n const callbackDeactivatedIntegrationConfirmation = async () => {\r\n const tempEvent = events.find((find1: any) =>\r\n find1.data.Integrations.find(\r\n (find2: any) => find2.Id === outboundIntegration.current!.Id\r\n ) !== undefined\r\n );\r\n const activeIntegrations = tempEvent!.data.Integrations.filter((f: any) => f.Active).length;\r\n\r\n let tempOutboundIntegration = outboundIntegration.current!;\r\n if (activeIntegrations <= 3 && outboundIntegration.current!.Active) {\r\n tempOutboundIntegration.Active = false;\r\n } else if (activeIntegrations <= 2 && !outboundIntegration.current!.Active) {\r\n tempOutboundIntegration.Active = true;\r\n } else if (activeIntegrations === 3 && !outboundIntegration.current!.Active) {\r\n setShowDeactivatedIntegrationModal(false);\r\n outboundIntegration.current = undefined;\r\n return;\r\n }\r\n\r\n OutboundServices.UpdateIntegration({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Integration: tempOutboundIntegration,\r\n Path: await Helper.getSite(),\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n }).then((res) => {\r\n if (res.Success !== undefined &&\r\n res.Success !== null &&\r\n res.Success === true) {\r\n props.showSuccessMessage(\"Integration has been updated successfully.\");\r\n loadEvents();\r\n } else {\r\n let errorMessage = res.ExceptionMessage !== undefined && res.ExceptionMessage !== \"\" ? res.ExceptionMessage : \"Something unexpected happened.\";\r\n props.showErrorMessage(\"Error: \" + errorMessage);\r\n }\r\n outboundIntegration.current = undefined;\r\n });\r\n };\r\n\r\n const customHideOutboundIntegrationModal = () => {\r\n event.current = undefined;\r\n outboundIntegration.current = undefined;\r\n hideOutboundIntegrationModal();\r\n\r\n };\r\n\r\n const outboundIntegrationColumns: IColumn[] = [\r\n {\r\n key: \"event\",\r\n name: \"Event\",\r\n fieldName: \"EventType\",\r\n minWidth: 80,\r\n maxWidth: 80,\r\n isResizable: false,\r\n },\r\n {\r\n key: \"name\",\r\n name: \"Name\",\r\n fieldName: \"Name\",\r\n minWidth: 150,\r\n isResizable: true,\r\n },\r\n {\r\n key: \"description\",\r\n name: \"Description\",\r\n fieldName: \"Description\",\r\n minWidth: 250,\r\n maxWidth: 250,\r\n isResizable: true,\r\n isCollapsable: true\r\n },\r\n {\r\n key: \"method\",\r\n name: \"Method\",\r\n minWidth: 60,\r\n maxWidth: 60,\r\n isResizable: false,\r\n isCollapsable: true,\r\n onRender: (item: OutboundIntegrationModel) => {\r\n return item.ObjectMapInput.MapInput.Params.Method;\r\n },\r\n },\r\n {\r\n key: \"authorization\",\r\n name: \"Authorization\",\r\n minWidth: 100,\r\n maxWidth: 100,\r\n isResizable: false,\r\n isCollapsable: true,\r\n onRender: (item: OutboundIntegrationModel) => {\r\n return item.AuthenticationType;\r\n },\r\n },\r\n {\r\n key: \"order\",\r\n name: \"Order\",\r\n fieldName: \"Order\",\r\n minWidth: 50,\r\n maxWidth: 50,\r\n isResizable: false,\r\n isCollapsable: true,\r\n },\r\n {\r\n key: \"actions\",\r\n name: \"Actions\",\r\n minWidth: 55,\r\n maxWidth: 55,\r\n isResizable: false,\r\n onRender: (item: OutboundIntegrationModel) => {\r\n return (\r\n <>\r\n \r\n >\r\n );\r\n },\r\n },\r\n ];\r\n\r\n const eventMenuCallback = (currentEvent: EventModel): IContextualMenuProps => {\r\n let tempMenu: IContextualMenuItem[] = [\r\n {\r\n key: \"edit\",\r\n text: \"Edit\",\r\n title: \"Edit Event.\",\r\n onClick: (ev?: | React.MouseEvent | React.KeyboardEvent, item?: IContextualMenuItem) => {\r\n event.current = item!.data as EventModel;\r\n showEventModal();\r\n },\r\n data: currentEvent\r\n },\r\n {\r\n key: \"delete\",\r\n text: \"Delete\",\r\n title: \"Delete Event.\",\r\n onClick: (ev?: | React.MouseEvent | React.KeyboardEvent, item?: IContextualMenuItem) => {\r\n onEventDelete(item!.data);\r\n },\r\n data: currentEvent\r\n },\r\n {\r\n key: \"addService\",\r\n text: \"Add Service\",\r\n title: \"Add Service.\",\r\n onClick: (ev?: | React.MouseEvent | React.KeyboardEvent, item?: IContextualMenuItem) => {\r\n event.current = item!.data as EventModel;\r\n showOutboundIntegrationModal();\r\n },\r\n disabled: currentEvent.EventType.trim() === EventType.OnClick && currentEvent.Integrations.length === 1,\r\n data: currentEvent\r\n }\r\n ]\r\n if (profile.AdminBilling) {\r\n tempMenu = tempMenu.concat([{\r\n key: \"saveConfigurationTemplate\",\r\n text: \"Save Configuration as Template\",\r\n title: \"Save Configuration as Template\",\r\n onClick: (ev?: | React.MouseEvent | React.KeyboardEvent, item?: IContextualMenuItem) => {\r\n event.current = item!.data as EventModel;\r\n showConfigurationTemplateModal()\r\n },\r\n data: currentEvent\r\n }])\r\n }\r\n\r\n const eventMenu: IContextualMenuProps = {\r\n shouldFocusOnMount: true,\r\n items: tempMenu\r\n };\r\n return eventMenu;\r\n };\r\n\r\n const onToggleCollapse = (props: IGroupDividerProps): void => {\r\n props.onToggleCollapse!(props.group!);\r\n };\r\n\r\n const onRenderGroupHeader: IRenderFunction = (props) => {\r\n\r\n return (\r\n\r\n \r\n {props!.columns!.map(column => (\r\n\r\n <>\r\n
\r\n {column.key === 'event' &&\r\n <>\r\n {props!.group!.data.EventType}\r\n >\r\n }\r\n\r\n {column.key === 'name' &&\r\n <>\r\n {props!.group!.data.Name}\r\n >\r\n }\r\n\r\n {column.key === 'description' &&\r\n <>\r\n {props!.group!.data.Description}\r\n >\r\n }\r\n\r\n {column.key === 'description' &&\r\n <>\r\n {props!.group!.data.Description}\r\n >\r\n }\r\n\r\n {column.key === 'actions' &&\r\n <>\r\n\r\n \r\n >\r\n }\r\n\r\n\r\n\r\n
\r\n >\r\n ))}\r\n
\r\n )}/>\r\n }\r\n\r\n const getModalDescription = (title: string, description: string) => {\r\n var value;\r\n isMobile ? (value = title) : (value = title + \" (\" + description + \")\");\r\n return value;\r\n };\r\n\r\n const onIntegrationDelete = (item: OutboundIntegrationModel) => {\r\n isIntegration.current = true;\r\n setLayoutLoaded(false);\r\n setConfirmationModalTitle(\r\n getModalDescription(\"Delete Integration\", item.Name!)\r\n );\r\n setDeleteId(item.Id!.toString());\r\n setDeleteMessage(\"Are you sure you want to delete this Integration?\");\r\n setActionText(\"Delete\");\r\n setLayoutLoaded(true);\r\n showDeleteModal();\r\n };\r\n\r\n const onEventDelete = (item: EventModel) => {\r\n setLayoutLoaded(false);\r\n setConfirmationModalTitle(getModalDescription(\"Delete Event\", item.Name!));\r\n setDeleteId(item.Id!.toString());\r\n setDeleteMessage(\"Are you sure you want to delete this Event?\");\r\n setActionText(\"Delete\");\r\n setLayoutLoaded(true);\r\n showDeleteModal();\r\n };\r\n\r\n const hideConfirm = () => {\r\n hideDeleteModal();\r\n setLayoutLoaded(false);\r\n setSpinnerText(\"Loading content...\");\r\n setConfirmationModalTitle(\"\");\r\n setDeleteMessage(\"\");\r\n setLayoutLoaded(false);\r\n };\r\n\r\n const confirmOutboundIntegrationDelete = (id: string) => {\r\n const deleteIntegration = async () => {\r\n let path = await Helper.getSite();\r\n OutboundServices.DeleteIntegration({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Id: Number(id),\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n UserName: Helper.getUsername(),\r\n SessionKey: Helper.getSessionKey(),\r\n }).then((res) => {\r\n if (res.Success !== undefined &&\r\n res.Success !== null &&\r\n res.Success === true) {\r\n props.showSuccessMessage(\"Integration has been deleted.\");\r\n } else {\r\n let errorMessage =\r\n res.ExceptionMessage !== undefined &&\r\n res.ExceptionMessage !== \"\"\r\n ? res.ExceptionMessage\r\n : \"Something unexpected happened.\";\r\n props.showErrorMessage(\"Error: \" + errorMessage);\r\n }\r\n loadEvents();\r\n hideConfirm();\r\n });\r\n };\r\n deleteIntegration();\r\n };\r\n\r\n const confirmEventDelete = (id: string) => {\r\n const deleteEvent = async () => {\r\n let path = await Helper.getSite();\r\n OutboundServices.DeleteEvent({\r\n AccountId: Helper.getDefaultAccount(),\r\n ApiKey: \"-1\",\r\n Autoprovision: true,\r\n Id: Number(id),\r\n Path: path,\r\n SK: Helper.getSessionKey(),\r\n TemplateId: Number(props.templateId),\r\n UserName: Helper.getUsername(),\r\n SessionKey: Helper.getSessionKey(),\r\n }).then((res) => {\r\n if (res.Success !== undefined &&\r\n res.Success !== null &&\r\n res.Success === true) {\r\n props.showSuccessMessage(\r\n \"Integration Event has been deleted.\"\r\n );\r\n } else {\r\n let errorMessage =\r\n res.ExceptionMessage !== undefined &&\r\n res.ExceptionMessage !== \"\"\r\n ? res.ExceptionMessage\r\n : \"Something unexpected happened.\";\r\n props.showErrorMessage(\"Error: \" + errorMessage);\r\n }\r\n loadEvents();\r\n hideConfirm();\r\n });\r\n };\r\n deleteEvent();\r\n };\r\n\r\n return (\r\n <>\r\n {isEventOpen ? (\r\n ) : null}\r\n {isOutboundIntegrationOpen ? (\r\n f.data.Id === event.current!.Id)\r\n ?.data.Integrations\r\n : []\r\n }\r\n hideOutboundIntegrationModal={customHideOutboundIntegrationModal}\r\n isOutboundIntegrationOpen={isOutboundIntegrationOpen}\r\n loadEvents={loadEvents}\r\n showSuccessMessage={props.showSuccessMessage}\r\n />\r\n ) : null}\r\n \r\n \r\n \r\n \r\n \r\n {profile !== undefined && profile.AdminBilling ?\r\n { setConfigurationTemplateAdminMenu(); showConfigurationTemplateListModal(); }}>Administrate Configuration Templates\r\n : null}\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n \r\n \r\n Kim Outbound Integration allows administrators to configure\r\n direct REST API calls from {branding.appName} to GET, POST, PUT\r\n and DELETE to a specified target URL. Security\r\n authentication type must be one of OAuth20, Bearer, Basic,\r\n or Custom for the specified target URL. Request Headers and\r\n URL Parameters may be specified for the target. The POST,\r\n PUT or DELETE may specify mapping and transformation for the\r\n target URL. Use to connect to Salesforce, SAP Success\r\n Factors, Kim Platform, MS DevOps and other platforms capable\r\n of being targeted with {branding.appName} Outbound Integration\r\n configurations.\r\n \r\n
\r\n \r\n \r\n { setConfigurationTemplateClientMenu(); showConfigurationTemplateListModal(); }} />\r\n \r\n\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n\r\n {isConfigurationTemplateListModaOpen ?\r\n : null}\r\n\r\n {isConfigurationTemplateModalOpen ?\r\n \r\n : null}\r\n >\r\n );\r\n}\r\n\r\nexport default OutboundIntegrationList;","import { Checkbox, DefaultButton, DialogFooter, Dropdown, IDropdownOption, Label, mergeStyleSets, PrimaryButton, Stack, TextField } from '@fluentui/react'\r\nimport React, { useMemo } from 'react'\r\nimport { Controller, useForm } from 'react-hook-form'\r\nimport { useTranslation } from 'react-i18next'\r\nimport { IDocumentAssembly } from '../../../interfaces/IDocumentAssembly'\r\nimport DocumentAssemblyService from '../../../services/assembly'\r\nimport { IStatusMessage } from '../../../interfaces/IApp'\r\ntype RulesFormType = {\r\n type: 'create' | 'update'\r\n close: (loading: boolean, message?: IStatusMessage, callback?: () => void) => void\r\n templateId: number\r\n item?: IDocumentAssembly\r\n}\r\nconst typeOptions: IDropdownOption[] = [\r\n { key: 'INLINE', text: 'INLINE' },\r\n { key: 'MERGE', text: 'MERGE' },\r\n]\r\nconst defaultValues: IDocumentAssembly = {\r\n RuleType: 'INLINE',\r\n RuleName: '',\r\n RuleOrder: 1,\r\n RuleDescription: '',\r\n Active: false,\r\n AssemblyExpressions: [],\r\n DocumentAssemblyActions: []\r\n}\r\nconst RulesForm = ({ close, templateId, item }: RulesFormType) => {\r\n\r\n const { t } = useTranslation('assembly')\r\n const formType: 'create' | 'update' = useMemo(() => { return item && Object.keys(item).length === 0 ? 'create' : 'update' }, [item])\r\n const { control, handleSubmit, reset, formState: { errors }, setValue } = useForm({\r\n defaultValues: useMemo(() => {\r\n if (formType === 'update') {\r\n return item\r\n }\r\n return defaultValues\r\n }, [formType, item])\r\n })\r\n\r\n const handleDropdown = (event: React.FormEvent, option?: IDropdownOption | undefined) => {\r\n if (option) {\r\n setValue('RuleType', option.key.toString())\r\n }\r\n }\r\n\r\n const saveForm = (formData: IDocumentAssembly) => {\r\n formData.RuleName = formData.RuleName?.trim()\r\n formData.RuleDescription = formData.RuleDescription?.trim()\r\n if (formType === 'create') {\r\n DocumentAssemblyService.createAssembly(templateId, JSON.stringify(formData)).then(({ data }: any) => {\r\n if (data.Success === false) {\r\n close(true, { Message: <>Error adding {formData.RuleName}: {data.ExceptionMessage}>, Type: 'error' })\r\n return\r\n }\r\n reset(defaultValues)\r\n close(true, { Message: <>Rule {formData.RuleName} added successfully>, Type: 'success' })\r\n })\r\n } else if (item?.RuleId) {\r\n let assembly: IDocumentAssembly = { ...formData, AssemblyExpressions: item.AssemblyExpressions }\r\n delete assembly.DocumentAssemblyActions\r\n DocumentAssemblyService.updateAssembly(templateId, item.RuleId, JSON.stringify(assembly)).then(({ data }: any) => {\r\n if (data.Success === false) {\r\n close(true, { Message: <>Error updating Rule {formData.RuleName}: {data.ExceptionMessage}>, Type: 'error' })\r\n return\r\n }\r\n reset(defaultValues)\r\n close(true, { Message: <>Rule {formData.RuleName} updated successfully>, Type: 'success' })\r\n })\r\n }\r\n }\r\n const modalClose = () => {\r\n close(false)\r\n }\r\n return (\r\n