@evenicanpm/admin-integrate 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/documents/Endpoint/list.ts +8 -0
  2. package/documents/Process/get-process-details.ts +0 -1
  3. package/documents/ProcessConfig/fragments.ts +1 -1
  4. package/documents/ProcessExport/read.ts +108 -0
  5. package/documents/ProcessTask/fragments.ts +4 -1
  6. package/documents/ProcessTemplate/fragments.ts +6 -1
  7. package/package.json +2 -2
  8. package/src/api/configuration/queries/configuration-export.query.ts +48 -0
  9. package/src/api/configuration/queries/configuration-export.server.ts +9 -0
  10. package/src/api/configuration/queries/index.ts +1 -0
  11. package/src/api/process/mutations/copy-process.mutation.ts +2 -5
  12. package/src/api/process-config/mutation/process-config-import.mutation.ts +9 -0
  13. package/src/api/process-task/queries/get-process-task-by-id.query.ts +1 -0
  14. package/src/api/scheduler/mutation/create-process-schedule-group-details.mutation.ts +2 -2
  15. package/src/api/scheduler/mutation/update-process-schedule-group-details.mutation.ts +2 -2
  16. package/src/api/templates/queries/template-input-search.query.ts +5 -0
  17. package/src/api/templates/queries/template-input-search.server.ts +8 -1
  18. package/src/api/templates/queries/types.ts +9 -3
  19. package/src/components/breadcrumbs/breadcrumbs.tsx +1 -1
  20. package/src/components/core/date-time-popover.tsx +1 -1
  21. package/src/components/core/drawer-buttons.tsx +1 -1
  22. package/src/components/core/edited-typography.tsx +1 -1
  23. package/src/components/core/title-edit.tsx +13 -11
  24. package/src/components/dashboard-list/dashboard-list.tsx +1 -1
  25. package/src/components/data-table/table-header.tsx +1 -1
  26. package/src/components/data-table/table-skeleton.tsx +1 -1
  27. package/src/components/execution-history-drawer/execution-history-drawer.tsx +1 -2
  28. package/src/components/header/integration-details-header.tsx +4 -0
  29. package/src/components/integration-list/list/integration-list-row.tsx +2 -2
  30. package/src/components/integration-list/list/integration-list-table.tsx +3 -3
  31. package/src/components/integration-list/list/integration-list.tsx +3 -3
  32. package/src/components/integration-view/edges/default-edge.tsx +1 -5
  33. package/src/components/integration-view/flow-types.tsx +2 -0
  34. package/src/components/integration-view/integration-view.tsx +148 -577
  35. package/src/components/integration-view/nodes/add-node.tsx +20 -0
  36. package/src/components/integration-view/nodes/group-node.tsx +15 -1
  37. package/src/components/integration-view/nodes/task-node.tsx +38 -10
  38. package/src/components/integration-view/temp-data/initialElements.tsx +0 -2
  39. package/src/components/integration-view/utils/mapping.ts +404 -0
  40. package/src/components/layouts/main-layout.tsx +1 -1
  41. package/src/components/layouts/root-container.tsx +2 -5
  42. package/src/components/link-cards/link-card.tsx +1 -1
  43. package/src/components/list-filter/date-filter.tsx +3 -1
  44. package/src/components/list-filter/date-range-filter.tsx +4 -2
  45. package/src/components/list-filter/list-filter.tsx +1 -1
  46. package/src/components/list-filter/select-filter.tsx +10 -4
  47. package/src/components/scheduler/schedule-drawer/schedule-details-integrations.tsx +6 -8
  48. package/src/components/scheduler/schedule-drawer/schedule-details-main.tsx +1 -1
  49. package/src/components/scheduler/schedule-drawer/schedule-details-name.tsx +1 -1
  50. package/src/components/scheduler/schedule-drawer/schedule-details.tsx +1 -1
  51. package/src/components/scheduler/schedule-drawer/schedule-drawer-group.tsx +4 -8
  52. package/src/components/scheduler/schedule-drawer/schedule-drawer-legacy.tsx +1 -1
  53. package/src/components/scheduler/schedule-drawer/schedule-drawer.tsx +2 -2
  54. package/src/components/scheduler/schedule-drawer/sortable-integration-row.tsx +1 -1
  55. package/src/components/templates/inputs/index.tsx +162 -121
  56. package/src/components/templates/templates-list/templates-list-table.tsx +2 -2
  57. package/src/components/templates/templates-list/templates-list.tsx +1 -1
  58. package/src/components/templates/types.tsx +1 -0
  59. package/src/components/templates/wizard.tsx +98 -50
  60. package/src/pages/dashboard/dashboard-list-sections.tsx +2 -2
  61. package/src/pages/execution-details/execution-details.tsx +4 -3
  62. package/src/pages/execution-details/task-execution-details.tsx +1 -1
  63. package/src/pages/execution-details/task-execution-drawer.tsx +1 -1
  64. package/src/pages/executions/executions-list/executions-list-table.tsx +1 -1
  65. package/src/pages/integration-create/integration-create.tsx +87 -45
  66. package/src/pages/integration-create/pre-creation-step.tsx +77 -5
  67. package/src/pages/integration-create/select-step.tsx +1 -1
  68. package/src/pages/integration-create/wizard-step.tsx +2 -1
  69. package/src/pages/integration-details/import-process/copy-tasks-list.tsx +2 -2
  70. package/src/pages/integration-details/import-process/copy-tasks-row.tsx +1 -1
  71. package/src/pages/integration-details/import-process/import-confirm.tsx +1 -1
  72. package/src/pages/integration-details/import-process/import-drawer.tsx +1 -1
  73. package/src/pages/integration-details/import-process/import-process.tsx +1 -1
  74. package/src/pages/integration-details/integration-details.tsx +290 -43
  75. package/src/pages/integration-details/task-drawer/add-task.tsx +65 -13
  76. package/src/pages/integration-details/task-drawer/edit-task.tsx +69 -83
  77. package/src/pages/integration-details/task-drawer/task-drawer.tsx +22 -4
  78. package/src/pages/integration-details/task-drawer/task-reducer.ts +32 -2
  79. package/src/pages/scheduler/schedules-list/schedules-list-table.tsx +1 -1
@@ -14,7 +14,7 @@ interface Props {
14
14
  rowSx?: SxProps;
15
15
  }
16
16
 
17
- export default function TemplatesListTable(props: Props) {
17
+ export default function TemplatesListTable(props: Readonly<Props>) {
18
18
  const handleRequestSort = (property: string) => {
19
19
  const current = props.input.sort;
20
20
  if (property === current) {
@@ -44,7 +44,7 @@ export default function TemplatesListTable(props: Props) {
44
44
  <TableBody>
45
45
  {props.items.map((item, index) => (
46
46
  <TemplatesListRow
47
- key={index}
47
+ key={`list-row-${index + 1}`}
48
48
  item={item}
49
49
  heading={props.heading}
50
50
  sx={props.rowSx}
@@ -47,7 +47,7 @@ interface Props {
47
47
  isTemplateGroupsList?: boolean;
48
48
  }
49
49
 
50
- export default function TemplatesList(props: Props) {
50
+ export default function TemplatesList(props: Readonly<Props>) {
51
51
  const t = useTranslations("Integrate.Templates");
52
52
 
53
53
  const theme = useTheme();
@@ -49,6 +49,7 @@ export type Metadata = {
49
49
  code: string;
50
50
  parallelProcessingGroup: number;
51
51
  sort: number;
52
+ processTaskId?: number;
52
53
  };
53
54
 
54
55
  export type FlatPage = ProcessTemplatePage & {
@@ -18,7 +18,7 @@ import {
18
18
  useTheme,
19
19
  } from "@mui/material";
20
20
  import { usePathname, useRouter, useSearchParams } from "next/navigation";
21
- // import { useTranslations } from "next-intl"; //Need to figure out how to use this if if templates are data driven
21
+ // useTranslations - Need to figure out how to use this if if templates are data driven
22
22
  import React, { useEffect, useState } from "react";
23
23
  import PageBody, { applyTemplateConfig } from "./inputs";
24
24
  import {
@@ -72,9 +72,9 @@ function buildProcessConfigMerge(
72
72
  t.pages?.forEach((page) => {
73
73
  page?.inputs?.forEach((input) => {
74
74
  const key = templateFieldKey(t.id, input?.fieldName ?? ""); // e.g. "1::dataDescription"
75
- if (!Object.hasOwn(values, key)) return;
76
75
 
77
76
  // metadata override (no hardcoding)
77
+ // allow any metafields to be mapped
78
78
  if (input?.fieldName && input.fieldName in metadata) {
79
79
  obj[input.fieldName] = metadata[
80
80
  input.fieldName as keyof Metadata
@@ -82,13 +82,24 @@ function buildProcessConfigMerge(
82
82
  return;
83
83
  }
84
84
 
85
- const v = values[key];
85
+ if (!Object.hasOwn(values, key)) return;
86
+
87
+ let v = values[key];
88
+
86
89
  if (
87
- input &&
88
- input.inputType === "input-table" &&
90
+ input?.inputType === "input-table" &&
89
91
  Array.isArray(v) &&
90
92
  input.schemas?.length
91
93
  ) {
94
+ v = v.map((row: any) =>
95
+ (row?.DataType || row?.FieldType) === "String"
96
+ ? {
97
+ ...row,
98
+ Length: 4000,
99
+ }
100
+ : row,
101
+ );
102
+
92
103
  const isStr = (x: unknown): x is string => typeof x === "string";
93
104
  const valueCol =
94
105
  input.schemas.find((s) => s?.fieldKey === "{0}")?.fieldKey ?? null;
@@ -113,16 +124,19 @@ function buildProcessConfigMerge(
113
124
  const collapsed = (v as Array<Record<string, FieldValue>>).reduce(
114
125
  (acc, row) => {
115
126
  const rawKey = (row as any)[keyColFinal];
116
- const k =
117
- typeof rawKey === "string"
118
- ? rawKey.trim()
119
- : rawKey != null
120
- ? String(rawKey)
121
- : "";
127
+
128
+ let k = "";
129
+ if (typeof rawKey === "string") {
130
+ k = rawKey.trim();
131
+ } else if (rawKey != null) {
132
+ k = String(rawKey);
133
+ }
134
+
122
135
  if (!k) return acc;
123
136
 
124
137
  const val = (row as any)[valueCol ?? ""];
125
138
  if (val !== undefined) acc[k] = val as FieldValue;
139
+
126
140
  return acc;
127
141
  },
128
142
  {} as Record<string, FieldValue>,
@@ -137,15 +151,21 @@ function buildProcessConfigMerge(
137
151
  const collapsed = (v as Array<Record<string, FieldValue>>).reduce(
138
152
  (acc, row) => {
139
153
  const rawKey = (row as any)[keyCol]; // e.g., row["{Variable}"] === "ASD"
140
- const k =
141
- typeof rawKey === "string"
142
- ? rawKey.trim()
143
- : rawKey != null
144
- ? String(rawKey)
145
- : "";
154
+
155
+ let k = "";
156
+ if (typeof rawKey === "string") {
157
+ k = rawKey.trim();
158
+ } else if (rawKey !== null && rawKey !== undefined) {
159
+ k = String(rawKey);
160
+ }
161
+
146
162
  if (!k) return acc;
147
163
 
148
- const val = (row as any)[valueCol ?? ""]; // e.g., row["{0}"] === "1"
164
+ const val =
165
+ valueCol !== null && valueCol !== undefined
166
+ ? (row as any)[valueCol]
167
+ : undefined; // e.g., row["{0}"] === "1"
168
+
149
169
  if (val !== undefined) acc[k] = val as FieldValue;
150
170
  return acc;
151
171
  },
@@ -161,22 +181,6 @@ function buildProcessConfigMerge(
161
181
  if (input?.fieldName) {
162
182
  obj[input.fieldName] = v;
163
183
  }
164
-
165
- console.log(
166
- "fieldName:",
167
- input?.fieldName,
168
- "Mapping key:",
169
- key,
170
- "with value:",
171
- values[key],
172
- );
173
-
174
- //obj[input.fieldName] = values[key]; // map to pure fieldName
175
-
176
- // obj[input.fieldName] =
177
- // input.fieldName in metadata
178
- // ? (metadata as any)[input.fieldName]
179
- // : values[key];
180
184
  });
181
185
  });
182
186
 
@@ -206,7 +210,10 @@ export function removeTemplateConfig(input: any): any {
206
210
  return input;
207
211
  }
208
212
 
209
- function Header({ title, subtitle }: { title: string; subtitle?: string }) {
213
+ function Header({
214
+ title,
215
+ subtitle,
216
+ }: Readonly<{ title: string; subtitle?: string }>) {
210
217
  return (
211
218
  <Box sx={{ mb: 2 }}>
212
219
  <Typography variant="h6" sx={{ mb: 0.5 }}>
@@ -221,11 +228,11 @@ function TemplateNav({
221
228
  templates,
222
229
  activeIndex,
223
230
  stylings,
224
- }: {
231
+ }: Readonly<{
225
232
  templates: ProcessTemplate[];
226
233
  activeIndex: number;
227
234
  stylings?: object;
228
- }) {
235
+ }>) {
229
236
  return (
230
237
  <Stepper activeStep={activeIndex} sx={stylings}>
231
238
  {templates.map((t) => (
@@ -242,12 +249,12 @@ function PageNav({
242
249
  activeIndex,
243
250
  stylings,
244
251
  isEditMode,
245
- }: {
252
+ }: Readonly<{
246
253
  pages: ProcessTemplatePage[];
247
254
  activeIndex: number;
248
255
  stylings?: object;
249
256
  isEditMode?: boolean;
250
- }) {
257
+ }>) {
251
258
  return (
252
259
  <Stepper nonLinear={isEditMode} activeStep={activeIndex} sx={stylings}>
253
260
  {pages.map((p) => (
@@ -271,11 +278,16 @@ interface Props {
271
278
  templateConfig?: string | null;
272
279
  disableBackToTemplates?: boolean;
273
280
  isEditMode?: boolean;
281
+ isCreateMode?: boolean;
274
282
  readOnly?: boolean;
275
283
  sharedCount?: (count: number) => void;
276
284
  }
277
285
 
278
- export default function Wizard({ metadata, sharedCount, ...props }: Props) {
286
+ export default function Wizard({
287
+ metadata,
288
+ sharedCount,
289
+ ...props
290
+ }: Readonly<Props>) {
279
291
  const theme = useTheme();
280
292
 
281
293
  const router = useRouter();
@@ -285,18 +297,21 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
285
297
  const [templates, setTemplates] = useState<ProcessTemplate[]>([]);
286
298
  const [templatesSorted, setTemplatesSorted] = useState<ProcessTemplate[]>([]);
287
299
 
288
- const [configTemplateId, setConfigTemplateId] = useState<string | null>(null);
289
300
  const { data, isLoading } = getProcessTemplate.useData({
290
301
  input: {
291
302
  processTemplateGroupId: props.processTemplateGroupId || null,
292
- processTemplateId: configTemplateId || props.processTemplateId || null,
303
+ processTemplateId:
304
+ /*configTemplateId ||*/ props.processTemplateId || null,
293
305
  },
294
306
  });
295
307
 
308
+ const [values, setValues] = React.useState<FormState>({});
309
+
296
310
  useEffect(() => {
297
311
  const typedData = data as GetProcessTemplateQuery;
298
312
  if (typedData?.processTemplate) {
299
313
  const templates = typedData.processTemplate as ProcessTemplate[];
314
+
300
315
  setTemplates(templates);
301
316
  setTemplatesSorted(
302
317
  templates.map((t) => ({
@@ -304,10 +319,29 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
304
319
  pages: sortBy(t.pages as ProcessTemplatePage[]),
305
320
  })),
306
321
  );
322
+
323
+ templates.forEach((tpl) => {
324
+ tpl.pages?.forEach((page) => {
325
+ page?.inputs?.forEach((input) => {
326
+ const key = templateFieldKey(tpl.id, input?.fieldName ?? "");
327
+ if (
328
+ input?.defaultValue !== undefined &&
329
+ input?.defaultValue !== null &&
330
+ !values[key]
331
+ ) {
332
+ setValues((prev) => ({
333
+ ...prev,
334
+ [key]: input.defaultValue as FieldValue,
335
+ }));
336
+ }
337
+ });
338
+ });
339
+ });
307
340
  }
308
341
  }, [data]);
309
342
 
310
343
  const [flatPages, setFlatPages] = useState<FlatPage[]>([]);
344
+
311
345
  useEffect(() => {
312
346
  let counter = 0;
313
347
  const newFlatPages = templatesSorted.flatMap((tpl, ti) => {
@@ -349,7 +383,6 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
349
383
  }
350
384
  }, [currentTemplate]);
351
385
 
352
- const [values, setValues] = React.useState<FormState>({});
353
386
  const [errors, setErrors] = React.useState<ErrorState>({});
354
387
  const [disabledFields, setDisabledFields] = React.useState<Set<string>>(
355
388
  new Set(),
@@ -360,7 +393,9 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
360
393
 
361
394
  const handleFieldChange = React.useCallback(
362
395
  (templateId: string, fieldName: string, value: FieldValue) => {
396
+ if (!templateId || !fieldName || value == null) return;
363
397
  const key = templateFieldKey(templateId, fieldName);
398
+
364
399
  setValues((prev) => ({ ...prev, [key]: value }));
365
400
  setErrors((prev) => ({ ...prev, [key]: null }));
366
401
  },
@@ -390,12 +425,11 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
390
425
  const config = JSON.parse(props.templateConfig as string);
391
426
  applyTemplateConfig(
392
427
  {
393
- name: config.dataDescription as string,
428
+ name: config.taskName as string,
394
429
  templateConfig: props.templateConfig as string,
395
430
  } as SearchOption,
396
431
  handleFieldChange,
397
432
  );
398
- setConfigTemplateId(config.processTemplateId ?? null);
399
433
  }
400
434
  }, [props.templateConfig]);
401
435
 
@@ -513,6 +547,19 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
513
547
  continue;
514
548
  }
515
549
 
550
+ if (
551
+ input.fieldName === "uniqueIdentifier" &&
552
+ typeof value === "string"
553
+ ) {
554
+ const notUnique = Object.entries(values).find(
555
+ ([k, v]) => k.endsWith(`${templateId}::isUnique`) && v === false,
556
+ );
557
+ if (notUnique) {
558
+ pageErrs[key] = "This identifier is not unique.";
559
+ continue;
560
+ }
561
+ }
562
+
516
563
  const fieldErr = validateInput(input, value);
517
564
  if (fieldErr) pageErrs[key] = fieldErr;
518
565
  }
@@ -540,8 +587,7 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
540
587
  if (currentFlat && !validatePage(currentFlat, currentFlat._templateId))
541
588
  return;
542
589
 
543
- const payload = buildProcessConfigMerge(templatesSorted, values, metadata);
544
- console.log("processConfigMerge payload:", payload);
590
+ let payload = buildProcessConfigMerge(templatesSorted, values, metadata);
545
591
 
546
592
  props.setProcessConfigMerge(payload);
547
593
  if (props.handleFinish) {
@@ -556,9 +602,9 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
556
602
  isLoading &&
557
603
  !currentFlat &&
558
604
  !currentTemplate &&
559
- (!props.processTemplateGroupId ||
560
- !props.processTemplateId ||
561
- !configTemplateId)
605
+ !props.templateConfig &&
606
+ (!props.processTemplateGroupId || !props.processTemplateId) /*||
607
+ !configTemplateId*/
562
608
  ) {
563
609
  return (
564
610
  <Box sx={{ padding: theme.spacing(10, 3) }}>
@@ -626,8 +672,10 @@ export default function Wizard({ metadata, sharedCount, ...props }: Props) {
626
672
  readOnly={props.readOnly}
627
673
  sharedCount={(count) => sharedCount?.(count)}
628
674
  isEditMode={props.isEditMode}
675
+ isCreateMode={props.isCreateMode}
629
676
  disabledFields={disabledFields}
630
677
  setFieldsDisabled={setFieldsDisabled}
678
+ templateConfig={props.templateConfig || ""}
631
679
  />
632
680
  </Box>
633
681
 
@@ -4,7 +4,7 @@ import type {
4
4
  } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
5
5
  // Custom components
6
6
  import SnackbarAlert, {
7
- type iSnackbarAlert,
7
+ type ISnackbarAlert,
8
8
  } from "@evenicanpm/admin-core/components/snackbar-alert";
9
9
 
10
10
  // API
@@ -25,7 +25,7 @@ export default function DashboardListSections() {
25
25
  const m = useTranslations("Integrate.Message");
26
26
 
27
27
  const [refreshed, setRefreshed] = useState<boolean>(false);
28
- const [message, setMessage] = useState<iSnackbarAlert>({ open: false });
28
+ const [message, setMessage] = useState<ISnackbarAlert>({ open: false });
29
29
 
30
30
  const {
31
31
  data: recent,
@@ -7,7 +7,7 @@ import type {
7
7
  ProcessTaskExecution,
8
8
  } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
9
9
  import SnackbarAlert, {
10
- type iSnackbarAlert,
10
+ type ISnackbarAlert,
11
11
  } from "@evenicanpm/admin-core/components/snackbar-alert";
12
12
  import {
13
13
  getProcessExecutionDetails,
@@ -96,7 +96,7 @@ export default function ExecutionDetails() {
96
96
  setSelected(typedData.processExecutionDetails as Execution);
97
97
 
98
98
  if (breadcrumbs.length === 2) {
99
- const newCrumbs: Crumb[] = JSON.parse(JSON.stringify(breadcrumbs));
99
+ const newCrumbs: Crumb[] = globalThis.structuredClone(breadcrumbs);
100
100
 
101
101
  newCrumbs.push({
102
102
  name: typedData.processExecutionDetails.name as string,
@@ -119,7 +119,7 @@ export default function ExecutionDetails() {
119
119
  }, [executions]);
120
120
 
121
121
  const runProcess = runProcessWebhook();
122
- const [message, setMessage] = useState<iSnackbarAlert>({ open: false });
122
+ const [message, setMessage] = useState<ISnackbarAlert>({ open: false });
123
123
 
124
124
  const handleRun = () => {
125
125
  runProcess.mutate(
@@ -214,6 +214,7 @@ export default function ExecutionDetails() {
214
214
  onTaskClick={handleSelectedTaskExecution}
215
215
  drawerOpen={!!selectedTaskExecution}
216
216
  processTaskId={selectedTaskExecution?.id}
217
+ canEdit={false}
217
218
  />
218
219
  <TaskExecutionDrawer
219
220
  open={selectedTaskExecution !== null}
@@ -21,7 +21,7 @@ interface Props {
21
21
  details: ProcessTaskExecution;
22
22
  }
23
23
 
24
- export default function TaskExecutionDetails({ details }: Props) {
24
+ export default function TaskExecutionDetails({ details }: Readonly<Props>) {
25
25
  const t = useTranslations("Integrate.Executions");
26
26
  const theme = useTheme();
27
27
  const styles = getStyles(theme);
@@ -29,7 +29,7 @@ export default function TaskExecutionDrawer({
29
29
  processTaskExecution,
30
30
  handleClose,
31
31
  ...props
32
- }: Props) {
32
+ }: Readonly<Props>) {
33
33
  const theme = useTheme();
34
34
 
35
35
  return (
@@ -20,7 +20,7 @@ interface Props {
20
20
  rowSx?: SxProps;
21
21
  }
22
22
 
23
- export default function ExecutionsListTable(props: Props) {
23
+ export default function ExecutionsListTable(props: Readonly<Props>) {
24
24
  const handleRequestSort = (property: string) => {
25
25
  const current = props.input.sort;
26
26
  if (property === current) {
@@ -1,4 +1,7 @@
1
- import type { ConfigurationMergeMutationVariables } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
1
+ import type {
2
+ ConfigExport,
3
+ ConfigurationMergeMutationVariables,
4
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
2
5
  import {
3
6
  processConfigImport,
4
7
  processConfigMerge,
@@ -11,7 +14,7 @@ import { IntegrationDetailsHeader } from "@evenicanpm/admin-integrate/components
11
14
  import { removeTemplateConfig } from "@evenicanpm/admin-integrate/components/templates/wizard";
12
15
  import { slugify } from "@evenicanpm/admin-integrate/utils/slugify";
13
16
  import { Clear, SaveOutlined } from "@mui/icons-material";
14
- import { Box, Button, Card, type Theme, useTheme } from "@mui/material";
17
+ import { Box, Button, type Theme, useTheme } from "@mui/material";
15
18
  import { usePathname, useRouter, useSearchParams } from "next/navigation";
16
19
  import { useTranslations } from "next-intl";
17
20
  import { useEffect, useState } from "react";
@@ -75,6 +78,27 @@ export default function IntegrationCreate() {
75
78
  c.code = code;
76
79
  }
77
80
 
81
+ console.log("configMergeInput", configMergeInput);
82
+
83
+ let sourceName = configMergeInput?.input?.config?.find(
84
+ (item: any) => (item?.source as string)?.toLowerCase() === "source",
85
+ )?.uniqueIdentifier;
86
+
87
+ if (sourceName) {
88
+ configMergeInput.input.config = configMergeInput.input!.config!.map(
89
+ (item: any) => {
90
+ if (item?.queues) {
91
+ return {
92
+ ...item,
93
+ queues: `${sourceName}_endpoint`,
94
+ };
95
+ } else {
96
+ return item;
97
+ }
98
+ },
99
+ );
100
+ }
101
+
78
102
  processConfigMergeMutation.mutate(
79
103
  {
80
104
  input:
@@ -82,8 +106,13 @@ export default function IntegrationCreate() {
82
106
  ({} as ConfigurationMergeMutationVariables),
83
107
  },
84
108
  {
85
- onSuccess: ({ configurationMerge }) =>
86
- setProcessConfig(configurationMerge),
109
+ onSuccess: ({ configurationMerge }) => {
110
+ console.log("configurationMerge", configurationMerge);
111
+ setProcessConfig({
112
+ ...configurationMerge,
113
+ CreateIntegrationProc: true,
114
+ });
115
+ },
87
116
  onError: (error) => {
88
117
  console.error("Update failed:", error);
89
118
  },
@@ -98,8 +127,7 @@ export default function IntegrationCreate() {
98
127
  reRoutedFromMerge: true,
99
128
  },
100
129
  {
101
- onSuccess: (res) => {
102
- console.log("res", res);
130
+ onSuccess: () => {
103
131
  router.push("/e4integrate/integrations");
104
132
  },
105
133
  onError: (error) => {
@@ -120,55 +148,69 @@ export default function IntegrationCreate() {
120
148
  }
121
149
  }, [name]);
122
150
 
151
+ useEffect(() => {
152
+ if (step === 3 && !processConfig) {
153
+ const blankConfig: ConfigExport = {
154
+ Processes: [
155
+ {
156
+ Process: slugify(name),
157
+ Name: name,
158
+ },
159
+ ],
160
+ };
161
+ setProcessConfig(blankConfig);
162
+ }
163
+ }, [step, processConfig]);
164
+
123
165
  return (
124
166
  <>
125
167
  <IntegrateBreadcrumbs breadcrumbs={breadcrumbs} />
126
- <Card>
127
- <Box sx={styles.header}>
128
- <IntegrationDetailsHeader
129
- name={name || t("Templates.defaultNewName")}
130
- setName={setName}
131
- toolbar={step === 3 ? "disabled" : "hidden"}
132
- draft
133
- untitled={name === ""}
168
+ {/* <Card> */}
169
+ <Box sx={styles.header}>
170
+ <IntegrationDetailsHeader
171
+ name={name || t("Templates.defaultNewName")}
172
+ setName={setName}
173
+ toolbar={step === 3 ? "disabled" : "hidden"}
174
+ draft
175
+ untitled={name === ""}
176
+ >
177
+ <Button
178
+ color="error"
179
+ variant="contained"
180
+ startIcon={<Clear />}
181
+ onClick={handleCancel}
182
+ >
183
+ {t("Templates.cancel")}
184
+ </Button>
185
+ <Button
186
+ color="info"
187
+ variant="contained"
188
+ startIcon={<SaveOutlined />}
189
+ onClick={handleProcessConfigImport}
190
+ disabled={step !== 3}
134
191
  >
135
- <Button
136
- color="error"
137
- variant="contained"
138
- startIcon={<Clear />}
139
- onClick={handleCancel}
140
- >
141
- {t("Templates.cancel")}
142
- </Button>
143
- <Button
144
- color="info"
145
- variant="contained"
146
- startIcon={<SaveOutlined />}
147
- onClick={handleProcessConfigImport}
148
- disabled={step !== 3}
149
- >
150
- {t("Templates.create")}
151
- </Button>
152
- </IntegrationDetailsHeader>
153
- </Box>
154
- {step === 0 && <SelectStep setStep={setStep} />}
155
- {step === 1 && <TemplateListStep />}
156
- {step === 2 && (
157
- <WizardStep
158
- setStep={setStep}
159
- setProcessConfigMerge={handleProcessConfigMerge}
160
- />
161
- )}
162
- {step === 3 && <PreCreationStep processConfig={processConfig} />}
163
- </Card>
192
+ {t("Templates.create")}
193
+ </Button>
194
+ </IntegrationDetailsHeader>
195
+ </Box>
196
+ {step === 0 && <SelectStep setStep={setStep} />}
197
+ {step === 1 && <TemplateListStep />}
198
+ {step === 2 && (
199
+ <WizardStep
200
+ setStep={setStep}
201
+ setProcessConfigMerge={handleProcessConfigMerge}
202
+ />
203
+ )}
204
+ {step === 3 && <PreCreationStep processConfig={processConfig} />}
205
+ {/* </Card> */}
164
206
  </>
165
207
  );
166
208
  }
167
209
 
168
- const getStyles = (theme: Theme) => {
210
+ const getStyles = (_theme: Theme) => {
169
211
  return {
170
212
  header: {
171
- padding: theme.spacing(2),
213
+ //padding: theme.spacing(2),
172
214
  },
173
215
  };
174
216
  };