@evenicanpm/admin-integrate 1.2.2 → 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 (215) hide show
  1. package/documents/ConfigImport/configuration-import.ts +54 -0
  2. package/documents/CopyProcess/copy.ts +25 -0
  3. package/documents/Endpoint/fragments.ts +9 -0
  4. package/documents/Endpoint/list.ts +30 -0
  5. package/documents/Process/fragments.ts +22 -0
  6. package/documents/Process/get-process-details.ts +72 -0
  7. package/documents/Process/list.ts +24 -0
  8. package/documents/ProcessConfig/fragments.ts +116 -0
  9. package/documents/ProcessConfig/read.ts +35 -0
  10. package/documents/ProcessExecution/fragments.ts +12 -0
  11. package/documents/ProcessExecution/list.ts +30 -1
  12. package/documents/ProcessExecutionDetails/fragments.ts +96 -0
  13. package/documents/ProcessExecutionDetails/read.ts +12 -0
  14. package/documents/ProcessExport/read.ts +108 -0
  15. package/documents/ProcessScheduleGroup/read.ts +43 -0
  16. package/documents/ProcessTask/fragments.ts +288 -0
  17. package/documents/ProcessTask/read.ts +12 -0
  18. package/documents/ProcessTemplate/fragments.ts +74 -0
  19. package/documents/ProcessTemplate/list.ts +67 -0
  20. package/documents/ProcessTemplate/read.ts +12 -0
  21. package/documents/RunProcess/run.ts +11 -0
  22. package/package.json +4 -3
  23. package/src/api/Integrations/queries/get-process.query.ts +12 -12
  24. package/src/api/Integrations/queries/get-process.server.ts +7 -2
  25. package/src/api/configuration/queries/configuration-export.query.ts +48 -0
  26. package/src/api/configuration/queries/configuration-export.server.ts +9 -0
  27. package/src/api/configuration/queries/index.ts +1 -0
  28. package/src/api/dashboard/queries/get-process-executions.query.ts +6 -3
  29. package/src/api/dashboard/queries/get-process-executions.server.ts +1 -1
  30. package/src/api/execution-details/queries/get-process-execution-details.query.ts +46 -0
  31. package/src/api/execution-details/queries/get-process-execution-details.server.ts +11 -0
  32. package/src/api/execution-details/queries/get-process-executions-by-process.query.ts +48 -0
  33. package/src/api/execution-details/queries/get-process-executions-by-process.server.ts +11 -0
  34. package/src/api/execution-details/queries/index.ts +2 -0
  35. package/src/api/process/mutations/copy-process.mutation.ts +45 -0
  36. package/src/api/process/mutations/copy-process.server.ts +14 -0
  37. package/src/api/process/mutations/index.ts +2 -0
  38. package/src/api/process/mutations/run-process.mutation.ts +41 -0
  39. package/src/api/process/mutations/run-process.server.ts +14 -0
  40. package/src/api/process/queries/get-process-by-id.query.ts +85 -0
  41. package/src/api/process/queries/get-process-by-id.server.ts +20 -0
  42. package/src/api/process/queries/index.ts +4 -0
  43. package/src/api/process-config/mutation/index.ts +2 -0
  44. package/src/api/process-config/mutation/process-config-import.mutation.ts +42 -0
  45. package/src/api/process-config/mutation/process-config-import.server.ts +14 -0
  46. package/src/api/process-config/mutation/process-config-merge.mutation.ts +33 -0
  47. package/src/api/process-config/mutation/process-config-merge.server.ts +14 -0
  48. package/src/api/process-task/queries/get-process-task-by-id.query.ts +46 -0
  49. package/src/api/process-task/queries/get-process-task-by-id.server.ts +9 -0
  50. package/src/api/process-task/queries/index.ts +1 -0
  51. package/src/api/scheduler/mutation/create-process-schedule-group-details.mutation.ts +47 -0
  52. package/src/api/scheduler/mutation/create-process-schedule-group-details.server.ts +14 -0
  53. package/src/api/scheduler/mutation/index.ts +2 -0
  54. package/src/api/scheduler/mutation/update-process-schedule-group-details.mutation.ts +47 -0
  55. package/src/api/scheduler/mutation/update-process-schedule-group-details.server.ts +14 -0
  56. package/src/api/scheduler/queries/get-non-scheduled-processes.query.ts +48 -0
  57. package/src/api/scheduler/queries/get-non-scheduled-processes.server.ts +11 -0
  58. package/src/api/scheduler/queries/get-process-schedule-group-details.query.ts +6 -3
  59. package/src/api/scheduler/queries/get-process-schedule-group-details.server.ts +3 -3
  60. package/src/api/scheduler/queries/get-process-schedule.query.ts +6 -3
  61. package/src/api/scheduler/queries/get-process-schedule.server.ts +3 -3
  62. package/src/api/scheduler/queries/get-scheduled-processes.query.ts +6 -3
  63. package/src/api/scheduler/queries/get-scheduled-processes.server.ts +1 -1
  64. package/src/api/scheduler/queries/index.ts +3 -2
  65. package/src/api/templates/queries/get-process-template-groups.query.ts +48 -0
  66. package/src/api/templates/queries/get-process-template-groups.server.ts +11 -0
  67. package/src/api/templates/queries/get-process-template-records.query.ts +48 -0
  68. package/src/api/templates/queries/get-process-template-records.server.ts +11 -0
  69. package/src/api/templates/queries/get-process-template.query.ts +48 -0
  70. package/src/api/templates/queries/get-process-template.server.ts +9 -0
  71. package/src/api/templates/queries/get-process-templates.query.ts +45 -0
  72. package/src/api/templates/queries/get-process-templates.server.ts +9 -0
  73. package/src/api/templates/queries/index.ts +5 -0
  74. package/src/api/templates/queries/template-input-search.query.ts +39 -0
  75. package/src/api/templates/queries/template-input-search.server.ts +42 -0
  76. package/src/api/templates/queries/types.ts +34 -0
  77. package/src/components/breadcrumbs/breadcrumbs.tsx +33 -6
  78. package/src/components/button/outlined-icon-button.tsx +2 -2
  79. package/src/components/core/date-time-popover.tsx +12 -5
  80. package/src/components/core/drawer-buttons.tsx +52 -0
  81. package/src/components/core/edited-typography.tsx +2 -2
  82. package/src/components/core/index.ts +4 -2
  83. package/src/components/core/loading.tsx +1 -1
  84. package/src/components/core/status-tag.tsx +97 -0
  85. package/src/components/core/title-edit.tsx +31 -22
  86. package/src/components/dashboard-list/dashboard-list-row.tsx +22 -29
  87. package/src/components/dashboard-list/dashboard-list.tsx +20 -16
  88. package/src/components/data-table/table-header.tsx +6 -8
  89. package/src/components/data-table/table-pagination.tsx +1 -1
  90. package/src/components/data-table/table-row.tsx +1 -1
  91. package/src/components/data-table/table-skeleton.tsx +10 -5
  92. package/src/components/execution/execution-filter.ts +1 -1
  93. package/src/components/execution/execution-status-icon.tsx +7 -7
  94. package/src/components/execution/execution-tag.tsx +12 -77
  95. package/src/components/execution/index.ts +1 -1
  96. package/src/components/execution-history-drawer/execution-history-drawer.tsx +202 -0
  97. package/src/components/execution-history-drawer/executions-card.tsx +85 -0
  98. package/src/components/execution-history-drawer/index.ts +1 -0
  99. package/src/components/footer/footer.tsx +10 -6
  100. package/src/components/header/dashboard-list-header.tsx +12 -7
  101. package/src/components/header/execution-details-header.tsx +35 -26
  102. package/src/components/header/header.tsx +10 -3
  103. package/src/components/header/index.ts +1 -1
  104. package/src/components/header/integration-details-header.tsx +108 -45
  105. package/src/components/integration-list/index.ts +2 -1
  106. package/src/components/integration-list/integration-filter.ts +1 -1
  107. package/src/components/integration-list/integration-status-icon.tsx +7 -8
  108. package/src/components/integration-list/integration-tag.tsx +6 -50
  109. package/src/components/integration-list/list/integration-list-row.tsx +161 -0
  110. package/src/components/integration-list/list/integration-list-table.tsx +62 -0
  111. package/src/{pages/integrations/integration-list → components/integration-list/list}/integration-list.tsx +47 -51
  112. package/src/components/integration-view/animated-svg.tsx +31 -0
  113. package/src/components/integration-view/edges/default-edge.tsx +2 -6
  114. package/src/components/integration-view/elk-layout-options.ts +2 -2
  115. package/src/components/integration-view/elk-types.ts +35 -6
  116. package/src/components/integration-view/flow-types.tsx +12 -0
  117. package/src/components/integration-view/integration-view.tsx +562 -56
  118. package/src/components/integration-view/nodes/add-node.tsx +20 -0
  119. package/src/components/integration-view/nodes/empty-node.tsx +65 -0
  120. package/src/components/integration-view/nodes/entry-node.tsx +98 -4
  121. package/src/components/integration-view/nodes/execution-entry-node.tsx +107 -0
  122. package/src/components/integration-view/nodes/execution-task-node.tsx +88 -0
  123. package/src/components/integration-view/nodes/group-node.tsx +33 -13
  124. package/src/components/integration-view/nodes/row-node.tsx +19 -0
  125. package/src/components/integration-view/nodes/task-node.tsx +50 -16
  126. package/src/components/integration-view/task-icon.tsx +193 -0
  127. package/src/components/integration-view/temp-data/initialElements.tsx +34 -32
  128. package/src/components/integration-view/types.ts +2 -2
  129. package/src/components/integration-view/utils/mapping.ts +404 -0
  130. package/src/components/layouts/main-layout.tsx +3 -4
  131. package/src/components/layouts/root-container.tsx +5 -11
  132. package/src/components/link-cards/link-card.tsx +15 -4
  133. package/src/components/link-cards/styles.ts +1 -1
  134. package/src/components/list-filter/date-filter.tsx +7 -4
  135. package/src/components/list-filter/date-range-filter.tsx +15 -7
  136. package/src/components/list-filter/index.ts +1 -1
  137. package/src/components/list-filter/list-filter.tsx +31 -26
  138. package/src/components/list-filter/multi-select-filter.tsx +11 -10
  139. package/src/components/list-filter/select-filter.tsx +23 -12
  140. package/src/components/scheduler/day-selector.tsx +29 -15
  141. package/src/components/scheduler/day-tag.tsx +14 -51
  142. package/src/components/scheduler/index.ts +2 -1
  143. package/src/components/scheduler/schedule-drawer/details-reducer.ts +217 -0
  144. package/src/components/scheduler/schedule-drawer/schedule-details-integrations.tsx +501 -0
  145. package/src/{pages → components}/scheduler/schedule-drawer/schedule-details-main.tsx +137 -100
  146. package/src/components/scheduler/schedule-drawer/schedule-details-name.tsx +94 -0
  147. package/src/{pages → components}/scheduler/schedule-drawer/schedule-details-skeleton.tsx +1 -2
  148. package/src/{pages → components}/scheduler/schedule-drawer/schedule-details.tsx +10 -14
  149. package/src/components/scheduler/schedule-drawer/schedule-drawer-group.tsx +214 -0
  150. package/src/{pages → components}/scheduler/schedule-drawer/schedule-drawer-legacy.tsx +7 -26
  151. package/src/components/scheduler/schedule-drawer/schedule-drawer.tsx +116 -0
  152. package/src/components/scheduler/schedule-drawer/sortable-integration-row.tsx +130 -0
  153. package/src/components/scheduler/schedule-filter.ts +1 -1
  154. package/src/components/scheduler/schedule-icon.tsx +5 -6
  155. package/src/components/scheduler/schedule-integration-icon.tsx +31 -0
  156. package/src/components/templates/index.ts +1 -0
  157. package/src/components/templates/inputs/index.tsx +1392 -0
  158. package/src/components/templates/template-filter.ts +5 -0
  159. package/src/components/templates/templates-list/index.ts +1 -0
  160. package/src/components/templates/templates-list/templates-list-row.tsx +55 -0
  161. package/src/components/templates/templates-list/templates-list-table.tsx +58 -0
  162. package/src/components/templates/templates-list/templates-list.tsx +253 -0
  163. package/src/components/templates/types.tsx +76 -0
  164. package/src/components/templates/wizard.tsx +737 -0
  165. package/src/hooks/use-breadcrumbs.ts +1 -1
  166. package/src/hooks/use-recurrence.tsx +1 -2
  167. package/src/pages/dashboard/dashboard-link-cards.tsx +8 -11
  168. package/src/pages/dashboard/dashboard-list-sections.tsx +8 -10
  169. package/src/pages/dashboard/dashboard.tsx +1 -2
  170. package/src/pages/execution-details/execution-details.tsx +212 -14
  171. package/src/pages/execution-details/task-execution-details.tsx +160 -0
  172. package/src/pages/execution-details/task-execution-drawer.tsx +54 -0
  173. package/src/pages/executions/executions-list/executions-list-row.tsx +21 -27
  174. package/src/pages/executions/executions-list/executions-list-table.tsx +29 -36
  175. package/src/pages/executions/executions-list/executions-list.tsx +24 -18
  176. package/src/pages/executions/executions.tsx +11 -15
  177. package/src/pages/integration-create/index.ts +1 -0
  178. package/src/pages/integration-create/integration-create.tsx +216 -0
  179. package/src/pages/integration-create/pre-creation-step.tsx +84 -0
  180. package/src/pages/integration-create/select-step.tsx +105 -0
  181. package/src/pages/integration-create/template-list-step.tsx +77 -0
  182. package/src/pages/integration-create/wizard-step.tsx +51 -0
  183. package/src/pages/integration-details/import-process/copy-tasks-list.tsx +265 -0
  184. package/src/pages/integration-details/import-process/copy-tasks-row.tsx +77 -0
  185. package/src/pages/integration-details/import-process/import-confirm.tsx +61 -0
  186. package/src/pages/integration-details/import-process/import-drawer.tsx +48 -0
  187. package/src/pages/integration-details/import-process/import-process-reducer.ts +90 -0
  188. package/src/pages/integration-details/import-process/import-process.tsx +149 -0
  189. package/src/pages/integration-details/index.ts +1 -0
  190. package/src/pages/integration-details/integration-details.tsx +468 -0
  191. package/src/pages/integration-details/task-drawer/add-task.tsx +172 -0
  192. package/src/pages/integration-details/task-drawer/edit-task.tsx +161 -0
  193. package/src/pages/integration-details/task-drawer/task-drawer.tsx +157 -0
  194. package/src/pages/integration-details/task-drawer/task-reducer.ts +103 -0
  195. package/src/pages/integrations/integrations.tsx +11 -14
  196. package/src/pages/scheduler/scheduler.tsx +12 -24
  197. package/src/pages/scheduler/schedules-list/schedules-list-row.tsx +27 -37
  198. package/src/pages/scheduler/schedules-list/schedules-list-table.tsx +28 -43
  199. package/src/pages/scheduler/schedules-list/schedules-list.tsx +48 -21
  200. package/src/utils/date-functions.ts +69 -0
  201. package/src/utils/slugify.ts +3 -0
  202. package/tsconfig.json +12 -4
  203. package/src/hooks/use-timestamp.tsx +0 -25
  204. package/src/pages/integrations/integration-list/integration-list-row.tsx +0 -147
  205. package/src/pages/integrations/integration-list/integration-list-table.tsx +0 -78
  206. package/src/pages/scheduler/schedule-drawer/schedule-details-integrations.tsx +0 -227
  207. package/src/pages/scheduler/schedule-drawer/schedule-details-name.tsx +0 -77
  208. package/src/pages/scheduler/schedule-drawer/schedule-drawer-buttons.tsx +0 -72
  209. package/src/pages/scheduler/schedule-drawer/schedule-drawer-group.tsx +0 -103
  210. package/src/pages/scheduler/schedule-drawer/schedule-drawer.tsx +0 -101
  211. package/src/pages/scheduler/schedule-drawer/sortable-integration-row.tsx +0 -93
  212. /package/src/{pages/integrations/integration-list → components/integration-list/list}/index.ts +0 -0
  213. /package/src/{pages → components}/scheduler/schedule-drawer/edited/edited-types.ts +0 -0
  214. /package/src/{pages → components}/scheduler/schedule-drawer/edited/index.ts +0 -0
  215. /package/src/{pages → components}/scheduler/schedule-drawer/index.ts +0 -0
@@ -1,22 +1,23 @@
1
- import { useTranslations } from "next-intl";
1
+ import { CloseOutlined } from "@mui/icons-material";
2
2
  import {
3
3
  Box,
4
- Typography,
4
+ Chip,
5
+ FormControl,
5
6
  IconButton,
6
7
  InputAdornment,
7
- Select,
8
8
  MenuItem,
9
- Theme,
9
+ Select,
10
+ type Theme,
11
+ Typography,
10
12
  useTheme,
11
- FormControl,
12
- Chip,
13
13
  } from "@mui/material";
14
- import { CloseOutlined } from "@mui/icons-material";
15
- import React, { useState } from "react";
16
- import {
14
+ import { useTranslations } from "next-intl";
15
+ import type React from "react";
16
+ import { useState } from "react";
17
+ import type {
17
18
  FilterOption,
18
- MultiSelectFilter,
19
19
  FilterProps,
20
+ MultiSelectFilter,
20
21
  } from "./list-filter-types";
21
22
 
22
23
  const MultiSelectFilterComponent: React.FC<FilterProps<MultiSelectFilter>> = ({
@@ -1,17 +1,22 @@
1
- import { useTranslations } from "next-intl";
1
+ import { CloseOutlined } from "@mui/icons-material";
2
2
  import {
3
- Typography,
3
+ FormControl,
4
4
  IconButton,
5
5
  InputAdornment,
6
- Select,
7
6
  MenuItem,
8
- Theme,
7
+ Select,
8
+ type Theme,
9
+ Typography,
9
10
  useTheme,
10
- FormControl,
11
11
  } from "@mui/material";
12
- import { CloseOutlined } from "@mui/icons-material";
13
- import React, { useState } from "react";
14
- import { FilterOption, SelectFilter, FilterProps } from "./list-filter-types";
12
+ import { useTranslations } from "next-intl";
13
+ import type React from "react";
14
+ import { useState } from "react";
15
+ import type {
16
+ FilterOption,
17
+ FilterProps,
18
+ SelectFilter,
19
+ } from "./list-filter-types";
15
20
 
16
21
  const SelectFilterComponent: React.FC<FilterProps<SelectFilter>> = ({
17
22
  filter,
@@ -34,10 +39,16 @@ const SelectFilterComponent: React.FC<FilterProps<SelectFilter>> = ({
34
39
  ) as { [id: string | number]: FilterOption };
35
40
 
36
41
  const updateValue = (optionId: string | number | null) => {
37
- const newValue =
38
- optionId !== null ? mappedOptionDictionary[optionId] : null;
39
- setValue(newValue && [newValue]);
40
- onSet(newValue && [newValue]);
42
+ if (optionId == null) {
43
+ setValue(null);
44
+ onSet(null);
45
+ return;
46
+ }
47
+
48
+ const newValue = mappedOptionDictionary[optionId];
49
+
50
+ setValue(newValue ? [newValue] : null);
51
+ onSet(newValue ? [newValue] : null);
41
52
  };
42
53
 
43
54
  return (
@@ -1,10 +1,17 @@
1
- import { useTranslations } from "next-intl";
2
1
  // MUI
3
- import { Theme, useTheme } from "@mui/material";
4
- import { Typography, Box, Stack, ButtonBase } from "@mui/material";
2
+ import {
3
+ Box,
4
+ ButtonBase,
5
+ Stack,
6
+ type SxProps,
7
+ type Theme,
8
+ Typography,
9
+ useTheme,
10
+ } from "@mui/material";
11
+ import { useTranslations } from "next-intl";
5
12
 
6
13
  // Types
7
- import { IsDay } from "./scheduler-types";
14
+ import type { IsDay } from "./scheduler-types";
8
15
 
9
16
  interface Props {
10
17
  days: IsDay;
@@ -16,7 +23,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
16
23
  const t = useTranslations("Integrate.Scheduler.DaySelector");
17
24
 
18
25
  const theme = useTheme();
19
- const styles = getStyles(theme);
26
+ const styles: DaySelectorStyles = getStyles(theme);
20
27
 
21
28
  const handleClick = (field: keyof IsDay) => {
22
29
  if (!props.disabled) {
@@ -34,7 +41,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
34
41
  disableRipple={props.disabled}
35
42
  >
36
43
  <Box
37
- sx={getDayStyle(styles, props.days.isMonday)}
44
+ sx={getDayStyle(styles, props.days?.isMonday)}
38
45
  alignContent="center"
39
46
  textAlign="center"
40
47
  >
@@ -49,7 +56,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
49
56
  disableRipple={props.disabled}
50
57
  >
51
58
  <Box
52
- sx={getDayStyle(styles, props.days.isTuesday)}
59
+ sx={getDayStyle(styles, props.days?.isTuesday)}
53
60
  alignContent="center"
54
61
  textAlign="center"
55
62
  >
@@ -64,7 +71,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
64
71
  disableRipple={props.disabled}
65
72
  >
66
73
  <Box
67
- sx={getDayStyle(styles, props.days.isWednesday)}
74
+ sx={getDayStyle(styles, props.days?.isWednesday)}
68
75
  alignContent="center"
69
76
  textAlign="center"
70
77
  >
@@ -79,7 +86,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
79
86
  disableRipple={props.disabled}
80
87
  >
81
88
  <Box
82
- sx={getDayStyle(styles, props.days.isThursday)}
89
+ sx={getDayStyle(styles, props.days?.isThursday)}
83
90
  alignContent="center"
84
91
  textAlign="center"
85
92
  >
@@ -94,7 +101,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
94
101
  disableRipple={props.disabled}
95
102
  >
96
103
  <Box
97
- sx={getDayStyle(styles, props.days.isFriday)}
104
+ sx={getDayStyle(styles, props.days?.isFriday)}
98
105
  alignContent="center"
99
106
  textAlign="center"
100
107
  >
@@ -109,7 +116,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
109
116
  disableRipple={props.disabled}
110
117
  >
111
118
  <Box
112
- sx={getDayStyle(styles, props.days.isSaturday)}
119
+ sx={getDayStyle(styles, props.days?.isSaturday)}
113
120
  alignContent="center"
114
121
  textAlign="center"
115
122
  >
@@ -124,7 +131,7 @@ const DaySelector: React.FC<Props> = (props: Props) => {
124
131
  disableRipple={props.disabled}
125
132
  >
126
133
  <Box
127
- sx={getDayStyle(styles, props.days.isSunday)}
134
+ sx={getDayStyle(styles, props.days?.isSunday)}
128
135
  alignContent="center"
129
136
  textAlign="center"
130
137
  >
@@ -137,7 +144,14 @@ const DaySelector: React.FC<Props> = (props: Props) => {
137
144
  );
138
145
  };
139
146
 
140
- const getStyles = (theme: Theme) => {
147
+ interface DaySelectorStyles {
148
+ days: SxProps;
149
+ dayOfWeek: SxProps;
150
+ dayOfWeekSelected: SxProps;
151
+ dayInitial: SxProps;
152
+ }
153
+
154
+ const getStyles = (theme: Theme): DaySelectorStyles => {
141
155
  return {
142
156
  days: {
143
157
  marginTop: theme.spacing(0),
@@ -164,9 +178,9 @@ const getStyles = (theme: Theme) => {
164
178
  };
165
179
  };
166
180
 
167
- const getDayStyle = (styles: any, selected: boolean) => {
181
+ const getDayStyle = (styles: DaySelectorStyles, selected: boolean): SxProps => {
168
182
  if (selected) {
169
- return { ...styles.dayOfWeek, ...styles.dayOfWeekSelected };
183
+ return { ...styles.dayOfWeek, ...styles.dayOfWeekSelected } as SxProps;
170
184
  }
171
185
  return styles.dayOfWeek;
172
186
  };
@@ -1,22 +1,8 @@
1
- import React from "react";
1
+ import { StatusTag } from "@evenicanpm/admin-integrate/components/core";
2
+ import type { SxProps } from "@mui/material";
2
3
  import { useTranslations } from "next-intl";
3
4
 
4
- import { styled } from "@mui/material/styles";
5
- import { Box, Typography, SxProps } from "@mui/material";
6
-
7
- import { DayString } from "./scheduler-types";
8
-
9
- // Styled components
10
- const StyledTagBox = styled(Box)(({ theme }) => ({
11
- padding: theme.spacing(0, 1.5),
12
- border: "solid 1px",
13
- borderRadius: 4,
14
- alignContent: "center",
15
- maxWidth: "fit-content",
16
- }));
17
- const StyledTag = styled(Typography)(() => ({
18
- fontWeight: "bold",
19
- }));
5
+ import type { DayString } from "./scheduler-types";
20
6
 
21
7
  interface Props {
22
8
  day: DayString;
@@ -28,45 +14,22 @@ const DayTag: React.FC<Props> = (props: Props) => {
28
14
 
29
15
  if (props.day === "disabled") {
30
16
  return (
31
- <StyledTagBox
32
- sx={{
33
- backgroundColor: "grey.300",
34
- borderColor: "grey.600",
35
- color: "grey.600",
36
- ...props.sx,
37
- }}
38
- >
39
- <StyledTag color="grey" variant="caption">
40
- {t("Scheduler.disabled")}
41
- </StyledTag>
42
- </StyledTagBox>
17
+ <StatusTag
18
+ type="unavailable"
19
+ text={t("Scheduler.disabled")}
20
+ sx={props.sx}
21
+ />
43
22
  );
44
23
  }
45
24
 
46
25
  return props.day === "everyday" ? (
47
- <StyledTagBox
48
- sx={{
49
- backgroundColor: "success.100",
50
- borderColor: "success.main",
51
- ...props.sx,
52
- }}
53
- >
54
- <StyledTag color="success" variant="caption">
55
- {t("Scheduler.everyday")}
56
- </StyledTag>
57
- </StyledTagBox>
26
+ <StatusTag type="success" text={t("Scheduler.everyday")} sx={props.sx} />
58
27
  ) : (
59
- <StyledTagBox
60
- sx={{
61
- backgroundColor: "info.100",
62
- borderColor: "info.main",
63
- ...props.sx,
64
- }}
65
- >
66
- <StyledTag color="info" variant="caption">
67
- {t(`Scheduler.${props.day}Short`)}
68
- </StyledTag>
69
- </StyledTagBox>
28
+ <StatusTag
29
+ type="info"
30
+ text={t(`Scheduler.${props.day}Short`)}
31
+ sx={props.sx}
32
+ />
70
33
  );
71
34
  };
72
35
 
@@ -1,4 +1,5 @@
1
+ export { default as DaySelector } from "./day-selector";
1
2
  export { default as DayTag } from "./day-tag";
2
3
  export { default as ScheduleIcon } from "./schedule-icon";
3
- export { default as DaySelector } from "./day-selector";
4
+ export { default as ScheduleIntegrationIcon } from "./schedule-integration-icon";
4
5
  export * from "./scheduler-types";
@@ -0,0 +1,217 @@
1
+ import type {
2
+ ProcessScheduleGroupDetailsProcessInput,
3
+ ProcessScheduleGroupDetailsUpdate,
4
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
5
+ import type { IsDay } from "@evenicanpm/admin-integrate/components/scheduler";
6
+
7
+ export interface DefaultScheduledProcess {
8
+ id: string;
9
+ name: string;
10
+ processIcon: string;
11
+ }
12
+
13
+ export enum DetailsActionType {
14
+ INIT = "INIT",
15
+ CLOSE = "CLOSE",
16
+ EDIT_NAME = "EDIT_NAME",
17
+ TOGGLE_ENABLED = "TOGGLE_ENABLED",
18
+ EDIT_DAYS = "EDIT_DAYS",
19
+ EDIT_START_DATE = "EDIT_START_DATE",
20
+ EDIT_RECURRENCE = "EDIT_RECURRENCE",
21
+ EDIT_INTEGRATIONS = "EDIT_INTEGRATIONS",
22
+ INIT_BLANK = "INIT_BLANK",
23
+ SET_ERRORS = "SET_ERRORS",
24
+ SET_DEFAULT_SCHEDULED_PROCESS = "SET_DEFAULT_SCHEDULED_PROCESS",
25
+ }
26
+
27
+ export interface DetailsAction {
28
+ type: DetailsActionType;
29
+ }
30
+
31
+ export interface InitAction extends DetailsAction {
32
+ details: ProcessScheduleGroupDetailsUpdate;
33
+ }
34
+
35
+ export interface EditNameAction extends DetailsAction {
36
+ name: string;
37
+ }
38
+
39
+ export interface EditDaysAction extends DetailsAction {
40
+ isDay: IsDay;
41
+ }
42
+
43
+ export interface EditStartDateAction extends DetailsAction {
44
+ startDate: string;
45
+ }
46
+
47
+ export interface EditRecurrenceAction extends DetailsAction {
48
+ interval?: number;
49
+ intervalUnitId?: string;
50
+ }
51
+
52
+ export interface EditIntegrationsAction extends DetailsAction {
53
+ processes: ProcessScheduleGroupDetailsProcessInput[];
54
+ }
55
+
56
+ export interface SetErrorsAction extends DetailsAction {
57
+ errors: ErrorsState;
58
+ }
59
+
60
+ export interface SetDefaultScheduledProcessAction extends DetailsAction {
61
+ defaultScheduledProcess: DefaultScheduledProcess;
62
+ }
63
+
64
+ export interface ErrorsState {
65
+ name?: boolean;
66
+ startDate?: boolean;
67
+ interval?: boolean;
68
+ processes?: boolean;
69
+ }
70
+
71
+ export interface DetailsState {
72
+ details: ProcessScheduleGroupDetailsUpdate | null;
73
+ errors?: ErrorsState;
74
+ defaultScheduledProcess?: DefaultScheduledProcess;
75
+ }
76
+
77
+ export function detailsReducer(
78
+ state: DetailsState,
79
+ action: DetailsAction,
80
+ ): DetailsState {
81
+ switch (action.type) {
82
+ case DetailsActionType.INIT: {
83
+ const { details } = action as InitAction;
84
+ return {
85
+ ...state,
86
+ details,
87
+ errors: {
88
+ name: !details.name || details.name === "",
89
+ startDate: !details.startDate,
90
+ interval: !details.interval,
91
+ processes: !details.processes || details.processes.length === 0,
92
+ },
93
+ };
94
+ }
95
+ case DetailsActionType.INIT_BLANK: {
96
+ const blankState: ProcessScheduleGroupDetailsUpdate = {
97
+ id: "",
98
+ name: "",
99
+ code: "",
100
+ isDisabled: false,
101
+ interval: 5,
102
+ intervalUnitId: "1",
103
+ startDate: new Date().toISOString(),
104
+ processes: [],
105
+ };
106
+ return {
107
+ ...state,
108
+ details: blankState,
109
+ errors: {
110
+ name: !blankState.name || blankState.name === "",
111
+ processes: !blankState.processes || blankState.processes.length === 0,
112
+ },
113
+ };
114
+ }
115
+ case DetailsActionType.CLOSE: {
116
+ return { details: null };
117
+ }
118
+ case DetailsActionType.EDIT_NAME: {
119
+ if (!state.details) return state;
120
+
121
+ const { name } = action as EditNameAction;
122
+ const code = name.replaceAll(" ", "_").toLowerCase();
123
+ return {
124
+ ...state,
125
+ details: {
126
+ ...state.details,
127
+ name,
128
+ code,
129
+ },
130
+ };
131
+ }
132
+ case DetailsActionType.TOGGLE_ENABLED: {
133
+ if (!state.details) return state;
134
+
135
+ return {
136
+ ...state,
137
+ details: {
138
+ ...state.details,
139
+ isDisabled: !state.details.isDisabled,
140
+ },
141
+ };
142
+ }
143
+ case DetailsActionType.EDIT_DAYS: {
144
+ if (!state.details) return state;
145
+
146
+ const { isDay } = action as EditDaysAction;
147
+ return {
148
+ ...state,
149
+ details: {
150
+ ...state.details,
151
+ ...isDay,
152
+ },
153
+ };
154
+ }
155
+ case DetailsActionType.EDIT_START_DATE: {
156
+ if (!state.details) return state;
157
+
158
+ const { startDate } = action as EditStartDateAction;
159
+ return {
160
+ ...state,
161
+ details: {
162
+ ...state.details,
163
+ startDate,
164
+ },
165
+ };
166
+ }
167
+ case DetailsActionType.EDIT_RECURRENCE: {
168
+ if (!state.details) return state;
169
+
170
+ const { interval, intervalUnitId } = action as EditRecurrenceAction;
171
+ return {
172
+ ...state,
173
+ details: {
174
+ ...state.details,
175
+ ...(interval !== undefined && { interval }),
176
+ ...(intervalUnitId !== undefined && { intervalUnitId }),
177
+ },
178
+ };
179
+ }
180
+ case DetailsActionType.EDIT_INTEGRATIONS: {
181
+ if (!state.details) return state;
182
+
183
+ const { processes } = action as EditIntegrationsAction;
184
+ return {
185
+ ...state,
186
+ details: {
187
+ ...state.details,
188
+ processes: processes,
189
+ },
190
+ };
191
+ }
192
+ case DetailsActionType.SET_DEFAULT_SCHEDULED_PROCESS: {
193
+ const { defaultScheduledProcess } =
194
+ action as SetDefaultScheduledProcessAction;
195
+ return {
196
+ ...state,
197
+ defaultScheduledProcess: defaultScheduledProcess,
198
+ };
199
+ }
200
+ case DetailsActionType.SET_ERRORS: {
201
+ if (!state.details) return state;
202
+
203
+ const { errors } = action as SetErrorsAction;
204
+ return {
205
+ ...state,
206
+ errors: {
207
+ ...state.errors,
208
+ ...errors,
209
+ },
210
+ };
211
+ }
212
+ default: {
213
+ console.error(`${action.type} is not a valid action for detailsReducer`);
214
+ return state;
215
+ }
216
+ }
217
+ }