@evenicanpm/admin-integrate 1.1.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/documents/Process/fragments.ts +13 -0
- package/documents/Process/list.ts +27 -0
- package/documents/ProcessSchedule/fragments.ts +24 -0
- package/documents/ProcessSchedule/read.ts +12 -0
- package/documents/ProcessScheduleGroup/fragments.ts +29 -0
- package/documents/ProcessScheduleGroup/read.ts +12 -0
- package/documents/ScheduledProcess/fragments.ts +24 -0
- package/documents/ScheduledProcess/list.ts +27 -0
- package/package.json +21 -17
- package/src/api/Integrations/queries/get-process.query.ts +48 -0
- package/src/api/Integrations/queries/get-process.server.ts +9 -0
- package/src/api/Integrations/queries/index.ts +1 -0
- package/src/api/dashboard/queries/get-process-executions.query.ts +33 -36
- package/src/api/dashboard/queries/get-process-executions.server.ts +4 -4
- package/src/api/scheduler/queries/get-process-schedule-group-details.query.ts +45 -0
- package/src/api/scheduler/queries/get-process-schedule-group-details.server.ts +14 -0
- package/src/api/scheduler/queries/get-process-schedule.query.ts +45 -0
- package/src/api/scheduler/queries/get-process-schedule.server.ts +14 -0
- package/src/api/scheduler/queries/get-scheduled-processes.query.ts +45 -0
- package/src/api/scheduler/queries/get-scheduled-processes.server.ts +11 -0
- package/src/api/scheduler/queries/index.ts +3 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +23 -26
- package/src/components/breadcrumbs/index.ts +1 -1
- package/src/components/breadcrumbs/types.tsx +4 -0
- package/src/components/button/outlined-icon-button.tsx +26 -38
- package/src/components/core/date-time-popover.tsx +32 -0
- package/src/components/core/edited-typography.tsx +20 -0
- package/src/components/core/index.ts +3 -0
- package/src/components/core/loading.tsx +6 -6
- package/src/components/core/title-edit.tsx +122 -0
- package/src/components/dashboard-list/dashboard-list-row.tsx +114 -115
- package/src/components/dashboard-list/dashboard-list.tsx +119 -119
- package/src/components/data-table/table-header.tsx +85 -81
- package/src/components/data-table/table-pagination.tsx +27 -27
- package/src/components/data-table/table-row.tsx +14 -14
- package/src/components/data-table/table-skeleton.tsx +34 -34
- package/src/components/execution/execution-filter.ts +22 -22
- package/src/components/execution/execution-status-icon.tsx +16 -17
- package/src/components/execution/execution-tag.tsx +81 -80
- package/src/components/footer/footer.tsx +34 -34
- package/src/components/header/dashboard-list-header.tsx +64 -63
- package/src/components/header/execution-details-header.tsx +102 -129
- package/src/components/header/header.tsx +27 -27
- package/src/components/header/index.ts +1 -0
- package/src/components/header/integration-details-header.tsx +99 -0
- package/src/components/icons/up-down.tsx +15 -15
- package/src/components/integration-list/index.ts +2 -0
- package/src/components/integration-list/integration-filter.ts +21 -0
- package/src/components/integration-list/integration-status-icon.tsx +33 -0
- package/src/components/integration-list/integration-tag.tsx +77 -0
- package/src/components/integration-view/edges/default-edge.tsx +18 -17
- package/src/components/integration-view/elk-layout-options.ts +26 -26
- package/src/components/integration-view/elk-types.ts +16 -12
- package/src/components/integration-view/flow-types.tsx +5 -5
- package/src/components/integration-view/integration-view.tsx +132 -130
- package/src/components/integration-view/nodes/base-node.tsx +50 -0
- package/src/components/integration-view/nodes/connection-node.tsx +8 -8
- package/src/components/integration-view/nodes/entry-node.tsx +8 -8
- package/src/components/integration-view/nodes/group-node.tsx +47 -6
- package/src/components/integration-view/nodes/task-node.tsx +58 -13
- package/src/components/integration-view/temp-data/initialElements.tsx +224 -0
- package/src/components/integration-view/types.ts +6 -6
- package/src/components/layouts/main-layout.tsx +13 -13
- package/src/components/layouts/root-container.tsx +25 -25
- package/src/components/link-cards/link-card.tsx +23 -23
- package/src/components/link-cards/styles.ts +15 -15
- package/src/components/list-filter/date-filter.tsx +41 -45
- package/src/components/list-filter/date-range-filter.tsx +78 -77
- package/src/components/list-filter/list-filter-types.ts +38 -38
- package/src/components/list-filter/list-filter.tsx +363 -354
- package/src/components/list-filter/multi-select-filter.tsx +94 -95
- package/src/components/list-filter/select-filter.tsx +67 -64
- package/src/components/scheduler/day-selector.tsx +174 -0
- package/src/components/scheduler/day-tag.tsx +73 -0
- package/src/components/scheduler/index.ts +4 -0
- package/src/components/scheduler/schedule-filter.ts +25 -0
- package/src/components/scheduler/schedule-icon.tsx +87 -0
- package/src/components/scheduler/scheduler-types.ts +40 -0
- package/src/hooks/use-breadcrumbs.ts +31 -31
- package/src/hooks/use-recurrence.tsx +13 -0
- package/src/hooks/use-timestamp.tsx +21 -21
- package/src/pages/dashboard/dashboard-link-cards.tsx +99 -99
- package/src/pages/dashboard/dashboard-list-sections.tsx +130 -125
- package/src/pages/dashboard/dashboard.tsx +6 -6
- package/src/pages/execution-details/execution-details.tsx +23 -29
- package/src/pages/executions/executions-list/executions-list-row.tsx +101 -104
- package/src/pages/executions/executions-list/executions-list-table.tsx +45 -53
- package/src/pages/executions/executions-list/executions-list.tsx +219 -212
- package/src/pages/executions/executions.tsx +67 -72
- package/src/pages/integrations/integration-list/index.ts +1 -0
- package/src/pages/integrations/integration-list/integration-list-row.tsx +147 -0
- package/src/pages/integrations/integration-list/integration-list-table.tsx +78 -0
- package/src/pages/integrations/integration-list/integration-list.tsx +262 -0
- package/src/pages/integrations/integrations.tsx +83 -28
- package/src/pages/scheduler/schedule-drawer/edited/edited-types.ts +17 -0
- package/src/pages/scheduler/schedule-drawer/edited/index.ts +1 -0
- package/src/pages/scheduler/schedule-drawer/index.ts +1 -0
- package/src/pages/scheduler/schedule-drawer/schedule-details-integrations.tsx +227 -0
- package/src/pages/scheduler/schedule-drawer/schedule-details-main.tsx +292 -0
- package/src/pages/scheduler/schedule-drawer/schedule-details-name.tsx +77 -0
- package/src/pages/scheduler/schedule-drawer/schedule-details-skeleton.tsx +64 -0
- package/src/pages/scheduler/schedule-drawer/schedule-details.tsx +42 -0
- package/src/pages/scheduler/schedule-drawer/schedule-drawer-buttons.tsx +72 -0
- package/src/pages/scheduler/schedule-drawer/schedule-drawer-group.tsx +103 -0
- package/src/pages/scheduler/schedule-drawer/schedule-drawer-legacy.tsx +94 -0
- package/src/pages/scheduler/schedule-drawer/schedule-drawer.tsx +101 -0
- package/src/pages/scheduler/schedule-drawer/sortable-integration-row.tsx +93 -0
- package/src/pages/scheduler/scheduler.tsx +106 -30
- package/src/pages/scheduler/schedules-list/index.ts +1 -0
- package/src/pages/scheduler/schedules-list/schedules-list-row.tsx +235 -0
- package/src/pages/scheduler/schedules-list/schedules-list-table.tsx +74 -0
- package/src/pages/scheduler/schedules-list/schedules-list.tsx +280 -0
- package/tsconfig.json +29 -26
- package/src/components/integration-view/temp-data/initialElements.ts +0 -238
|
@@ -1,39 +1,115 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useState } from "react";
|
|
2
2
|
import { useTranslations } from "next-intl";
|
|
3
3
|
|
|
4
|
+
// API
|
|
5
|
+
import { getScheduledProcesses } from "@evenicanpm/admin-integrate/api/scheduler/queries";
|
|
6
|
+
import {
|
|
7
|
+
ScheduledProcessInput,
|
|
8
|
+
GetScheduledProcessesQuery,
|
|
9
|
+
} from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
|
|
10
|
+
|
|
4
11
|
// MUI
|
|
5
|
-
import { Theme, useTheme } from "@mui/material";
|
|
6
12
|
import { Box } from "@mui/material";
|
|
7
13
|
|
|
8
14
|
// Custom components
|
|
9
|
-
import {
|
|
10
|
-
IntegrateBreadcrumbs,
|
|
11
|
-
Crumb,
|
|
12
|
-
} from "@evenicanpm/admin-integrate/components/breadcrumbs";
|
|
15
|
+
import { IntegrateBreadcrumbs } from "@evenicanpm/admin-integrate/components/breadcrumbs";
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
name: t("Header.dashboard"),
|
|
23
|
-
url: "/e4integrate",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: t("Header.scheduler"),
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Box>
|
|
32
|
-
<IntegrateBreadcrumbs breadcrumbs={breadcrumbs} />
|
|
33
|
-
</Box>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
17
|
+
// Local components
|
|
18
|
+
import SchedulesList from "./schedules-list";
|
|
19
|
+
import ScheduleDrawer from "./schedule-drawer";
|
|
20
|
+
|
|
21
|
+
// Types
|
|
22
|
+
import { Crumb } from "@evenicanpm/admin-integrate/components/breadcrumbs";
|
|
23
|
+
import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
export type DrawerOpen = {
|
|
26
|
+
id: string;
|
|
27
|
+
group?: boolean;
|
|
39
28
|
};
|
|
29
|
+
|
|
30
|
+
export default function Scheduler() {
|
|
31
|
+
const t = useTranslations("Integrate");
|
|
32
|
+
const l = useTranslations("Integrate.Scheduler.ListHeader");
|
|
33
|
+
|
|
34
|
+
const breadcrumbs: Crumb[] = [
|
|
35
|
+
{
|
|
36
|
+
name: t("Header.dashboard"),
|
|
37
|
+
url: "/e4integrate",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: t("Header.scheduler"),
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const heading: Head[] = [
|
|
45
|
+
{
|
|
46
|
+
id: "name",
|
|
47
|
+
label: l("schedule"),
|
|
48
|
+
align: "left",
|
|
49
|
+
width: "20%",
|
|
50
|
+
sortable: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "daysOfTheWeek",
|
|
54
|
+
label: l("daysOfTheWeek"),
|
|
55
|
+
align: "center",
|
|
56
|
+
width: "20%",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "interval",
|
|
60
|
+
label: l("recurrence"),
|
|
61
|
+
align: "center",
|
|
62
|
+
width: "20%",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "startDate",
|
|
66
|
+
label: l("start"),
|
|
67
|
+
align: "center",
|
|
68
|
+
width: "15%",
|
|
69
|
+
sortable: true,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "modified",
|
|
73
|
+
label: l("lastModified"),
|
|
74
|
+
align: "center",
|
|
75
|
+
width: "15%",
|
|
76
|
+
sortable: true,
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "view",
|
|
80
|
+
label: l("actions"),
|
|
81
|
+
align: "right",
|
|
82
|
+
width: "5%",
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
// id of clicked schedule if open OR null if closed
|
|
87
|
+
const [drawerOpen, setDrawerOpen] = useState<DrawerOpen | null>(null);
|
|
88
|
+
|
|
89
|
+
// TODO: initialize input based on url query params
|
|
90
|
+
const [input, setInput] = useState<ScheduledProcessInput>({
|
|
91
|
+
sort: "modified",
|
|
92
|
+
sortDesc: true,
|
|
93
|
+
top: 10,
|
|
94
|
+
skip: 0,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const { data, isLoading } = getScheduledProcesses.useData({
|
|
98
|
+
input: input,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Box>
|
|
103
|
+
<IntegrateBreadcrumbs breadcrumbs={breadcrumbs} />
|
|
104
|
+
<SchedulesList
|
|
105
|
+
heading={heading}
|
|
106
|
+
data={data as GetScheduledProcessesQuery}
|
|
107
|
+
loading={isLoading}
|
|
108
|
+
input={input}
|
|
109
|
+
setInput={setInput}
|
|
110
|
+
setDrawerOpen={setDrawerOpen}
|
|
111
|
+
/>
|
|
112
|
+
<ScheduleDrawer drawerOpen={drawerOpen} setDrawerOpen={setDrawerOpen} />
|
|
113
|
+
</Box>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./schedules-list";
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
|
|
3
|
+
// MUI
|
|
4
|
+
import { Theme, useTheme } from "@mui/material";
|
|
5
|
+
import { Box, Stack, Typography } from "@mui/material";
|
|
6
|
+
import { RemoveRedEye } from "@mui/icons-material";
|
|
7
|
+
import { SxProps } from "@mui/material";
|
|
8
|
+
|
|
9
|
+
// Custom components
|
|
10
|
+
import {
|
|
11
|
+
StyledTableCell,
|
|
12
|
+
StyledTableRow,
|
|
13
|
+
StyledIconButton,
|
|
14
|
+
} from "@evenicanpm/admin-integrate/components/data-table/table-row";
|
|
15
|
+
import {
|
|
16
|
+
DayTag,
|
|
17
|
+
ScheduleIcon,
|
|
18
|
+
} from "@evenicanpm/admin-integrate/components/scheduler";
|
|
19
|
+
import { DateTimePopover } from "@evenicanpm/admin-integrate/components/core";
|
|
20
|
+
|
|
21
|
+
// Hooks
|
|
22
|
+
import useTimestamp from "@evenicanpm/admin-integrate/hooks/use-timestamp";
|
|
23
|
+
import useRecurrence from "@evenicanpm/admin-integrate/hooks/use-recurrence";
|
|
24
|
+
|
|
25
|
+
// Types
|
|
26
|
+
import { Item } from "./schedules-list";
|
|
27
|
+
import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
|
|
28
|
+
import { TableCellProps } from "@mui/material";
|
|
29
|
+
import {
|
|
30
|
+
DayString,
|
|
31
|
+
dayKeys,
|
|
32
|
+
isDayMap,
|
|
33
|
+
} from "@evenicanpm/admin-integrate/components/scheduler";
|
|
34
|
+
import { DrawerOpen } from "../scheduler";
|
|
35
|
+
|
|
36
|
+
interface Props {
|
|
37
|
+
item: Item;
|
|
38
|
+
heading: Head[]; // for alignment
|
|
39
|
+
sx?: SxProps;
|
|
40
|
+
setDrawerOpen: React.Dispatch<React.SetStateAction<DrawerOpen | null>>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SchedulesListRow: React.FC<Props> = (props: Props) => {
|
|
44
|
+
const theme = useTheme();
|
|
45
|
+
const styles = getStyles(theme);
|
|
46
|
+
|
|
47
|
+
// e.g. "xx days ago"
|
|
48
|
+
const modified = useTimestamp(props.item.modified);
|
|
49
|
+
const modifiedFull = new Date(props.item.modified).toString();
|
|
50
|
+
|
|
51
|
+
const recurrence = useRecurrence(
|
|
52
|
+
props.item.interval,
|
|
53
|
+
props.item.intervalUnitId,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const start = new Date(props.item.startDate);
|
|
57
|
+
const startDateLocale = start.toLocaleString().split(",")[0];
|
|
58
|
+
const startTimeLocale = start.toLocaleTimeString().slice(0, 5);
|
|
59
|
+
const startDateFull = start.toString();
|
|
60
|
+
|
|
61
|
+
const [modifiedAnchorEl, setModifiedAnchorEl] = useState<HTMLElement | null>(
|
|
62
|
+
null,
|
|
63
|
+
);
|
|
64
|
+
const modifiedOpen = Boolean(modifiedAnchorEl);
|
|
65
|
+
const [startDateAnchorEl, setStartDateAnchorlEl] =
|
|
66
|
+
useState<HTMLElement | null>(null);
|
|
67
|
+
const startDateOpen = Boolean(startDateAnchorEl);
|
|
68
|
+
|
|
69
|
+
const handlePopoverOpen = (event: React.MouseEvent<HTMLElement>) => {
|
|
70
|
+
const classList = event.currentTarget.classList;
|
|
71
|
+
if (classList.contains("scheduled-process-modified")) {
|
|
72
|
+
setModifiedAnchorEl(event.currentTarget);
|
|
73
|
+
} else if (classList.contains("scheduled-process-start-date")) {
|
|
74
|
+
setStartDateAnchorlEl(event.currentTarget);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const handlePopoverClose = () => {
|
|
79
|
+
setModifiedAnchorEl(null);
|
|
80
|
+
setStartDateAnchorlEl(null);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleMenuOpen = () => {
|
|
84
|
+
const newDrawerOpen: DrawerOpen = {
|
|
85
|
+
id: props.item.id,
|
|
86
|
+
};
|
|
87
|
+
if (props.item.processScheduleGroup) {
|
|
88
|
+
newDrawerOpen.group = true;
|
|
89
|
+
}
|
|
90
|
+
props.setDrawerOpen(newDrawerOpen);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const daysOfTheWeek = parseDaysOfTheWeek(props.item);
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<StyledTableRow sx={props.sx}>
|
|
97
|
+
<StyledTableCell
|
|
98
|
+
align={props.heading[0].align as TableCellProps["align"]}
|
|
99
|
+
width={props.heading[0].width}
|
|
100
|
+
>
|
|
101
|
+
<Stack spacing={1} direction="row">
|
|
102
|
+
<Box display="flex" justifyContent="flex-end" alignItems="center">
|
|
103
|
+
<ScheduleIcon
|
|
104
|
+
isDisabled={props.item.isDisabled}
|
|
105
|
+
isLegacy={!props.item.processScheduleGroup}
|
|
106
|
+
enablePopover
|
|
107
|
+
/>
|
|
108
|
+
</Box>
|
|
109
|
+
<Box display="flex" justifyContent="flex-end" alignItems="center">
|
|
110
|
+
<Typography>{props.item.name}</Typography>
|
|
111
|
+
</Box>
|
|
112
|
+
</Stack>
|
|
113
|
+
</StyledTableCell>
|
|
114
|
+
<StyledTableCell
|
|
115
|
+
align={props.heading[1].align as TableCellProps["align"]}
|
|
116
|
+
width={props.heading[1].width}
|
|
117
|
+
>
|
|
118
|
+
<Box
|
|
119
|
+
display="flex"
|
|
120
|
+
flexWrap="wrap"
|
|
121
|
+
justifyContent={props.heading[1].align as TableCellProps["align"]}
|
|
122
|
+
minWidth={theme.spacing(25)}
|
|
123
|
+
>
|
|
124
|
+
{daysOfTheWeek.map((day) => (
|
|
125
|
+
<DayTag
|
|
126
|
+
key={`${props.item.id}_${day}`}
|
|
127
|
+
day={day}
|
|
128
|
+
sx={styles.dayTag}
|
|
129
|
+
/>
|
|
130
|
+
))}
|
|
131
|
+
</Box>
|
|
132
|
+
</StyledTableCell>
|
|
133
|
+
<StyledTableCell
|
|
134
|
+
align={props.heading[2].align as TableCellProps["align"]}
|
|
135
|
+
width={props.heading[2].width}
|
|
136
|
+
>
|
|
137
|
+
<Typography>{recurrence}</Typography>
|
|
138
|
+
</StyledTableCell>
|
|
139
|
+
<StyledTableCell
|
|
140
|
+
align={props.heading[3].align as TableCellProps["align"]}
|
|
141
|
+
width={props.heading[3].width}
|
|
142
|
+
sx={styles.timeCell}
|
|
143
|
+
>
|
|
144
|
+
<Typography
|
|
145
|
+
className="scheduled-process-start-date"
|
|
146
|
+
onMouseEnter={handlePopoverOpen}
|
|
147
|
+
onMouseLeave={handlePopoverClose}
|
|
148
|
+
>
|
|
149
|
+
{`${startDateLocale} ${startTimeLocale}`}
|
|
150
|
+
</Typography>
|
|
151
|
+
</StyledTableCell>
|
|
152
|
+
<StyledTableCell
|
|
153
|
+
align={props.heading[4].align as TableCellProps["align"]}
|
|
154
|
+
width={props.heading[4].width}
|
|
155
|
+
sx={styles.timeCell}
|
|
156
|
+
>
|
|
157
|
+
<Typography
|
|
158
|
+
className="scheduled-process-modified"
|
|
159
|
+
onMouseEnter={handlePopoverOpen}
|
|
160
|
+
onMouseLeave={handlePopoverClose}
|
|
161
|
+
>
|
|
162
|
+
{modified}
|
|
163
|
+
</Typography>
|
|
164
|
+
</StyledTableCell>
|
|
165
|
+
<StyledTableCell
|
|
166
|
+
align={props.heading[5].align as TableCellProps["align"]}
|
|
167
|
+
width={props.heading[5].width}
|
|
168
|
+
>
|
|
169
|
+
<StyledIconButton onClick={handleMenuOpen}>
|
|
170
|
+
<RemoveRedEye />
|
|
171
|
+
</StyledIconButton>
|
|
172
|
+
</StyledTableCell>
|
|
173
|
+
|
|
174
|
+
<DateTimePopover
|
|
175
|
+
dateIsoString={modifiedFull}
|
|
176
|
+
sx={{ pointerEvents: "none" }}
|
|
177
|
+
open={modifiedOpen}
|
|
178
|
+
anchorEl={modifiedAnchorEl}
|
|
179
|
+
anchorOrigin={{
|
|
180
|
+
vertical: "bottom",
|
|
181
|
+
horizontal: "center",
|
|
182
|
+
}}
|
|
183
|
+
transformOrigin={{
|
|
184
|
+
vertical: "top",
|
|
185
|
+
horizontal: "center",
|
|
186
|
+
}}
|
|
187
|
+
onClose={handlePopoverClose}
|
|
188
|
+
disableRestoreFocus
|
|
189
|
+
/>
|
|
190
|
+
<DateTimePopover
|
|
191
|
+
dateIsoString={startDateFull}
|
|
192
|
+
sx={{ pointerEvents: "none" }}
|
|
193
|
+
open={startDateOpen}
|
|
194
|
+
anchorEl={startDateAnchorEl}
|
|
195
|
+
anchorOrigin={{
|
|
196
|
+
vertical: "bottom",
|
|
197
|
+
horizontal: "center",
|
|
198
|
+
}}
|
|
199
|
+
transformOrigin={{
|
|
200
|
+
vertical: "top",
|
|
201
|
+
horizontal: "center",
|
|
202
|
+
}}
|
|
203
|
+
onClose={handlePopoverClose}
|
|
204
|
+
disableRestoreFocus
|
|
205
|
+
/>
|
|
206
|
+
</StyledTableRow>
|
|
207
|
+
);
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const getStyles = (theme: Theme) => {
|
|
211
|
+
return {
|
|
212
|
+
timeCell: {
|
|
213
|
+
cursor: "default",
|
|
214
|
+
},
|
|
215
|
+
popover: {
|
|
216
|
+
padding: theme.spacing(1),
|
|
217
|
+
},
|
|
218
|
+
dayTag: {
|
|
219
|
+
margin: theme.spacing(0.5),
|
|
220
|
+
},
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const parseDaysOfTheWeek = (item: Item): DayString[] => {
|
|
225
|
+
type Day = keyof typeof isDayMap;
|
|
226
|
+
|
|
227
|
+
const selectedDays = dayKeys.filter((day): day is Day => {
|
|
228
|
+
const key = isDayMap[day as Day];
|
|
229
|
+
return item[key];
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
return selectedDays.length === 7 ? ["everyday"] : selectedDays;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export default SchedulesListRow;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
// Types
|
|
4
|
+
import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
|
|
5
|
+
import { Item } from "./schedules-list";
|
|
6
|
+
|
|
7
|
+
// API
|
|
8
|
+
import { ScheduledProcessInput } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
|
|
9
|
+
|
|
10
|
+
// MUI
|
|
11
|
+
import { TableContainer, Table, TableBody } from "@mui/material";
|
|
12
|
+
import { SxProps } from "@mui/material";
|
|
13
|
+
|
|
14
|
+
// Custom components
|
|
15
|
+
import { TableHeader } from "@evenicanpm/admin-integrate/components/data-table";
|
|
16
|
+
|
|
17
|
+
// Local components
|
|
18
|
+
import SchedulesListRow from "./schedules-list-row";
|
|
19
|
+
|
|
20
|
+
// Types
|
|
21
|
+
import { DrawerOpen } from "../scheduler";
|
|
22
|
+
|
|
23
|
+
interface Props {
|
|
24
|
+
heading: Head[];
|
|
25
|
+
items: Item[];
|
|
26
|
+
input: ScheduledProcessInput;
|
|
27
|
+
setInput: (newInput: ScheduledProcessInput) => void;
|
|
28
|
+
rowSx?: SxProps;
|
|
29
|
+
setDrawerOpen: React.Dispatch<React.SetStateAction<DrawerOpen | null>>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default function SchedulesListTable(props: Props) {
|
|
33
|
+
const handleRequestSort = (property: string) => {
|
|
34
|
+
const current = props.input.sort;
|
|
35
|
+
if (property === current) {
|
|
36
|
+
props.setInput({
|
|
37
|
+
...props.input,
|
|
38
|
+
sortDesc: !props.input.sortDesc,
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
props.setInput({
|
|
42
|
+
...props.input,
|
|
43
|
+
sort: property,
|
|
44
|
+
sortDesc: false,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
<TableContainer>
|
|
52
|
+
<Table>
|
|
53
|
+
<TableHeader
|
|
54
|
+
heading={props.heading}
|
|
55
|
+
orderBy={props.input.sort || ""}
|
|
56
|
+
order={props.input.sortDesc ? "desc" : "asc"}
|
|
57
|
+
onRequestSort={handleRequestSort}
|
|
58
|
+
/>
|
|
59
|
+
<TableBody>
|
|
60
|
+
{props.items.map((item, index) => (
|
|
61
|
+
<SchedulesListRow
|
|
62
|
+
key={index}
|
|
63
|
+
item={item}
|
|
64
|
+
heading={props.heading}
|
|
65
|
+
sx={props.rowSx}
|
|
66
|
+
setDrawerOpen={props.setDrawerOpen}
|
|
67
|
+
/>
|
|
68
|
+
))}
|
|
69
|
+
</TableBody>
|
|
70
|
+
</Table>
|
|
71
|
+
</TableContainer>
|
|
72
|
+
</>
|
|
73
|
+
);
|
|
74
|
+
}
|