@dexteel/mesf-core 7.17.2 → 7.18.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.
- package/.github/workflows/publish-to-npm.yaml +2 -7
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +7 -0
- package/dist/configuration/pages/shifCrew/ShiftsCrewsPage.d.ts +0 -2
- package/dist/configuration/pages/shifCrew/components/Create/CreateShift.d.ts +3 -1
- package/dist/configuration/pages/shifCrew/components/Delete/DeleteShift.d.ts +3 -1
- package/dist/configuration/pages/shifCrew/components/Edit/EditShift.d.ts +3 -1
- package/dist/configuration/pages/shifCrew/repositories/ShiftsCrewsRepository.d.ts +3 -3
- package/dist/controls/index.d.ts +2 -0
- package/dist/controls/shift-navigator/component/shift-navigator.control.d.ts +2 -1
- package/dist/controls/shift-navigator/hook/useShiftNavigator.d.ts +6 -6
- package/dist/controls/shift-navigator-v2/repositories/ShiftsRepository.d.ts +1 -0
- package/dist/controls/shift-selector/ShiftAutocomplete.d.ts +12 -2
- package/dist/controls/shift-selector/repositories/ShiftRepository.d.ts +6 -0
- package/dist/index.esm.js +1482 -1412
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
|
|
2
2
|
export * from '@microsoft/signalr';
|
|
3
3
|
export { LicenseManager } from 'ag-grid-enterprise';
|
|
4
|
-
import { styled, DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogActions as DialogActions$1, Grid2, Button, Box, MenuItem, ListItemIcon, createTheme, TextField, Alert as Alert$2, useTheme, InputAdornment, Popover, MenuList, ListItemText, alpha, Dialog as Dialog$1, Paper, List, ListItem, Chip, SvgIcon, Typography as Typography$1, Checkbox, IconButton as IconButton$1, CircularProgress, FormControl, FormHelperText, FormControlLabel, Snackbar, DialogContentText, Badge, InputLabel, Select, Input, Divider, Card, CardContent, CardActions, Collapse, Tooltip, CssBaseline, AppBar, Toolbar, Container, Menu, Switch, Autocomplete, useMediaQuery, Drawer, Grid, Accordion, AccordionSummary, AccordionDetails, Tabs, Tab, ListSubheader, ListItemButton, StyledEngineProvider, ThemeProvider, ListItemSecondaryAction } from '@mui/material';
|
|
4
|
+
import { styled, DialogTitle as DialogTitle$1, DialogContent as DialogContent$1, DialogActions as DialogActions$1, Grid2, Button, Box, MenuItem, ListItemIcon, createTheme, TextField, Alert as Alert$2, useTheme, InputAdornment, Popover, MenuList, ListItemText, alpha, Dialog as Dialog$1, Paper, List, ListItem, Chip, SvgIcon, Typography as Typography$1, Checkbox, IconButton as IconButton$1, CircularProgress, FormControl, FormHelperText, FormControlLabel, Snackbar, DialogContentText, Badge, InputLabel, Select, Input, Divider, Card, CardContent, CardActions, Collapse, Tooltip, CssBaseline, AppBar, Toolbar, Container, Menu, Switch, Autocomplete as Autocomplete$1, useMediaQuery, Drawer, Grid, Accordion, AccordionSummary, AccordionDetails, Tabs, Tab, ListSubheader, ListItemButton, StyledEngineProvider, ThemeProvider, ListItemSecondaryAction } from '@mui/material';
|
|
5
5
|
import { useMutation, useQuery, useQueryClient, QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import React__default, { createContext, useContext, useRef, useState, useEffect, useCallback, useMemo, Component, lazy, Suspense } from 'react';
|
|
@@ -11,7 +11,7 @@ import { createPart, themeMaterial, provideGlobalGridOptions } from 'ag-grid-com
|
|
|
11
11
|
import { values, get, isEmpty, isNil } from 'lodash-es';
|
|
12
12
|
import { useForm, Controller } from 'react-hook-form';
|
|
13
13
|
import { isAncestor, Tree, DndProvider as DndProvider$1 } from '@minoru/react-dnd-treeview';
|
|
14
|
-
import { Alert as Alert$4,
|
|
14
|
+
import { Alert as Alert$4, Autocomplete, AlertTitle } from '@mui/lab';
|
|
15
15
|
import { Helmet, HelmetProvider } from 'react-helmet-async';
|
|
16
16
|
import AccountTree from '@mui/icons-material/AccountTree';
|
|
17
17
|
import Settings$1 from '@mui/icons-material/Settings';
|
|
@@ -5568,7 +5568,7 @@ const LongFilterPanel = (props) => {
|
|
|
5568
5568
|
};
|
|
5569
5569
|
|
|
5570
5570
|
const getShiftByParameters = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5571
|
-
var _a;
|
|
5571
|
+
var _a, _b;
|
|
5572
5572
|
const utcString = (_a = parameters.productionDate) === null || _a === void 0 ? void 0 : _a.toISOString();
|
|
5573
5573
|
try {
|
|
5574
5574
|
const sqlParameters = [];
|
|
@@ -5580,6 +5580,10 @@ const getShiftByParameters = (parameters) => __awaiter(void 0, void 0, void 0, f
|
|
|
5580
5580
|
name: "@ProductionDate",
|
|
5581
5581
|
value: utcString,
|
|
5582
5582
|
});
|
|
5583
|
+
sqlParameters.push({
|
|
5584
|
+
name: "@AssetId",
|
|
5585
|
+
value: (_b = parameters.assetId) !== null && _b !== void 0 ? _b : null,
|
|
5586
|
+
});
|
|
5583
5587
|
const apiService = new MESApiService();
|
|
5584
5588
|
const resp = yield apiService.callV2("[MES].[GetShiftByParameters]", sqlParameters);
|
|
5585
5589
|
if (resp.ok) {
|
|
@@ -5604,7 +5608,7 @@ const useShiftNavigatorManager = () => {
|
|
|
5604
5608
|
const [shiftInfo, setShiftInfo] = useState(null);
|
|
5605
5609
|
const [isShiftInfoLoading, setIsShiftInfoLoading] = useState(false);
|
|
5606
5610
|
const [error, setError] = useState("");
|
|
5607
|
-
const moveShift = (direction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5611
|
+
const moveShift = (direction, assetId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5608
5612
|
if (isNil(shiftInfo)) {
|
|
5609
5613
|
return;
|
|
5610
5614
|
}
|
|
@@ -5623,6 +5627,7 @@ const useShiftNavigatorManager = () => {
|
|
|
5623
5627
|
const resp = yield getShiftByParameters({
|
|
5624
5628
|
productionDate: null,
|
|
5625
5629
|
shiftId: shiftId,
|
|
5630
|
+
assetId,
|
|
5626
5631
|
});
|
|
5627
5632
|
if (resp.ok) {
|
|
5628
5633
|
const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$f
|
|
@@ -5635,12 +5640,13 @@ const useShiftNavigatorManager = () => {
|
|
|
5635
5640
|
}
|
|
5636
5641
|
}
|
|
5637
5642
|
});
|
|
5638
|
-
const getShiftDataFromAPI = (productionDate, shiftId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5643
|
+
const getShiftDataFromAPI = (productionDate, shiftId, assetId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5639
5644
|
setIsShiftInfoLoading(true);
|
|
5640
5645
|
try {
|
|
5641
5646
|
const resp = yield getShiftByParameters({
|
|
5642
5647
|
productionDate: productionDate,
|
|
5643
5648
|
shiftId: shiftId,
|
|
5649
|
+
assetId,
|
|
5644
5650
|
});
|
|
5645
5651
|
if (resp.ok) {
|
|
5646
5652
|
const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$f
|
|
@@ -5657,10 +5663,11 @@ const useShiftNavigatorManager = () => {
|
|
|
5657
5663
|
}
|
|
5658
5664
|
setIsShiftInfoLoading(false);
|
|
5659
5665
|
});
|
|
5660
|
-
const initShiftNavigator = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
5666
|
+
const initShiftNavigator = (assetId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5661
5667
|
const resp = yield getShiftByParameters({
|
|
5662
5668
|
productionDate: new Date(),
|
|
5663
5669
|
shiftId: 0,
|
|
5670
|
+
assetId,
|
|
5664
5671
|
});
|
|
5665
5672
|
if (resp.ok) {
|
|
5666
5673
|
const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$f
|
|
@@ -5723,7 +5730,7 @@ const ShiftNavigatorProvider = ({ children }) => {
|
|
|
5723
5730
|
|
|
5724
5731
|
const ShiftDayNavigatorControl = (_a) => {
|
|
5725
5732
|
var _b;
|
|
5726
|
-
var { useRouter, onShiftChange, preventInit, withPaper = true, margin = "1rem 1rem 1rem 1rem" } = _a, props = __rest(_a, ["useRouter", "onShiftChange", "preventInit", "withPaper", "margin"]);
|
|
5733
|
+
var { useRouter, onShiftChange, preventInit, withPaper = true, margin = "1rem 1rem 1rem 1rem", assetId } = _a, props = __rest(_a, ["useRouter", "onShiftChange", "preventInit", "withPaper", "margin", "assetId"]);
|
|
5727
5734
|
const { shiftInfo, initShiftNavigator, moveShift, getShiftDataFromAPI } = useShiftNavigator();
|
|
5728
5735
|
const [shiftInfoCopy, setShiftInfoCopy] = useState(shiftInfo);
|
|
5729
5736
|
const [error, setError] = useState("");
|
|
@@ -5775,12 +5782,12 @@ const ShiftDayNavigatorControl = (_a) => {
|
|
|
5775
5782
|
return;
|
|
5776
5783
|
}
|
|
5777
5784
|
if (useRouter && shiftId) {
|
|
5778
|
-
getShiftDataFromAPI(null, Number(shiftId)).then(() => {
|
|
5785
|
+
getShiftDataFromAPI(null, Number(shiftId), assetId).then(() => {
|
|
5779
5786
|
onShiftChange && onShiftChange(Number(shiftId));
|
|
5780
5787
|
});
|
|
5781
5788
|
}
|
|
5782
5789
|
else {
|
|
5783
|
-
initShiftNavigator().then(() => {
|
|
5790
|
+
initShiftNavigator(assetId).then(() => {
|
|
5784
5791
|
onShiftChange && onShiftChange(Number(shiftId));
|
|
5785
5792
|
});
|
|
5786
5793
|
}
|
|
@@ -5790,13 +5797,13 @@ const ShiftDayNavigatorControl = (_a) => {
|
|
|
5790
5797
|
React__default.createElement(Grid2, { size: "auto" },
|
|
5791
5798
|
React__default.createElement(Tooltip, { title: "Previous Shift" },
|
|
5792
5799
|
React__default.createElement(IconButton$1, { "aria-label": "Previous Shift", color: "primary", disabled: !(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.PreviousShiftId), onClick: () => {
|
|
5793
|
-
moveShift("Previous").then(() => { });
|
|
5800
|
+
moveShift("Previous", assetId).then(() => { });
|
|
5794
5801
|
}, size: "small" },
|
|
5795
5802
|
React__default.createElement(ArrowBackRounded, null)))),
|
|
5796
5803
|
React__default.createElement(Grid2, { size: "auto" },
|
|
5797
5804
|
React__default.createElement(DatePicker, { label: "Current Date", timezone: "UTC", format: "MM/DD/YYYY", maxDate: moment$g(), closeOnSelect: true, formatDensity: "dense", value: moment$g(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentProductionDate), onChange: (date) => {
|
|
5798
5805
|
if (date) {
|
|
5799
|
-
getShiftDataFromAPI(date.toDate(), 0).then(() => { });
|
|
5806
|
+
getShiftDataFromAPI(date.toDate(), 0, assetId).then(() => { });
|
|
5800
5807
|
}
|
|
5801
5808
|
}, slots: {
|
|
5802
5809
|
textField: TextField,
|
|
@@ -5817,13 +5824,13 @@ const ShiftDayNavigatorControl = (_a) => {
|
|
|
5817
5824
|
React__default.createElement(Grid2, { size: "auto" },
|
|
5818
5825
|
React__default.createElement(Tooltip, { title: "Next Shift" },
|
|
5819
5826
|
React__default.createElement(IconButton$1, { "aria-label": "next", color: "primary", disabled: !(shiftInfoCopy === null || shiftInfoCopy === void 0 ? void 0 : shiftInfoCopy.NextShiftId), onClick: () => {
|
|
5820
|
-
moveShift("Next").then(() => { });
|
|
5827
|
+
moveShift("Next", assetId).then(() => { });
|
|
5821
5828
|
}, size: "small" },
|
|
5822
5829
|
React__default.createElement(ArrowForwardRounded, null)))),
|
|
5823
5830
|
React__default.createElement(Grid2, null,
|
|
5824
5831
|
React__default.createElement(Tooltip, { title: "Last Shift" },
|
|
5825
5832
|
React__default.createElement(IconButton$1, { "aria-label": "delete", color: "primary", disabled: !(shiftInfoCopy === null || shiftInfoCopy === void 0 ? void 0 : shiftInfoCopy.LastShiftId) || !(shiftInfoCopy === null || shiftInfoCopy === void 0 ? void 0 : shiftInfoCopy.NextShiftId), onClick: () => {
|
|
5826
|
-
moveShift("Last").then(() => { });
|
|
5833
|
+
moveShift("Last", assetId).then(() => { });
|
|
5827
5834
|
}, size: "small" },
|
|
5828
5835
|
React__default.createElement(SkipNext, null))))));
|
|
5829
5836
|
return withPaper !== false ? React__default.createElement(Paper, null, gridContent) : gridContent;
|
|
@@ -6142,6 +6149,170 @@ const ShiftPeriodNavigatorControl = ({ value, actualPeriod, onChange, showShiftA
|
|
|
6142
6149
|
React__default.createElement(SkipNextIcon, null)))));
|
|
6143
6150
|
};
|
|
6144
6151
|
|
|
6152
|
+
const moment$e = getMomentTz();
|
|
6153
|
+
const getShifts = (params, signal) => __awaiter(void 0, void 0, void 0, function* () {
|
|
6154
|
+
var _a;
|
|
6155
|
+
const apiService = new MESApiService();
|
|
6156
|
+
const parameters = [
|
|
6157
|
+
{
|
|
6158
|
+
name: "ShiftId",
|
|
6159
|
+
value: (_a = params.shiftId) !== null && _a !== void 0 ? _a : null,
|
|
6160
|
+
},
|
|
6161
|
+
];
|
|
6162
|
+
const resp = yield apiService.callV2(`[MES].[GetShiftByParameters]`, parameters, signal);
|
|
6163
|
+
if (resp.ok) {
|
|
6164
|
+
let rows = get(resp, "data.tables[0].rows", []);
|
|
6165
|
+
rows = rows.map((row) => {
|
|
6166
|
+
(row.CurrentProductionDate = moment$e
|
|
6167
|
+
.utc(row["CurrentProductionDate"])
|
|
6168
|
+
.toDate()),
|
|
6169
|
+
(row.CurrentStart = moment$e.utc(row["CurrentStart"]).toDate()),
|
|
6170
|
+
(row.CurrentEnd = moment$e.utc(row["CurrentEnd"]).toDate()),
|
|
6171
|
+
(row.PreviousProductionDate = moment$e
|
|
6172
|
+
.utc(row["PreviousProductionDate"])
|
|
6173
|
+
.toDate()),
|
|
6174
|
+
(row.PreviousStart = moment$e.utc(row["PreviousStart"]).toDate()),
|
|
6175
|
+
(row.PreviousEnd = moment$e.utc(row["PreviousEnd"]).toDate()),
|
|
6176
|
+
(row.NextProductionDate = moment$e
|
|
6177
|
+
.utc(row["NextProductionDate"])
|
|
6178
|
+
.toDate()),
|
|
6179
|
+
(row.NextStart = moment$e.utc(row["NextStart"]).toDate()),
|
|
6180
|
+
(row.NextEnd = moment$e.utc(row["NextEnd"]).toDate()),
|
|
6181
|
+
(row.LastProductionDate = moment$e
|
|
6182
|
+
.utc(row["LastProductionDate"])
|
|
6183
|
+
.toDate()),
|
|
6184
|
+
(row.LastStart = moment$e.utc(row["LastStart"]).toDate()),
|
|
6185
|
+
(row.LastEnd = moment$e.utc(row["LastEnd"]).toDate());
|
|
6186
|
+
return row;
|
|
6187
|
+
});
|
|
6188
|
+
return rows;
|
|
6189
|
+
}
|
|
6190
|
+
else {
|
|
6191
|
+
throw new Error(resp.message || "Error fetching shifts");
|
|
6192
|
+
}
|
|
6193
|
+
});
|
|
6194
|
+
const getShiftsByRange = (_a) => __awaiter(void 0, [_a], void 0, function* ({ shiftId, assetId, shiftsBefore, shiftsAfter, }) {
|
|
6195
|
+
const apiService = new MESApiService();
|
|
6196
|
+
const parameters = [
|
|
6197
|
+
{ name: "ShiftId", value: shiftId !== null && shiftId !== void 0 ? shiftId : null },
|
|
6198
|
+
{ name: "AssetId", value: assetId !== null && assetId !== void 0 ? assetId : null },
|
|
6199
|
+
];
|
|
6200
|
+
if (shiftsBefore !== undefined) {
|
|
6201
|
+
parameters.push({ name: "ShiftsBefore", value: shiftsBefore });
|
|
6202
|
+
}
|
|
6203
|
+
if (shiftsAfter !== undefined) {
|
|
6204
|
+
parameters.push({ name: "ShiftsAfter", value: shiftsAfter });
|
|
6205
|
+
}
|
|
6206
|
+
const resp = yield apiService.callV2("[MES].[GetShiftsByRange]", parameters);
|
|
6207
|
+
if (resp.ok) {
|
|
6208
|
+
let rows = get(resp, "data.tables[0].rows", []);
|
|
6209
|
+
rows = rows.map((row) => (Object.assign(Object.assign({}, row), { Start: moment$e.utc(row.Start).toDate(), End: moment$e.utc(row.End).toDate() })));
|
|
6210
|
+
return rows;
|
|
6211
|
+
}
|
|
6212
|
+
else {
|
|
6213
|
+
throw new Error(resp.message || "Error fetching shifts by range");
|
|
6214
|
+
}
|
|
6215
|
+
});
|
|
6216
|
+
const getShiftsAroundCurrent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ currentShiftId, shiftsRange, }) {
|
|
6217
|
+
const apiService = new MESApiService();
|
|
6218
|
+
const parameters = [
|
|
6219
|
+
{ name: "CurrentShiftId", value: currentShiftId || null },
|
|
6220
|
+
];
|
|
6221
|
+
if (shiftsRange) {
|
|
6222
|
+
parameters.push({ name: "ShiftsRange", value: shiftsRange });
|
|
6223
|
+
}
|
|
6224
|
+
const resp = yield apiService.callV2("[MES].[GetShiftsAroundCurrent]", parameters);
|
|
6225
|
+
if (resp.ok) {
|
|
6226
|
+
let rows = get(resp, "data.tables[0].rows", []);
|
|
6227
|
+
rows = rows.map((row) => (Object.assign(Object.assign({}, row), { Start: moment$e.utc(row.Start).toDate(), End: moment$e.utc(row.End).toDate() })));
|
|
6228
|
+
return rows;
|
|
6229
|
+
}
|
|
6230
|
+
else {
|
|
6231
|
+
throw new Error(resp.message || "Error fetching shifts");
|
|
6232
|
+
}
|
|
6233
|
+
});
|
|
6234
|
+
|
|
6235
|
+
const moment$d = getMomentTz();
|
|
6236
|
+
const useShiftsAroundCurrent = ({ currentShiftId, shiftsRange, enabled = true, }) => {
|
|
6237
|
+
return useQuery({
|
|
6238
|
+
queryKey: ["shiftsAroundCurrent", currentShiftId, shiftsRange],
|
|
6239
|
+
queryFn: ({ signal }) => getShiftsAroundCurrent({ currentShiftId, shiftsRange }),
|
|
6240
|
+
enabled,
|
|
6241
|
+
});
|
|
6242
|
+
};
|
|
6243
|
+
const useShiftsByRange = ({ shiftId, assetId, shiftsBefore, shiftsAfter, enabled = true, }) => {
|
|
6244
|
+
return useQuery({
|
|
6245
|
+
queryKey: ["shiftsByRange", shiftId, assetId, shiftsBefore, shiftsAfter],
|
|
6246
|
+
queryFn: () => getShiftsByRange({ shiftId, assetId, shiftsBefore, shiftsAfter }),
|
|
6247
|
+
enabled,
|
|
6248
|
+
});
|
|
6249
|
+
};
|
|
6250
|
+
const ShiftAutocomplete = ({ currentShiftId, value, onShiftSelected, disabled, shiftsRange, assetId, shiftsAfter, }) => {
|
|
6251
|
+
const [error, setError] = useState("");
|
|
6252
|
+
const useNewPath = assetId !== undefined;
|
|
6253
|
+
// Legacy path (existing consumers)
|
|
6254
|
+
const { data: legacyRows, isLoading: legacyLoading, error: legacyError, isError: legacyIsError, } = useShiftsAroundCurrent({
|
|
6255
|
+
currentShiftId,
|
|
6256
|
+
shiftsRange,
|
|
6257
|
+
enabled: !useNewPath,
|
|
6258
|
+
});
|
|
6259
|
+
// New path (asset-filtered, count-based)
|
|
6260
|
+
const { data: rangeRows, isLoading: rangeLoading, error: rangeError, isError: rangeIsError, } = useShiftsByRange({
|
|
6261
|
+
shiftId: currentShiftId,
|
|
6262
|
+
assetId,
|
|
6263
|
+
shiftsBefore: shiftsRange !== null && shiftsRange !== void 0 ? shiftsRange : 10,
|
|
6264
|
+
shiftsAfter: shiftsAfter !== null && shiftsAfter !== void 0 ? shiftsAfter : 0,
|
|
6265
|
+
enabled: useNewPath,
|
|
6266
|
+
});
|
|
6267
|
+
// Unified variables
|
|
6268
|
+
const rows = useNewPath ? rangeRows : legacyRows;
|
|
6269
|
+
const isLoading = useNewPath ? rangeLoading : legacyLoading;
|
|
6270
|
+
const e = useNewPath ? rangeError : legacyError;
|
|
6271
|
+
const isError = useNewPath ? rangeIsError : legacyIsError;
|
|
6272
|
+
const selectedShift = (rows === null || rows === void 0 ? void 0 : rows.find((type) => type.ShiftId === value)) || null;
|
|
6273
|
+
useEffect(() => {
|
|
6274
|
+
if (e && isError) {
|
|
6275
|
+
setError(e.message);
|
|
6276
|
+
}
|
|
6277
|
+
}, [e, isError]);
|
|
6278
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
6279
|
+
React__default.createElement(Grid2, { container: true },
|
|
6280
|
+
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
6281
|
+
React__default.createElement(Autocomplete, { loading: isLoading, options: rows || [], getOptionLabel: (option) => {
|
|
6282
|
+
return `${moment$d
|
|
6283
|
+
.utc(option.ProductionDate)
|
|
6284
|
+
.format("MM/DD/YYYY")} - ${option.Shift} - ${option.Crew}`;
|
|
6285
|
+
}, value: selectedShift, onChange: (event, newValue) => {
|
|
6286
|
+
if (newValue) {
|
|
6287
|
+
onShiftSelected(newValue);
|
|
6288
|
+
}
|
|
6289
|
+
}, disabled: disabled, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: "Shift", variant: "outlined", size: "small", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null, isLoading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 20 })) : null)) }) }))) }))),
|
|
6290
|
+
React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
|
|
6291
|
+
};
|
|
6292
|
+
|
|
6293
|
+
const useShifts = (shiftId) => {
|
|
6294
|
+
return useQuery({
|
|
6295
|
+
queryKey: ["shifts", shiftId],
|
|
6296
|
+
queryFn: ({ signal }) => getShifts({ shiftId }, signal),
|
|
6297
|
+
});
|
|
6298
|
+
};
|
|
6299
|
+
const ShiftSelector = ({ label = "Shift - Crew", value, onChange = () => { }, fieldError, disabled = false, }) => {
|
|
6300
|
+
const [error, setError] = useState("");
|
|
6301
|
+
const { data: shifts, isLoading, isError, error: e } = useShifts(value);
|
|
6302
|
+
const selectedShift = (shifts === null || shifts === void 0 ? void 0 : shifts.find((s) => s.CurrentShiftId === value)) || null;
|
|
6303
|
+
useEffect(() => {
|
|
6304
|
+
if (isError) {
|
|
6305
|
+
setError(e.message);
|
|
6306
|
+
}
|
|
6307
|
+
}, [isError, e]);
|
|
6308
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
6309
|
+
React__default.createElement(Autocomplete, { id: "clear-on-escape", clearOnEscape: true, options: shifts || [], getOptionLabel: (option) => `${option.CurrentShift} - ${option.CurrentCrew}`, disabled: disabled, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: label, variant: "outlined", fullWidth: true, size: "small", error: !!fieldError, helperText: fieldError === null || fieldError === void 0 ? void 0 : fieldError.message, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null, isLoading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 20 })) : (React__default.createElement(React__default.Fragment, null, params.InputProps.endAdornment)))) }) }))), value: selectedShift, onChange: (event, newValue) => {
|
|
6310
|
+
var _a;
|
|
6311
|
+
onChange((_a = newValue === null || newValue === void 0 ? void 0 : newValue.CurrentShiftId) !== null && _a !== void 0 ? _a : null);
|
|
6312
|
+
} }),
|
|
6313
|
+
React__default.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error loading shifts" })));
|
|
6314
|
+
};
|
|
6315
|
+
|
|
6145
6316
|
function ChangePassword(props) {
|
|
6146
6317
|
const { onClose, userId, open } = props;
|
|
6147
6318
|
//states
|
|
@@ -7739,14 +7910,14 @@ const TagFilter = ({ tagFilters, setTagFilters, filterContext, }) => {
|
|
|
7739
7910
|
} },
|
|
7740
7911
|
React__default.createElement(Typography$1, { variant: "subtitle2" }, selectedTag ? "Edit Tag Filter" : "Add Tag Filter"),
|
|
7741
7912
|
React__default.createElement(FormControlLabel, { control: React__default.createElement(Checkbox, { size: "small", checked: showOnlyWithData, onChange: (e) => setShowOnlyWithData(e.target.checked) }), label: React__default.createElement(Typography$1, { variant: "caption" }, "Only with data"), sx: { mr: 0 } })),
|
|
7742
|
-
React__default.createElement(Autocomplete, { size: "small", options: availableTagsForSelection, getOptionLabel: (option) => option.TagName, value: selectedTag, onChange: (_, newValue) => {
|
|
7913
|
+
React__default.createElement(Autocomplete$1, { size: "small", options: availableTagsForSelection, getOptionLabel: (option) => option.TagName, value: selectedTag, onChange: (_, newValue) => {
|
|
7743
7914
|
setSelectedTag(newValue);
|
|
7744
7915
|
setSelectedValues([]);
|
|
7745
7916
|
}, renderOption: (props, option) => (React__default.createElement("li", Object.assign({}, props, { style: {
|
|
7746
7917
|
opacity: option.HasData ? 1 : 0.8,
|
|
7747
7918
|
} }), option.TagName)), renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: "Tag Name", variant: "outlined" }))) }),
|
|
7748
7919
|
selectedTag && (React__default.createElement(React__default.Fragment, null, isLoadingValues ? (React__default.createElement(Box, { sx: { display: "flex", justifyContent: "center", py: 2 } },
|
|
7749
|
-
React__default.createElement(CircularProgress, { size: 24 }))) : (React__default.createElement(Autocomplete, { multiple: true, size: "small", options: availableTagValues, getOptionLabel: (option) => option.Value, value: selectedValues, onChange: (_, newValue) => setSelectedValues(newValue), isOptionEqualToValue: (option, value) => option.Value === value.Value, disableCloseOnSelect: true, renderOption: (props, option, { selected }) => (React__default.createElement("li", Object.assign({}, props, { style: {
|
|
7920
|
+
React__default.createElement(CircularProgress, { size: 24 }))) : (React__default.createElement(Autocomplete$1, { multiple: true, size: "small", options: availableTagValues, getOptionLabel: (option) => option.Value, value: selectedValues, onChange: (_, newValue) => setSelectedValues(newValue), isOptionEqualToValue: (option, value) => option.Value === value.Value, disableCloseOnSelect: true, renderOption: (props, option, { selected }) => (React__default.createElement("li", Object.assign({}, props, { style: {
|
|
7750
7921
|
opacity: option.HasData ? 1 : 0.8,
|
|
7751
7922
|
} }),
|
|
7752
7923
|
React__default.createElement(Checkbox, { icon: icon, checkedIcon: checkedIcon, style: { marginRight: 8 }, checked: selected, size: "small" }),
|
|
@@ -8233,259 +8404,249 @@ const ProfilesPage = (props) => {
|
|
|
8233
8404
|
return React.createElement(Profiles, null);
|
|
8234
8405
|
};
|
|
8235
8406
|
|
|
8236
|
-
const
|
|
8237
|
-
const
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
{
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8407
|
+
const useSettingsOptionsFunctions = ({ setSettingId, setShowDeleteModal, setShowCreateModal, setShowEditModal, }) => {
|
|
8408
|
+
const getMenuOptions = (data) => {
|
|
8409
|
+
let options = [];
|
|
8410
|
+
if (!data) {
|
|
8411
|
+
options = options.concat([
|
|
8412
|
+
{
|
|
8413
|
+
name: "New Setting",
|
|
8414
|
+
key: "new_setting",
|
|
8415
|
+
onClick: () => {
|
|
8416
|
+
setShowCreateModal(true);
|
|
8417
|
+
},
|
|
8418
|
+
icon: React__default.createElement(PlaylistAddIcon, null),
|
|
8419
|
+
},
|
|
8420
|
+
]);
|
|
8421
|
+
}
|
|
8422
|
+
else {
|
|
8423
|
+
options = options.concat([
|
|
8424
|
+
{
|
|
8425
|
+
name: "New Setting",
|
|
8426
|
+
key: "new_setting",
|
|
8427
|
+
onClick: () => {
|
|
8428
|
+
setShowCreateModal(true);
|
|
8429
|
+
},
|
|
8430
|
+
icon: React__default.createElement(PlaylistAddIcon, null),
|
|
8431
|
+
},
|
|
8432
|
+
{
|
|
8433
|
+
name: "Edit Setting",
|
|
8434
|
+
key: "edit_setting",
|
|
8435
|
+
onClick: () => {
|
|
8436
|
+
setSettingId(data);
|
|
8437
|
+
setShowEditModal(true);
|
|
8438
|
+
},
|
|
8439
|
+
icon: React__default.createElement(EditIcon, null),
|
|
8440
|
+
},
|
|
8441
|
+
{
|
|
8442
|
+
name: "Delete Setting",
|
|
8443
|
+
key: "delete_setting",
|
|
8444
|
+
onClick: () => {
|
|
8445
|
+
setSettingId(data);
|
|
8446
|
+
setShowDeleteModal(true);
|
|
8447
|
+
},
|
|
8448
|
+
icon: React__default.createElement(DeleteIcon, null),
|
|
8449
|
+
},
|
|
8450
|
+
]);
|
|
8451
|
+
}
|
|
8452
|
+
return options;
|
|
8453
|
+
};
|
|
8454
|
+
return {
|
|
8455
|
+
getMenuOptions,
|
|
8456
|
+
};
|
|
8284
8457
|
};
|
|
8285
8458
|
|
|
8286
|
-
const
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
defaultValues: shiftSelected ? shiftSelected : INITIAL_VALUES$1,
|
|
8294
|
-
});
|
|
8295
|
-
// Progress bar
|
|
8296
|
-
const calculatePercentage = () => ((crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) / maxCrewRotationLength) * 100;
|
|
8297
|
-
const createShift = useMutation({
|
|
8298
|
-
mutationFn: upsertShiftParameters,
|
|
8299
|
-
onSuccess: () => {
|
|
8300
|
-
setOpen(true);
|
|
8301
|
-
onHide(true);
|
|
8459
|
+
const useTableData$5 = ({ setOpenModalEditSetting, setOpenModalDeleteSetting, showContextMenu, setSettingSelected, }) => {
|
|
8460
|
+
const columnDefs = [
|
|
8461
|
+
{
|
|
8462
|
+
field: "SettingName",
|
|
8463
|
+
headerName: "Name",
|
|
8464
|
+
minWidth: 180,
|
|
8465
|
+
flex: 4,
|
|
8302
8466
|
},
|
|
8303
|
-
|
|
8304
|
-
|
|
8467
|
+
{
|
|
8468
|
+
field: "Value",
|
|
8469
|
+
headerName: "Value",
|
|
8470
|
+
minWidth: 180,
|
|
8471
|
+
flex: 2,
|
|
8305
8472
|
},
|
|
8306
|
-
|
|
8307
|
-
|
|
8473
|
+
{
|
|
8474
|
+
field: "Description",
|
|
8475
|
+
headerName: "Description",
|
|
8476
|
+
minWidth: 150,
|
|
8477
|
+
flex: 4,
|
|
8308
8478
|
},
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8479
|
+
{
|
|
8480
|
+
cellRenderer: (params) => {
|
|
8481
|
+
return (React__default.createElement(Grid2, { container: true, sx: {
|
|
8482
|
+
height: "100%",
|
|
8483
|
+
display: "flex",
|
|
8484
|
+
justifyContent: "center",
|
|
8485
|
+
alignItems: "center",
|
|
8486
|
+
opacity: 0,
|
|
8487
|
+
transition: "opacity 0.1s ease-in-out",
|
|
8488
|
+
".ag-row-hover &": {
|
|
8489
|
+
opacity: 1,
|
|
8490
|
+
},
|
|
8491
|
+
".ag-row-focus &": {
|
|
8492
|
+
opacity: 1,
|
|
8493
|
+
},
|
|
8494
|
+
".ag-row-selected &": {
|
|
8495
|
+
opacity: 1,
|
|
8496
|
+
},
|
|
8497
|
+
} },
|
|
8498
|
+
React__default.createElement(Grid2, { size: { xs: 12, md: 12 }, style: {
|
|
8499
|
+
display: "flex",
|
|
8500
|
+
justifyContent: "space-evenly",
|
|
8501
|
+
alignItems: "center",
|
|
8502
|
+
} },
|
|
8503
|
+
React__default.createElement(IconButton$1, { size: "small", onClick: () => {
|
|
8504
|
+
setSettingSelected(params === null || params === void 0 ? void 0 : params.data);
|
|
8505
|
+
setOpenModalEditSetting(true);
|
|
8506
|
+
} },
|
|
8507
|
+
React__default.createElement(EditIcon, { color: "primary" })),
|
|
8508
|
+
React__default.createElement(IconButton$1, { size: "small", onClick: () => {
|
|
8509
|
+
setSettingSelected(params === null || params === void 0 ? void 0 : params.data);
|
|
8510
|
+
setOpenModalDeleteSetting(true);
|
|
8511
|
+
} },
|
|
8512
|
+
React__default.createElement(DeleteIcon, { color: "secondary" })),
|
|
8513
|
+
React__default.createElement(IconButton$1, { size: "small", onClick: (e) => showContextMenu(e, params.data, "TableSettings") },
|
|
8514
|
+
React__default.createElement(FormatListBulletedSharpIcon, { color: "action" })))));
|
|
8515
|
+
},
|
|
8516
|
+
field: "",
|
|
8517
|
+
flex: 1,
|
|
8518
|
+
minWidth: 240,
|
|
8519
|
+
editable: false,
|
|
8520
|
+
autoHeight: false,
|
|
8521
|
+
suppressNavigable: true,
|
|
8522
|
+
},
|
|
8523
|
+
];
|
|
8524
|
+
const defaultColDef = useMemo(() => {
|
|
8525
|
+
return {
|
|
8526
|
+
sortable: true,
|
|
8527
|
+
wrapText: true,
|
|
8528
|
+
autoHeight: true,
|
|
8529
|
+
wrapHeaderText: true,
|
|
8530
|
+
suppressHeaderMenuButton: true,
|
|
8531
|
+
cellStyle: {
|
|
8532
|
+
display: "flex",
|
|
8533
|
+
alignItems: "center",
|
|
8534
|
+
justifyContent: "center",
|
|
8535
|
+
},
|
|
8536
|
+
};
|
|
8537
|
+
}, []);
|
|
8538
|
+
return { columnDefs, defaultColDef };
|
|
8539
|
+
};
|
|
8540
|
+
|
|
8541
|
+
const INITIAL_VALUES$1 = {
|
|
8542
|
+
SettingName: "",
|
|
8543
|
+
Value: "",
|
|
8544
|
+
Description: "",
|
|
8545
|
+
};
|
|
8546
|
+
|
|
8547
|
+
const upsertSettings = (_a) => __awaiter(void 0, [_a], void 0, function* ({ oldName, newName, description, value, }) {
|
|
8548
|
+
const apiService = new MESApiService();
|
|
8549
|
+
const parameters = [
|
|
8550
|
+
{ name: "OldName", value: oldName },
|
|
8551
|
+
{ name: "NewName", value: newName },
|
|
8552
|
+
{ name: "Description", value: description },
|
|
8553
|
+
{ name: "Value", value: value },
|
|
8554
|
+
];
|
|
8555
|
+
const resp = yield apiService.callV2("[UTL].[SetSetting]", parameters);
|
|
8556
|
+
if (!resp.ok) {
|
|
8557
|
+
throw new Error(resp.message || "Error when upsert setting");
|
|
8558
|
+
}
|
|
8559
|
+
});
|
|
8560
|
+
const deleteSetting = (settingName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8561
|
+
const apiService = new MESApiService();
|
|
8562
|
+
const parameters = [
|
|
8563
|
+
{ name: "SettingName", value: settingName },
|
|
8564
|
+
];
|
|
8565
|
+
const resp = yield apiService.callV2("[UTL].[DeleteSetting]", parameters);
|
|
8566
|
+
if (!resp.ok) {
|
|
8567
|
+
throw new Error(resp.message || "Error when delete setting");
|
|
8568
|
+
}
|
|
8569
|
+
});
|
|
8570
|
+
|
|
8571
|
+
const CreateSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
|
|
8572
|
+
const [open, setOpen] = useState(false);
|
|
8573
|
+
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
8574
|
+
const [error, setError] = useState("");
|
|
8575
|
+
const { control, handleSubmit, reset } = useForm({
|
|
8576
|
+
defaultValues: settingSelected ? settingSelected : INITIAL_VALUES$1,
|
|
8577
|
+
});
|
|
8578
|
+
const updateSetting = useMutation({
|
|
8579
|
+
mutationFn: upsertSettings,
|
|
8580
|
+
onSuccess: () => {
|
|
8581
|
+
setOpen(true);
|
|
8582
|
+
onHide(true);
|
|
8583
|
+
},
|
|
8584
|
+
onError: (error) => {
|
|
8585
|
+
setError(error.message);
|
|
8586
|
+
},
|
|
8587
|
+
onSettled: () => {
|
|
8588
|
+
setIsSubmitLoading(false);
|
|
8589
|
+
},
|
|
8590
|
+
});
|
|
8591
|
+
const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8592
|
+
setIsSubmitLoading(true);
|
|
8593
|
+
yield updateSetting.mutate({
|
|
8594
|
+
oldName: "",
|
|
8595
|
+
newName: data.SettingName,
|
|
8596
|
+
description: data.Description,
|
|
8597
|
+
value: data.Value,
|
|
8598
|
+
});
|
|
8599
|
+
});
|
|
8600
|
+
const handleClose = (event, reason) => {
|
|
8601
|
+
if (reason === "clickaway") {
|
|
8602
|
+
return;
|
|
8603
|
+
}
|
|
8604
|
+
setOpen(false);
|
|
8319
8605
|
};
|
|
8320
|
-
// const patternStart = watch('PatternStart');
|
|
8321
|
-
const shiftsPerDay = watch("ShiftsPerDay");
|
|
8322
|
-
const shiftCodes = watch("ShiftCodes");
|
|
8323
|
-
const numberOfCrews = watch("NumberOfCrews");
|
|
8324
|
-
const crewsCodes = watch("Crews");
|
|
8325
|
-
const rotationPattern = watch("PatternDays");
|
|
8326
|
-
const crewRotation = watch("CrewRotation");
|
|
8327
|
-
const comments = watch("Comments");
|
|
8328
|
-
const maxCrewRotationLength = shiftsPerDay * rotationPattern;
|
|
8329
8606
|
useEffect(() => {
|
|
8330
8607
|
if (show) {
|
|
8331
8608
|
reset();
|
|
8332
|
-
setValue("PatternStart", new Date());
|
|
8333
8609
|
}
|
|
8334
8610
|
}, [show]);
|
|
8335
8611
|
return (React.createElement(React.Fragment, null,
|
|
8336
|
-
show && (React.createElement(HelmetDexteel, { title: `New
|
|
8337
|
-
React.createElement(
|
|
8338
|
-
React.createElement(
|
|
8339
|
-
React.createElement(MesfModal
|
|
8340
|
-
React.createElement(
|
|
8341
|
-
React.createElement(
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
|
|
8362
|
-
min: 1,
|
|
8363
|
-
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${shiftsPerDay > 1 ? "Shifts" : "Shift"} per day`, variant: "outlined", error: !!errors.ShiftsPerDay, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: value, onChange: (evt) => parseInt(evt.target.value) >= 1 &&
|
|
8364
|
-
parseInt(evt.target.value) <= 10 &&
|
|
8365
|
-
onChange(evt) })) }),
|
|
8366
|
-
((_a = errors.ShiftsPerDay) === null || _a === void 0 ? void 0 : _a.type) === "min" && (React.createElement(ErrorLabel, { text: "Shift per day is required" }))),
|
|
8367
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8368
|
-
React.createElement(Controller, { name: "ShiftCodes", control: control, rules: {
|
|
8369
|
-
validate: (value) => value.length == shiftsPerDay,
|
|
8370
|
-
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: "Shifts Ids", variant: "outlined", error: !!errors.ShiftCodes, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
8371
|
-
// TODO: aquí podriamos hacer que no pueda haber dos valores iguales, para prevenir errores. Ej. dos DNN
|
|
8372
|
-
if (evt.target.value.length <= shiftsPerDay)
|
|
8373
|
-
onChange(evt.target.value.toString().toUpperCase());
|
|
8374
|
-
} })) }),
|
|
8375
|
-
!!errors.ShiftCodes && (React.createElement("span", { style: {
|
|
8376
|
-
fontSize: 12,
|
|
8377
|
-
} },
|
|
8378
|
-
"Please put ",
|
|
8379
|
-
shiftsPerDay,
|
|
8380
|
-
" shifts")),
|
|
8381
|
-
shiftCodes.length < shiftsPerDay &&
|
|
8382
|
-
!!errors.ShiftCodes === false && (React.createElement("span", { style: {
|
|
8383
|
-
fontSize: 12,
|
|
8384
|
-
color: theme.palette.info.main,
|
|
8385
|
-
} }, `Insert: ${shiftsPerDay} ${shiftsPerDay == 1 ? "Id" : "Ids"}. ${shiftsPerDay > 1 ? "The Ids must be differents" : ""}`))),
|
|
8386
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8387
|
-
React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
|
|
8388
|
-
min: 1,
|
|
8389
|
-
max: 9,
|
|
8390
|
-
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${numberOfCrews > 1 ? "Crews" : "Crew"}`, variant: "outlined", error: !!errors.NumberOfCrews, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", onChange: (evt) => {
|
|
8391
|
-
// max. crew 15
|
|
8392
|
-
if (parseInt(evt.target.value) >= 1 &&
|
|
8393
|
-
parseInt(evt.target.value) <= 15)
|
|
8394
|
-
onChange(evt);
|
|
8395
|
-
}, value: value })) }),
|
|
8396
|
-
((_b = errors.NumberOfCrews) === null || _b === void 0 ? void 0 : _b.type) === "min" && (React.createElement(ErrorLabel, { text: "# Crews days is required" }))),
|
|
8397
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8398
|
-
React.createElement(Controller, { name: "Crews", control: control, rules: {
|
|
8399
|
-
validate: (value) => value.length == numberOfCrews,
|
|
8400
|
-
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: "Crews Ids", variant: "outlined", error: !!errors.Crews, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
8401
|
-
if (evt.target.value.length <= numberOfCrews)
|
|
8402
|
-
onChange(evt.target.value.toString().toUpperCase());
|
|
8403
|
-
} })) }),
|
|
8404
|
-
!!errors.Crews && (React.createElement("span", { style: {
|
|
8405
|
-
fontSize: 12,
|
|
8406
|
-
} },
|
|
8407
|
-
"Please put ",
|
|
8408
|
-
numberOfCrews,
|
|
8409
|
-
" crews")),
|
|
8410
|
-
crewsCodes.length < numberOfCrews &&
|
|
8411
|
-
!!errors.Crews === false && (React.createElement("span", { style: {
|
|
8412
|
-
fontSize: 12,
|
|
8413
|
-
color: theme.palette.info.main,
|
|
8414
|
-
} }, `Insert: ${numberOfCrews} ${numberOfCrews == 1 ? "Crew" : "Crews"}. ${numberOfCrews > 1 ? "The Crews must be differents" : ""}`))),
|
|
8415
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8416
|
-
React.createElement(Controller, { name: "PatternDays", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { label: "Rotation Pattern", variant: "outlined", error: !!errors.PatternDays, fullWidth: true, type: "number", margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
8417
|
-
if (parseInt(evt.target.value) >= 5 &&
|
|
8418
|
-
parseInt(evt.target.value) <= 60)
|
|
8419
|
-
onChange(evt);
|
|
8420
|
-
} })) })),
|
|
8421
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8422
|
-
React.createElement(Controller, { name: "CrewRotation", control: control, rules: {
|
|
8423
|
-
validate: (value) => value.length == maxCrewRotationLength,
|
|
8424
|
-
}, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { value: value, onChange: (evt) => {
|
|
8425
|
-
if (evt.target.value.length <= maxCrewRotationLength)
|
|
8426
|
-
onChange(evt.target.value.toString().toUpperCase());
|
|
8427
|
-
}, label: "Crew rotation", variant: "outlined", fullWidth: true, error: !!errors.CrewRotation, margin: "dense", autoComplete: "off" })) }),
|
|
8428
|
-
React.createElement(Grid2, { container: true, height: 2 },
|
|
8429
|
-
React.createElement(Grid2, { style: {
|
|
8430
|
-
height: 2,
|
|
8431
|
-
width: `${calculatePercentage()}% `,
|
|
8432
|
-
backgroundColor: `${crewRotation.length == maxCrewRotationLength
|
|
8433
|
-
? "#4CAF50"
|
|
8434
|
-
: "#F44336"}`,
|
|
8435
|
-
transition: " 0.2s ease",
|
|
8436
|
-
margin: "0 5px",
|
|
8437
|
-
} })),
|
|
8438
|
-
React.createElement(Grid2, { container: true, style: { margin: "4px 0 0" } },
|
|
8439
|
-
React.createElement(Grid2, null, (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) >= 1 &&
|
|
8440
|
-
(crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) !==
|
|
8441
|
-
maxCrewRotationLength && (React.createElement("span", { style: {
|
|
8442
|
-
fontSize: 12,
|
|
8443
|
-
color: theme.palette.info.main,
|
|
8444
|
-
marginLeft: 5,
|
|
8445
|
-
} }, `${crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length}/${maxCrewRotationLength}`)))),
|
|
8446
|
-
!!errors.CrewRotation && (React.createElement(ErrorLabel, { text: `Please put ${maxCrewRotationLength} crews` })),
|
|
8447
|
-
numberOfCrews > 0 &&
|
|
8448
|
-
Number.isInteger(maxCrewRotationLength / numberOfCrews) ===
|
|
8449
|
-
false && (React.createElement(Grid2, { container: true, style: { padding: "0", marginLeft: 5 } },
|
|
8450
|
-
React.createElement(ErrorLabel, { text: `Rotation # not a multiple of Shifts (${maxCrewRotationLength}) / Crews (${numberOfCrews})` })))),
|
|
8451
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8452
|
-
React.createElement(Controller, { name: "Comments", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { style: { margin: "8px 0" }, size: "medium", maxRows: 5, label: "Comments", multiline: true, variant: "outlined", fullWidth: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
8453
|
-
if (evt.target.value.length <= 200)
|
|
8454
|
-
onChange(evt);
|
|
8455
|
-
} })) }),
|
|
8456
|
-
React.createElement(Grid2, { container: true, style: { marginBottom: 18 } },
|
|
8457
|
-
React.createElement(Grid2, null,
|
|
8458
|
-
(comments === null || comments === void 0 ? void 0 : comments.length) >= 1 &&
|
|
8459
|
-
(comments === null || comments === void 0 ? void 0 : comments.length) !== 200 && (React.createElement("span", { style: {
|
|
8460
|
-
fontSize: 12,
|
|
8461
|
-
color: theme.palette.info.main,
|
|
8462
|
-
marginLeft: 5,
|
|
8463
|
-
} }, `${comments === null || comments === void 0 ? void 0 : comments.length}/200 max.`)),
|
|
8464
|
-
(comments === null || comments === void 0 ? void 0 : comments.length) == 200 && (React.createElement("span", { style: {
|
|
8465
|
-
fontSize: 12,
|
|
8466
|
-
color: theme.palette.info.main,
|
|
8467
|
-
marginLeft: 5,
|
|
8468
|
-
} }, "Max. 200"))))))),
|
|
8469
|
-
React.createElement(MesfModal.Actions, null,
|
|
8470
|
-
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
8471
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8472
|
-
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
8473
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8474
|
-
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))),
|
|
8475
|
-
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error Creating Shift" }),
|
|
8612
|
+
show && (React.createElement(HelmetDexteel, { title: `New Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
8613
|
+
React.createElement(Grid2, { container: true },
|
|
8614
|
+
React.createElement(Grid2, null,
|
|
8615
|
+
React.createElement(MesfModal, { title: "NEW SETTING", open: show, handleClose: () => onHide(false), id: "create-setting-modal", maxWidth: "md" },
|
|
8616
|
+
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
8617
|
+
React.createElement(MesfModal.Content, null,
|
|
8618
|
+
React.createElement(Grid2, { container: true, spacing: 2 },
|
|
8619
|
+
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
8620
|
+
React.createElement(Controller, { name: "SettingName", control: control, rules: { required: "Name is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Name", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
8621
|
+
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
8622
|
+
React.createElement(Controller, { name: "Value", control: control, rules: {
|
|
8623
|
+
required: "Value is required",
|
|
8624
|
+
}, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Value", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
8625
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8626
|
+
React.createElement(Controller, { name: "Description", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { size: "medium", maxRows: 5, label: "Description", multiline: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
8627
|
+
if (evt.target.value.length <= 200)
|
|
8628
|
+
onChange(evt);
|
|
8629
|
+
} })) })))),
|
|
8630
|
+
React.createElement(MesfModal.Actions, null,
|
|
8631
|
+
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
8632
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8633
|
+
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
8634
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8635
|
+
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))))),
|
|
8636
|
+
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error Creating Setting" }),
|
|
8476
8637
|
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
8477
|
-
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The
|
|
8638
|
+
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was created successfully"))));
|
|
8478
8639
|
};
|
|
8479
8640
|
|
|
8480
|
-
const
|
|
8481
|
-
var _a;
|
|
8641
|
+
const DeleteSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
|
|
8482
8642
|
const [open, setOpen] = useState(false);
|
|
8483
8643
|
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
8484
|
-
const [deleteAlert, setDeleteAlert] = useState(false);
|
|
8485
8644
|
const [error, setError] = useState("");
|
|
8486
|
-
const { control,
|
|
8487
|
-
|
|
8488
|
-
|
|
8645
|
+
const { control, handleSubmit, reset, setValue } = useForm({
|
|
8646
|
+
defaultValues: settingSelected ? settingSelected : INITIAL_VALUES$1,
|
|
8647
|
+
});
|
|
8648
|
+
const removeSetting = useMutation({
|
|
8649
|
+
mutationFn: deleteSetting,
|
|
8489
8650
|
onSuccess: () => {
|
|
8490
8651
|
setOpen(true);
|
|
8491
8652
|
onHide(true);
|
|
@@ -8495,122 +8656,65 @@ const DeleteShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
|
|
|
8495
8656
|
},
|
|
8496
8657
|
onSettled: () => {
|
|
8497
8658
|
setIsSubmitLoading(false);
|
|
8498
|
-
setDeleteAlert(false);
|
|
8499
8659
|
},
|
|
8500
8660
|
});
|
|
8501
|
-
const
|
|
8661
|
+
const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8502
8662
|
setIsSubmitLoading(true);
|
|
8503
|
-
yield
|
|
8663
|
+
yield removeSetting.mutate(data.SettingName);
|
|
8504
8664
|
});
|
|
8505
8665
|
const handleClose = (event, reason) => {
|
|
8506
8666
|
if (reason === "clickaway") {
|
|
8507
8667
|
return;
|
|
8508
8668
|
}
|
|
8509
8669
|
setOpen(false);
|
|
8510
|
-
setDeleteAlert(false);
|
|
8511
8670
|
};
|
|
8512
|
-
const patternStart = watch("PatternStart");
|
|
8513
|
-
const shiftsPerDay = watch("ShiftsPerDay");
|
|
8514
|
-
const crewRotation = watch("CrewRotation");
|
|
8515
|
-
const numberOfCrews = watch("NumberOfCrews");
|
|
8516
|
-
const crewsCodes = watch("Crews");
|
|
8517
|
-
const rotationPattern = watch("PatternDays");
|
|
8518
8671
|
useEffect(() => {
|
|
8519
|
-
var _a, _b, _c, _d, _e, _f;
|
|
8520
8672
|
if (show) {
|
|
8521
8673
|
reset();
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
|
|
8674
|
+
if (settingSelected) {
|
|
8675
|
+
setValue("SettingName", settingSelected.SettingName);
|
|
8676
|
+
setValue("Value", settingSelected.Value);
|
|
8677
|
+
setValue("Description", settingSelected.Description);
|
|
8678
|
+
}
|
|
8528
8679
|
}
|
|
8529
8680
|
}, [show]);
|
|
8530
8681
|
return (React.createElement(React.Fragment, null,
|
|
8531
|
-
show && (React.createElement(HelmetDexteel, { title: `Delete
|
|
8532
|
-
React.createElement(
|
|
8533
|
-
React.createElement(
|
|
8534
|
-
React.createElement(MesfModal
|
|
8535
|
-
React.createElement(
|
|
8536
|
-
React.createElement(
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
React.createElement(Grid2, { size: { md:
|
|
8550
|
-
React.createElement(
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
disabled: true,
|
|
8555
|
-
},
|
|
8556
|
-
} })))) }),
|
|
8557
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8558
|
-
React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
|
|
8559
|
-
min: 1,
|
|
8560
|
-
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${shiftsPerDay > 1 ? "Shifts" : "Shift"} per day`, variant: "outlined", error: !!errors.ShiftsPerDay, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: crewRotation.length / rotationPattern, disabled: !!shiftSelected })) }),
|
|
8561
|
-
((_a = errors.ShiftsPerDay) === null || _a === void 0 ? void 0 : _a.type) === "min" && (React.createElement(ErrorLabel, { text: "Shift per day is required" }))),
|
|
8562
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 }, style: { paddingBottom: "0" } },
|
|
8563
|
-
React.createElement(Controller, { name: "ShiftCodes", control: control, render: ({ field: { value } }) => (React.createElement(TextField, { label: "Shifts Ids", variant: "outlined", error: !!errors.ShiftCodes, fullWidth: true, margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
8564
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8565
|
-
React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
|
|
8566
|
-
min: 1,
|
|
8567
|
-
max: 9,
|
|
8568
|
-
}, render: ({ field: { value } }) => (React.createElement(TextField, { label: `# ${numberOfCrews > 1 ? "Crews" : "Crew"}`, variant: "outlined", error: !!errors.NumberOfCrews, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: crewsCodes.length, disabled: !!shiftSelected })) })),
|
|
8569
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 }, style: { paddingBottom: "0" } },
|
|
8570
|
-
React.createElement(Controller, { name: "Crews", control: control, render: ({ field: { value } }) => (React.createElement(TextField, { label: "Crews Ids", variant: "outlined", error: !!errors.Crews, fullWidth: true, margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
8571
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8572
|
-
React.createElement(Controller, { name: "PatternDays", control: control, render: ({ field: { value } }) => (React.createElement(TextField, { label: "Rotation Pattern", variant: "outlined", error: !!errors.PatternDays, fullWidth: true, type: "number", margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
8573
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8574
|
-
React.createElement(Controller, { name: "CrewRotation", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { label: "Crew rotation", variant: "outlined", fullWidth: true, margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
8575
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8576
|
-
React.createElement(Controller, { name: "Comments", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { style: { margin: "8px 0" }, size: "medium", maxRows: 5, label: "Comments", multiline: true, variant: "outlined", fullWidth: true, autoComplete: "off", value: value, disabled: !!shiftSelected })) })))),
|
|
8577
|
-
React.createElement(MesfModal.Actions, null,
|
|
8578
|
-
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
8579
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
|
|
8580
|
-
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
8581
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
|
|
8582
|
-
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading
|
|
8583
|
-
? isSubmitLoading
|
|
8584
|
-
: shiftSelected
|
|
8585
|
-
? new Date(shiftSelected.PatternStart) < new Date() &&
|
|
8586
|
-
true
|
|
8587
|
-
: false, variant: "contained", color: "secondary", onClick: () => setDeleteAlert(true) }, "Delete"),
|
|
8588
|
-
shiftSelected &&
|
|
8589
|
-
new Date(shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) < new Date() && (React.createElement(Grid2, null,
|
|
8590
|
-
React.createElement(ErrorLabel, { text: "Can not delete before the current date" })))))),
|
|
8591
|
-
React.createElement(Dialog$1, { open: deleteAlert, onClose: () => handleClose(), "aria-labelledby": "responsive-dialog-title" },
|
|
8592
|
-
React.createElement(DialogTitle$1, { id: "responsive-dialog-title" }, "WARNING"),
|
|
8593
|
-
React.createElement(DialogContent$1, null,
|
|
8594
|
-
React.createElement(DialogContentText, { style: { padding: 0, margin: 0 } }, "Be careful, once deleted you will not be able to recover this shift, are you sure you want to delete it?")),
|
|
8595
|
-
React.createElement(DialogActions$1, { style: { padding: "16px 24px" } },
|
|
8596
|
-
React.createElement(Button, { onClick: () => setDeleteAlert(false), autoFocus: true, color: "inherit" }, "CANCEL"),
|
|
8597
|
-
React.createElement(Button, { startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), autoFocus: true, color: "secondary", onClick: () => onDelete(patternStart) }, "Delete"))))),
|
|
8598
|
-
React.createElement(ErrorModal, { error: error, onHide: () => setError("") }),
|
|
8682
|
+
show && (React.createElement(HelmetDexteel, { title: `Delete Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
8683
|
+
React.createElement(Grid2, { container: true },
|
|
8684
|
+
React.createElement(Grid2, null,
|
|
8685
|
+
React.createElement(MesfModal, { title: "DELETE SETTING", open: show, handleClose: () => onHide(false), id: "delete-setting-modal", maxWidth: "md" },
|
|
8686
|
+
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
8687
|
+
React.createElement(MesfModal.Content, null,
|
|
8688
|
+
React.createElement(Grid2, { container: true, spacing: 2 },
|
|
8689
|
+
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
8690
|
+
React.createElement(Controller, { name: "SettingName", control: control, rules: { required: "Name is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({ disabled: true }, field, { label: "Name", variant: "outlined", error: !!error, helperText: error ? error.message : null, fullWidth: true, margin: "dense", autoComplete: "off" }))) })),
|
|
8691
|
+
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
8692
|
+
React.createElement(Controller, { name: "Value", control: control, rules: { required: "Value is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({ disabled: true }, field, { label: "Value", variant: "outlined", error: !!error, helperText: error ? error.message : null, fullWidth: true, margin: "dense", autoComplete: "off" }))) })),
|
|
8693
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8694
|
+
React.createElement(Controller, { name: "Description", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { disabled: true, size: "medium", maxRows: 5, label: "Description", multiline: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
8695
|
+
if (evt.target.value.length <= 200)
|
|
8696
|
+
onChange(evt);
|
|
8697
|
+
} })) })))),
|
|
8698
|
+
React.createElement(MesfModal.Actions, null,
|
|
8699
|
+
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
8700
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8701
|
+
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
8702
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8703
|
+
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "secondary", type: "submit" }, "Delete")))))))),
|
|
8704
|
+
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error deleting Setting" }),
|
|
8599
8705
|
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
8600
|
-
React.createElement(Alert$1, { severity: "
|
|
8706
|
+
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was deleted successfully"))));
|
|
8601
8707
|
};
|
|
8602
8708
|
|
|
8603
|
-
const
|
|
8604
|
-
const theme = useTheme();
|
|
8709
|
+
const EditSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
|
|
8605
8710
|
const [open, setOpen] = useState(false);
|
|
8606
|
-
const [error, setError] = useState("");
|
|
8607
8711
|
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
8608
|
-
const [
|
|
8609
|
-
const { control,
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
const
|
|
8613
|
-
mutationFn:
|
|
8712
|
+
const [error, setError] = useState("");
|
|
8713
|
+
const { control, handleSubmit, reset, setValue } = useForm({
|
|
8714
|
+
defaultValues: settingSelected ? settingSelected : INITIAL_VALUES$1,
|
|
8715
|
+
});
|
|
8716
|
+
const updateSetting = useMutation({
|
|
8717
|
+
mutationFn: upsertSettings,
|
|
8614
8718
|
onSuccess: () => {
|
|
8615
8719
|
setOpen(true);
|
|
8616
8720
|
onHide(true);
|
|
@@ -8623,8 +8727,14 @@ const EditShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
|
|
|
8623
8727
|
},
|
|
8624
8728
|
});
|
|
8625
8729
|
const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8730
|
+
var _a;
|
|
8626
8731
|
setIsSubmitLoading(true);
|
|
8627
|
-
yield
|
|
8732
|
+
yield updateSetting.mutate({
|
|
8733
|
+
oldName: (_a = settingSelected === null || settingSelected === void 0 ? void 0 : settingSelected.SettingName) !== null && _a !== void 0 ? _a : null,
|
|
8734
|
+
newName: data.SettingName,
|
|
8735
|
+
description: data.Description,
|
|
8736
|
+
value: data.Value,
|
|
8737
|
+
});
|
|
8628
8738
|
});
|
|
8629
8739
|
const handleClose = (event, reason) => {
|
|
8630
8740
|
if (reason === "clickaway") {
|
|
@@ -8632,377 +8742,84 @@ const EditShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
|
|
|
8632
8742
|
}
|
|
8633
8743
|
setOpen(false);
|
|
8634
8744
|
};
|
|
8635
|
-
// const patternStart = watch('PatternStart');
|
|
8636
|
-
const shiftsPerDay = watch("ShiftsPerDay");
|
|
8637
|
-
const shiftCodes = watch("ShiftCodes");
|
|
8638
|
-
const numberOfCrews = watch("NumberOfCrews");
|
|
8639
|
-
const crewsCodes = watch("Crews");
|
|
8640
|
-
const rotationPattern = watch("PatternDays");
|
|
8641
|
-
const comments = watch("Comments");
|
|
8642
|
-
const crewRotation = watch("CrewRotation");
|
|
8643
|
-
const maxCrewRotationLength = shiftsPerDay * rotationPattern;
|
|
8644
8745
|
useEffect(() => {
|
|
8645
|
-
var _a, _b, _c, _d, _e, _f;
|
|
8646
8746
|
if (show) {
|
|
8647
8747
|
reset();
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
|
|
8654
|
-
setInitialShiftPerDayAndCrewsNumber(!initialShiftPerDayAndCrewsNumber);
|
|
8748
|
+
if (settingSelected) {
|
|
8749
|
+
setValue("SettingName", settingSelected.SettingName);
|
|
8750
|
+
setValue("Value", settingSelected.Value);
|
|
8751
|
+
setValue("Description", settingSelected.Description);
|
|
8752
|
+
}
|
|
8655
8753
|
}
|
|
8656
8754
|
}, [show]);
|
|
8657
|
-
useEffect(() => {
|
|
8658
|
-
setValue("ShiftsPerDay", crewRotation.length / rotationPattern);
|
|
8659
|
-
setValue("NumberOfCrews", crewsCodes.length);
|
|
8660
|
-
}, [initialShiftPerDayAndCrewsNumber]);
|
|
8661
8755
|
return (React.createElement(React.Fragment, null,
|
|
8662
|
-
show && (React.createElement(HelmetDexteel, { title: `Edit
|
|
8663
|
-
React.createElement(MesfModal, { title: "EDIT
|
|
8756
|
+
show && (React.createElement(HelmetDexteel, { title: `Edit Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
8757
|
+
React.createElement(MesfModal, { title: "EDIT SETTING", open: show, handleClose: () => onHide(false), id: "edit-setting-modal", maxWidth: "md" },
|
|
8664
8758
|
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
8665
8759
|
React.createElement(MesfModal.Content, null,
|
|
8666
|
-
React.createElement(Grid2, { container: true, spacing: 2
|
|
8667
|
-
React.createElement(
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
}, label: "Start", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
8674
|
-
textField: {
|
|
8675
|
-
fullWidth: true,
|
|
8676
|
-
variant: "standard",
|
|
8677
|
-
},
|
|
8678
|
-
} })),
|
|
8679
|
-
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
8680
|
-
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
8681
|
-
textField: {
|
|
8682
|
-
fullWidth: true,
|
|
8683
|
-
variant: "standard",
|
|
8684
|
-
},
|
|
8685
|
-
} })))) }),
|
|
8686
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8687
|
-
React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
|
|
8688
|
-
min: 1,
|
|
8689
|
-
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${shiftsPerDay > 1 ? "Shifts" : "Shift"} per day`, variant: "outlined", error: !!errors.ShiftsPerDay, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: value, onChange:
|
|
8690
|
-
// FIXME: límite de 10?
|
|
8691
|
-
(evt) => parseInt(evt.target.value) >= 1 &&
|
|
8692
|
-
parseInt(evt.target.value) <= 10 &&
|
|
8693
|
-
onChange(evt) })) })),
|
|
8694
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8695
|
-
React.createElement(Controller, { name: "ShiftCodes", control: control, rules: {
|
|
8696
|
-
required: `Please put ${shiftsPerDay} shifts`,
|
|
8697
|
-
validate: (value) => value.length == shiftsPerDay,
|
|
8698
|
-
}, render: ({ field: { onChange, value }, fieldState: { error }, }) => (React.createElement(TextField, { label: "Shifts Ids", variant: "outlined", error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
8699
|
-
// TODO: aquí deberíamos prevenir, que no pueda haber dos valores iguales, . Ej. dos DNN
|
|
8700
|
-
if (evt.target.value.length <= shiftsPerDay)
|
|
8701
|
-
onChange(evt.target.value.toString().toUpperCase());
|
|
8702
|
-
} })) }),
|
|
8703
|
-
shiftCodes.length < shiftsPerDay &&
|
|
8704
|
-
!!errors.ShiftCodes === false && (React.createElement(ErrorLabel, { text: `Insert: ${shiftsPerDay} ${shiftsPerDay == 1 ? "Id" : "Ids"}. ${shiftsPerDay > 1 ? "The Ids must be differents" : ""}` }))),
|
|
8705
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8706
|
-
React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
|
|
8707
|
-
required: "# Crews day is required",
|
|
8708
|
-
min: 1,
|
|
8709
|
-
max: 9,
|
|
8710
|
-
}, render: ({ field: { onChange, value }, fieldState: { error }, }) => (React.createElement(TextField, { label: `# ${numberOfCrews > 1 ? "Crews" : "Crew"}`, variant: "outlined", error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: value, onChange: (evt) => {
|
|
8711
|
-
if (parseInt(evt.target.value) >= 1 &&
|
|
8712
|
-
parseInt(evt.target.value) <= 9)
|
|
8713
|
-
onChange(evt);
|
|
8714
|
-
} })) })),
|
|
8715
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8716
|
-
React.createElement(Controller, { name: "Crews", control: control, rules: {
|
|
8717
|
-
required: `Please put ${numberOfCrews} crews`,
|
|
8718
|
-
validate: (value) => value.length == numberOfCrews,
|
|
8719
|
-
}, render: ({ field: { onChange, value }, fieldState: { error }, }) => (React.createElement(TextField, { label: "Crews Ids", variant: "outlined", error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, disabled: numberOfCrews <= 0, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
8720
|
-
if (evt.target.value.length <= numberOfCrews)
|
|
8721
|
-
onChange(evt.target.value.toString().toUpperCase());
|
|
8722
|
-
} })) }),
|
|
8723
|
-
crewsCodes.length < numberOfCrews &&
|
|
8724
|
-
!!errors.Crews === false && (React.createElement(ErrorLabel, { text: `Insert: ${numberOfCrews} ${numberOfCrews == 1 ? "Crew" : "Crews"}. ${numberOfCrews > 1 ? "The Crews must be differents" : ""}` }))),
|
|
8725
|
-
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
8726
|
-
React.createElement(Controller, { name: "PatternDays", control: control,
|
|
8727
|
-
// rules={{
|
|
8728
|
-
// required: true
|
|
8729
|
-
// }}
|
|
8730
|
-
render: ({ field: { value, onChange } }) => (React.createElement(TextField, { label: "Rotation Pattern", variant: "outlined", error: !!errors.PatternDays, fullWidth: true, type: "number", margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
8731
|
-
// FIXME: consultar si estos valores están bien, son los limites del sP
|
|
8732
|
-
if (parseInt(evt.target.value) >= 5 &&
|
|
8733
|
-
parseInt(evt.target.value) <= 60)
|
|
8734
|
-
onChange(evt);
|
|
8735
|
-
} })) })),
|
|
8736
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8737
|
-
React.createElement(Controller, { name: "CrewRotation", control: control, rules: {
|
|
8738
|
-
validate: (value) => value.length == maxCrewRotationLength,
|
|
8739
|
-
}, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { value: value, onChange: (evt) => {
|
|
8740
|
-
if (evt.target.value.length <= maxCrewRotationLength)
|
|
8741
|
-
onChange(evt.target.value.toString().toUpperCase());
|
|
8742
|
-
}, error: !!errors.CrewRotation, label: "Crew rotation", variant: "outlined", fullWidth: true, margin: "dense", autoComplete: "off" })) }),
|
|
8743
|
-
React.createElement(Grid2, { container: true, height: 2 },
|
|
8744
|
-
React.createElement(Grid2, { style: {
|
|
8745
|
-
height: 2,
|
|
8746
|
-
width: `${calculatePercentage()}% `,
|
|
8747
|
-
backgroundColor: `${crewRotation.length == maxCrewRotationLength
|
|
8748
|
-
? "#4CAF50"
|
|
8749
|
-
: "#F44336"}`,
|
|
8750
|
-
transition: " 0.2s ease",
|
|
8751
|
-
margin: "0 5px",
|
|
8752
|
-
} })),
|
|
8753
|
-
React.createElement(Grid2, { container: true },
|
|
8754
|
-
React.createElement(Grid2, null, (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) >= 1 &&
|
|
8755
|
-
(crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) !==
|
|
8756
|
-
maxCrewRotationLength && (React.createElement("span", { style: {
|
|
8757
|
-
fontSize: 12,
|
|
8758
|
-
color: theme.palette.info.main,
|
|
8759
|
-
marginLeft: 5,
|
|
8760
|
-
} }, `${crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length}/${maxCrewRotationLength}`)))),
|
|
8761
|
-
!!errors.CrewRotation && (React.createElement(ErrorLabel, { text: `Please put ${maxCrewRotationLength} crews` })),
|
|
8762
|
-
numberOfCrews > 0 &&
|
|
8763
|
-
Number.isInteger(maxCrewRotationLength / numberOfCrews) ===
|
|
8764
|
-
false && (React.createElement(Grid2, { container: true, style: { padding: "0", marginLeft: 5 } },
|
|
8765
|
-
React.createElement(ErrorLabel, { text: `Rotation # not a multiple of Shifts (${maxCrewRotationLength}) / Crews (${numberOfCrews})` })))),
|
|
8760
|
+
React.createElement(Grid2, { container: true, spacing: 2 },
|
|
8761
|
+
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
8762
|
+
React.createElement(Controller, { name: "SettingName", control: control, rules: { required: "Name is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Name", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
8763
|
+
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
8764
|
+
React.createElement(Controller, { name: "Value", control: control, rules: {
|
|
8765
|
+
required: "Value is required",
|
|
8766
|
+
}, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Value", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
8766
8767
|
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8767
|
-
React.createElement(Controller, { name: "
|
|
8768
|
+
React.createElement(Controller, { name: "Description", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { size: "medium", maxRows: 5, label: "Description", multiline: true, variant: "outlined", fullWidth: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
8768
8769
|
if (evt.target.value.length <= 200)
|
|
8769
8770
|
onChange(evt);
|
|
8770
|
-
} })) }),
|
|
8771
|
-
React.createElement(Grid2, { container: true, style: { marginBottom: 18 } },
|
|
8772
|
-
React.createElement(Grid2, null,
|
|
8773
|
-
(comments === null || comments === void 0 ? void 0 : comments.length) >= 1 &&
|
|
8774
|
-
(comments === null || comments === void 0 ? void 0 : comments.length) !== 200 && (React.createElement("span", { style: {
|
|
8775
|
-
fontSize: 12,
|
|
8776
|
-
color: theme.palette.info.main,
|
|
8777
|
-
marginLeft: 5,
|
|
8778
|
-
} }, `${comments === null || comments === void 0 ? void 0 : comments.length}/200`)),
|
|
8779
|
-
(comments === null || comments === void 0 ? void 0 : comments.length) == 200 && (React.createElement("span", { style: {
|
|
8780
|
-
fontSize: 12,
|
|
8781
|
-
color: theme.palette.info.main,
|
|
8782
|
-
marginLeft: 5,
|
|
8783
|
-
} }, "Max. 200"))))))),
|
|
8771
|
+
} })) })))),
|
|
8784
8772
|
React.createElement(MesfModal.Actions, null,
|
|
8785
8773
|
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
8786
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 }
|
|
8774
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8787
8775
|
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
8788
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 }
|
|
8776
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
8789
8777
|
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))),
|
|
8790
|
-
React.createElement(ErrorModal, { error: error, onHide: () => setError("") }),
|
|
8778
|
+
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error updating Setting" }),
|
|
8791
8779
|
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
8792
|
-
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The
|
|
8793
|
-
};
|
|
8794
|
-
|
|
8795
|
-
const useShiftsOptionsFunctions = ({ setShiftId, setShowDeleteModal, setShowCreateModal, setShowEditModal, }) => {
|
|
8796
|
-
const getMenuOptions = (data) => {
|
|
8797
|
-
let options = [];
|
|
8798
|
-
if (!data) {
|
|
8799
|
-
options = options.concat([
|
|
8800
|
-
{
|
|
8801
|
-
name: "New Shift",
|
|
8802
|
-
key: "new_shift",
|
|
8803
|
-
onClick: () => {
|
|
8804
|
-
setShowCreateModal(true);
|
|
8805
|
-
},
|
|
8806
|
-
icon: React__default.createElement(PlaylistAddIcon, null),
|
|
8807
|
-
},
|
|
8808
|
-
]);
|
|
8809
|
-
}
|
|
8810
|
-
else {
|
|
8811
|
-
options = options.concat([
|
|
8812
|
-
{
|
|
8813
|
-
name: "New Shift",
|
|
8814
|
-
key: "new_shift",
|
|
8815
|
-
onClick: () => {
|
|
8816
|
-
setShowCreateModal(true);
|
|
8817
|
-
},
|
|
8818
|
-
icon: React__default.createElement(PlaylistAddIcon, null),
|
|
8819
|
-
},
|
|
8820
|
-
{
|
|
8821
|
-
name: "Edit Shift",
|
|
8822
|
-
key: "edit_shift",
|
|
8823
|
-
onClick: () => {
|
|
8824
|
-
setShiftId(data);
|
|
8825
|
-
setShowEditModal(true);
|
|
8826
|
-
},
|
|
8827
|
-
icon: React__default.createElement(EditIcon, null),
|
|
8828
|
-
},
|
|
8829
|
-
{
|
|
8830
|
-
name: "Delete Shift",
|
|
8831
|
-
key: "delete_shift",
|
|
8832
|
-
onClick: () => {
|
|
8833
|
-
setShiftId(data);
|
|
8834
|
-
setShowDeleteModal(true);
|
|
8835
|
-
},
|
|
8836
|
-
icon: React__default.createElement(DeleteIcon, null),
|
|
8837
|
-
},
|
|
8838
|
-
]);
|
|
8839
|
-
}
|
|
8840
|
-
return options;
|
|
8841
|
-
};
|
|
8842
|
-
return {
|
|
8843
|
-
getMenuOptions,
|
|
8844
|
-
};
|
|
8845
|
-
};
|
|
8846
|
-
|
|
8847
|
-
const useTableData$5 = ({ setShiftSelected, setOpenModalEditShift, setOpenModalDeleteShift, showContextMenu, }) => {
|
|
8848
|
-
const columnDefs = [
|
|
8849
|
-
{
|
|
8850
|
-
field: "PatternStart",
|
|
8851
|
-
headerName: "Pattern Start",
|
|
8852
|
-
valueFormatter: ({ value }) => `${moment$f(value).format("L")}, ${moment$f(value).format("LTS")}`,
|
|
8853
|
-
minWidth: 180,
|
|
8854
|
-
flex: 4,
|
|
8855
|
-
cellStyle: {
|
|
8856
|
-
display: "flex",
|
|
8857
|
-
alignItems: "center",
|
|
8858
|
-
justifyContent: "center",
|
|
8859
|
-
},
|
|
8860
|
-
},
|
|
8861
|
-
{
|
|
8862
|
-
field: "ShiftCodes",
|
|
8863
|
-
headerName: "Shift Codes",
|
|
8864
|
-
minWidth: 150,
|
|
8865
|
-
flex: 2,
|
|
8866
|
-
cellStyle: {
|
|
8867
|
-
display: "flex",
|
|
8868
|
-
alignItems: "center",
|
|
8869
|
-
justifyContent: "center",
|
|
8870
|
-
},
|
|
8871
|
-
},
|
|
8872
|
-
{
|
|
8873
|
-
field: "Crews",
|
|
8874
|
-
headerName: "Crews",
|
|
8875
|
-
minWidth: 150,
|
|
8876
|
-
flex: 2,
|
|
8877
|
-
cellStyle: {
|
|
8878
|
-
display: "flex",
|
|
8879
|
-
alignItems: "center",
|
|
8880
|
-
justifyContent: "center",
|
|
8881
|
-
},
|
|
8882
|
-
},
|
|
8883
|
-
{
|
|
8884
|
-
sortable: false,
|
|
8885
|
-
field: "PatternDays",
|
|
8886
|
-
headerName: "Shifts",
|
|
8887
|
-
minWidth: 130,
|
|
8888
|
-
flex: 1,
|
|
8889
|
-
cellStyle: {
|
|
8890
|
-
display: "flex",
|
|
8891
|
-
alignItems: "center",
|
|
8892
|
-
justifyContent: "center",
|
|
8893
|
-
},
|
|
8894
|
-
},
|
|
8895
|
-
{
|
|
8896
|
-
cellRenderer: (params) => {
|
|
8897
|
-
return (React__default.createElement(Grid2, { container: true, style: {
|
|
8898
|
-
height: "100%",
|
|
8899
|
-
display: "flex",
|
|
8900
|
-
justifyContent: "center",
|
|
8901
|
-
alignItems: "center",
|
|
8902
|
-
}, sx: {
|
|
8903
|
-
opacity: 0,
|
|
8904
|
-
transition: "opacity 0.1s ease-in-out",
|
|
8905
|
-
".ag-row-hover &": {
|
|
8906
|
-
opacity: 1,
|
|
8907
|
-
},
|
|
8908
|
-
".ag-row-focus &": {
|
|
8909
|
-
opacity: 1,
|
|
8910
|
-
},
|
|
8911
|
-
".ag-row-selected &": {
|
|
8912
|
-
opacity: 1,
|
|
8913
|
-
},
|
|
8914
|
-
} },
|
|
8915
|
-
React__default.createElement(Grid2, { size: { xs: 12, md: 12 }, style: {
|
|
8916
|
-
display: "flex",
|
|
8917
|
-
justifyContent: "center",
|
|
8918
|
-
alignItems: "center",
|
|
8919
|
-
} },
|
|
8920
|
-
React__default.createElement(Button, { style: {}, onClick: () => {
|
|
8921
|
-
setShiftSelected(params === null || params === void 0 ? void 0 : params.data);
|
|
8922
|
-
setOpenModalEditShift(true);
|
|
8923
|
-
} },
|
|
8924
|
-
React__default.createElement(EditIcon, { color: "primary" })),
|
|
8925
|
-
React__default.createElement(Button, { style: {}, onClick: () => {
|
|
8926
|
-
setShiftSelected(params === null || params === void 0 ? void 0 : params.data);
|
|
8927
|
-
setOpenModalDeleteShift(true);
|
|
8928
|
-
} },
|
|
8929
|
-
React__default.createElement(DeleteIcon, { color: "secondary" })),
|
|
8930
|
-
React__default.createElement(Button, { style: {}, onClick: (e) => showContextMenu(e, params.data, "TableShifts") },
|
|
8931
|
-
React__default.createElement(FormatListBulletedSharpIcon, { color: "action" })))));
|
|
8932
|
-
},
|
|
8933
|
-
field: "",
|
|
8934
|
-
flex: 3,
|
|
8935
|
-
minWidth: 240,
|
|
8936
|
-
editable: false,
|
|
8937
|
-
autoHeight: false,
|
|
8938
|
-
suppressNavigable: true,
|
|
8939
|
-
},
|
|
8940
|
-
];
|
|
8941
|
-
return { columnDefs };
|
|
8780
|
+
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was edited successfully"))));
|
|
8942
8781
|
};
|
|
8943
8782
|
|
|
8944
|
-
const
|
|
8783
|
+
const useSearchSettings = () => {
|
|
8945
8784
|
return useQuery({
|
|
8946
|
-
queryKey: ["
|
|
8947
|
-
queryFn: ({ signal }) =>
|
|
8785
|
+
queryKey: ["settings"],
|
|
8786
|
+
queryFn: ({ signal }) => getUTLSettings(signal),
|
|
8948
8787
|
});
|
|
8949
8788
|
};
|
|
8950
|
-
const
|
|
8951
|
-
const
|
|
8789
|
+
const TableSettings = () => {
|
|
8790
|
+
const queryClient = useQueryClient();
|
|
8791
|
+
const { showContextMenu, registerConfig } = useContextMenuMESF();
|
|
8952
8792
|
const [error, setError] = useState("");
|
|
8793
|
+
const [gridApi, setGridApi] = useState(null);
|
|
8794
|
+
const [filterValue, setFilterValue] = useState("");
|
|
8795
|
+
const [settingSelected, setSettingSelected] = useState(null);
|
|
8953
8796
|
const [openModalNew, setOpenModalNew] = useState(false);
|
|
8954
|
-
const [
|
|
8955
|
-
const [
|
|
8956
|
-
const
|
|
8957
|
-
const {
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
PatternStart,
|
|
8961
|
-
ShiftCodes,
|
|
8962
|
-
Crews,
|
|
8963
|
-
PatternDays,
|
|
8964
|
-
CrewRotation,
|
|
8965
|
-
Comments,
|
|
8966
|
-
CanEdit,
|
|
8967
|
-
}));
|
|
8968
|
-
const defaultColDef = useMemo(() => {
|
|
8969
|
-
return {
|
|
8970
|
-
sortable: true,
|
|
8971
|
-
wrapText: true,
|
|
8972
|
-
autoHeight: true,
|
|
8973
|
-
wrapHeaderText: true,
|
|
8974
|
-
suppressHeaderMenuButton: true,
|
|
8975
|
-
cellStyle: {
|
|
8976
|
-
display: "flex",
|
|
8977
|
-
alignItems: "center",
|
|
8978
|
-
justifyContent: "center",
|
|
8979
|
-
},
|
|
8980
|
-
};
|
|
8981
|
-
}, []);
|
|
8982
|
-
const { getMenuOptions } = useShiftsOptionsFunctions({
|
|
8983
|
-
setShiftId: setShiftSelected,
|
|
8797
|
+
const [openModalEditSetting, setOpenModalEditSetting] = useState(false);
|
|
8798
|
+
const [openModalDeleteSetting, setOpenModalDeleteSetting] = useState(false);
|
|
8799
|
+
const { data: rows, isLoading, isError, error: e } = useSearchSettings();
|
|
8800
|
+
const { getMenuOptions } = useSettingsOptionsFunctions({
|
|
8801
|
+
setSettingId: setSettingSelected,
|
|
8802
|
+
setShowDeleteModal: setOpenModalDeleteSetting,
|
|
8984
8803
|
setShowCreateModal: setOpenModalNew,
|
|
8985
|
-
|
|
8986
|
-
setShowEditModal: setOpenModalEditShift,
|
|
8804
|
+
setShowEditModal: setOpenModalEditSetting,
|
|
8987
8805
|
});
|
|
8988
|
-
const {
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
setOpenModalEditShift,
|
|
8992
|
-
setOpenModalDeleteShift,
|
|
8806
|
+
const { columnDefs, defaultColDef } = useTableData$5({
|
|
8807
|
+
setOpenModalEditSetting,
|
|
8808
|
+
setOpenModalDeleteSetting,
|
|
8993
8809
|
showContextMenu,
|
|
8810
|
+
setSettingSelected,
|
|
8994
8811
|
});
|
|
8995
8812
|
const getContextMenuItems = (params) => {
|
|
8996
8813
|
var _a, _b;
|
|
8997
8814
|
const data = (_a = params.node) === null || _a === void 0 ? void 0 : _a.data;
|
|
8998
8815
|
params.api.deselectAll();
|
|
8999
8816
|
(_b = params.node) === null || _b === void 0 ? void 0 : _b.setSelected(true);
|
|
9000
|
-
showContextMenu(event, data, "
|
|
8817
|
+
showContextMenu(event, data, "TableSettings");
|
|
9001
8818
|
return [];
|
|
9002
8819
|
};
|
|
9003
8820
|
useEffect(() => {
|
|
9004
8821
|
registerConfig({
|
|
9005
|
-
id: "
|
|
8822
|
+
id: "TableSettings",
|
|
9006
8823
|
getOptions: getMenuOptions,
|
|
9007
8824
|
});
|
|
9008
8825
|
}, []);
|
|
@@ -9011,225 +8828,700 @@ const TableShiftsCrews = () => {
|
|
|
9011
8828
|
setError(e.message);
|
|
9012
8829
|
}
|
|
9013
8830
|
}, [e, isError]);
|
|
9014
|
-
return (
|
|
9015
|
-
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
8831
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
8832
|
+
React__default.createElement(Grid2, { container: true, justifyContent: "center", p: 1, spacing: 1 },
|
|
8833
|
+
React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8834
|
+
React__default.createElement(Typography$1, { variant: "h5", fontWeight: 600 }, "Settings")),
|
|
8835
|
+
React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
8836
|
+
React__default.createElement(TextField, { fullWidth: true, label: "Search", variant: "outlined", size: "small", margin: "dense", value: filterValue, onChange: (event) => {
|
|
8837
|
+
setFilterValue(event.target.value);
|
|
8838
|
+
gridApi === null || gridApi === void 0 ? void 0 : gridApi.setGridOption("quickFilterText", event.target.value);
|
|
8839
|
+
}, slotProps: {
|
|
8840
|
+
input: {
|
|
8841
|
+
startAdornment: (React__default.createElement(InputAdornment, { position: "start" },
|
|
8842
|
+
React__default.createElement(IconButton$1, { edge: "start", type: "submit" },
|
|
8843
|
+
React__default.createElement(SearchIcon, null)))),
|
|
8844
|
+
},
|
|
8845
|
+
} })),
|
|
8846
|
+
React__default.createElement(Grid2, { container: true, size: { md: 12, xs: 12 } },
|
|
8847
|
+
React__default.createElement(Grid2, { size: { md: 12, xs: 12 }, style: {
|
|
8848
|
+
height: "70vh",
|
|
8849
|
+
} },
|
|
8850
|
+
React__default.createElement(Paper, { style: { height: "100%", width: "100%" } },
|
|
8851
|
+
React__default.createElement(AgGridReact, { loading: isLoading, gridOptions: {
|
|
9024
8852
|
theme: themeDXT,
|
|
9025
|
-
},
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
} })),
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
8853
|
+
}, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 34, headerHeight: 34, animateRows: true, loadingOverlayComponent: CenteredLazyLoading, getContextMenuItems: (e) => getContextMenuItems(e), rowSelection: "single", onRowDoubleClicked: (event) => {
|
|
8854
|
+
setSettingSelected(event.data);
|
|
8855
|
+
setOpenModalEditSetting(true);
|
|
8856
|
+
}, onGridReady: (params) => setGridApi(params.api) }))),
|
|
8857
|
+
React__default.createElement(Grid2, { container: true, justifyContent: "flex-end" },
|
|
8858
|
+
React__default.createElement(Grid2, { size: { md: 2, xs: 12 } },
|
|
8859
|
+
React__default.createElement(Button, { variant: "contained", color: "primary", onClick: () => setOpenModalNew(!openModalNew), fullWidth: true }, "NEW SETTING"))))),
|
|
8860
|
+
React__default.createElement(CreateSetting, { settingSelected: settingSelected, show: openModalNew, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9033
8861
|
setOpenModalNew(false);
|
|
9034
8862
|
if (shouldUpdate)
|
|
9035
|
-
|
|
9036
|
-
}, suffixTitle: "
|
|
9037
|
-
|
|
9038
|
-
|
|
8863
|
+
yield queryClient.invalidateQueries({ queryKey: ["settings"] });
|
|
8864
|
+
}), suffixTitle: "Settings" }),
|
|
8865
|
+
React__default.createElement(EditSetting, { settingSelected: settingSelected, show: openModalEditSetting, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8866
|
+
setOpenModalEditSetting(false);
|
|
9039
8867
|
if (shouldUpdate)
|
|
9040
|
-
|
|
9041
|
-
}, suffixTitle: "
|
|
9042
|
-
|
|
9043
|
-
|
|
8868
|
+
yield queryClient.invalidateQueries({ queryKey: ["settings"] });
|
|
8869
|
+
}), suffixTitle: "Settings" }),
|
|
8870
|
+
React__default.createElement(DeleteSetting, { settingSelected: settingSelected, show: openModalDeleteSetting, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8871
|
+
setOpenModalDeleteSetting(false);
|
|
9044
8872
|
if (shouldUpdate)
|
|
9045
|
-
|
|
9046
|
-
}, suffixTitle: "
|
|
9047
|
-
};
|
|
9048
|
-
|
|
9049
|
-
const ShiftsCrews = () => {
|
|
9050
|
-
return (React.createElement(React.Fragment, null,
|
|
9051
|
-
React.createElement(HelmetDexteel, { title: "Shifts and Crews" }),
|
|
9052
|
-
React.createElement(TableShiftsCrews, null)));
|
|
9053
|
-
};
|
|
9054
|
-
|
|
9055
|
-
const ShiftsCrewsPage = (props) => {
|
|
9056
|
-
return React.createElement(ShiftsCrews, null);
|
|
9057
|
-
};
|
|
9058
|
-
|
|
9059
|
-
const AssetPage = () => {
|
|
9060
|
-
return (React__default.createElement(React__default.Fragment, null,
|
|
9061
|
-
React__default.createElement(DndProvider, { backend: HTML5Backend },
|
|
9062
|
-
React__default.createElement(TreeAsset, null))));
|
|
9063
|
-
};
|
|
9064
|
-
|
|
9065
|
-
const Asset = (props) => {
|
|
9066
|
-
return React.createElement(AssetPage, null);
|
|
9067
|
-
};
|
|
9068
|
-
|
|
9069
|
-
const UsersPage = (props) => {
|
|
9070
|
-
return React.createElement(Users, null);
|
|
8873
|
+
yield queryClient.invalidateQueries({ queryKey: ["settings"] });
|
|
8874
|
+
}), suffixTitle: "Settings" }),
|
|
8875
|
+
React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
|
|
9071
8876
|
};
|
|
9072
8877
|
|
|
9073
|
-
const
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
})
|
|
9077
|
-
|
|
9078
|
-
style: "currency",
|
|
9079
|
-
currency: "USD",
|
|
9080
|
-
});
|
|
9081
|
-
const IntegerFormatter = new Intl.NumberFormat("en-US", {});
|
|
9082
|
-
const DateTimeFormatter = new Intl.DateTimeFormat("en-US-u-hc-h23", {
|
|
9083
|
-
year: "numeric",
|
|
9084
|
-
month: "2-digit",
|
|
9085
|
-
day: "2-digit",
|
|
9086
|
-
hour: "numeric",
|
|
9087
|
-
minute: "numeric",
|
|
9088
|
-
second: "numeric",
|
|
9089
|
-
hour12: false,
|
|
9090
|
-
// timeZone: 'America/Los_Angeles'
|
|
9091
|
-
});
|
|
9092
|
-
const DateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
9093
|
-
year: "numeric",
|
|
9094
|
-
month: "2-digit",
|
|
9095
|
-
day: "2-digit",
|
|
9096
|
-
// timeZone: 'America/Los_Angeles'
|
|
9097
|
-
});
|
|
9098
|
-
const TimeFormatter = new Intl.DateTimeFormat("en-US-u-hc-h23", {
|
|
9099
|
-
hour: "2-digit",
|
|
9100
|
-
minute: "numeric",
|
|
9101
|
-
second: "numeric",
|
|
9102
|
-
hour12: false,
|
|
9103
|
-
// timeZone: 'America/Los_Angeles'
|
|
9104
|
-
});
|
|
9105
|
-
|
|
9106
|
-
const getShiftStyle = (shift) => {
|
|
9107
|
-
if (shift === "D") {
|
|
9108
|
-
return { color: "#52a8b7" };
|
|
9109
|
-
}
|
|
9110
|
-
else if (shift === "N") {
|
|
9111
|
-
return { color: "#A5A5A5" };
|
|
9112
|
-
}
|
|
9113
|
-
else {
|
|
9114
|
-
return {};
|
|
9115
|
-
}
|
|
9116
|
-
};
|
|
9117
|
-
const getCrewStyle = (crew) => {
|
|
9118
|
-
if (crew === "A") {
|
|
9119
|
-
return { color: "#0070C0" };
|
|
9120
|
-
}
|
|
9121
|
-
else if (crew === "B") {
|
|
9122
|
-
return { color: "#FFD24A" };
|
|
9123
|
-
}
|
|
9124
|
-
else if (crew === "C") {
|
|
9125
|
-
return { color: "#FD8359" };
|
|
9126
|
-
}
|
|
9127
|
-
else if (crew === "D") {
|
|
9128
|
-
return { color: "#00B050" };
|
|
9129
|
-
}
|
|
9130
|
-
else {
|
|
9131
|
-
return {};
|
|
9132
|
-
}
|
|
9133
|
-
};
|
|
9134
|
-
const GetShiftColor = (props) => {
|
|
9135
|
-
return (React__default.createElement(React__default.Fragment, null,
|
|
9136
|
-
React__default.createElement(Square$1, { sx: Object.assign({ mr: 1 }, getShiftStyle(props.value)), fontSize: "small" })));
|
|
8878
|
+
const searchSettings = () => {
|
|
8879
|
+
return useQuery({
|
|
8880
|
+
queryKey: ["settings"],
|
|
8881
|
+
queryFn: ({ signal }) => getUTLSettings(signal),
|
|
8882
|
+
});
|
|
9137
8883
|
};
|
|
9138
|
-
const
|
|
8884
|
+
const SettingsPage = () => {
|
|
9139
8885
|
return (React__default.createElement(React__default.Fragment, null,
|
|
9140
|
-
React__default.createElement(
|
|
8886
|
+
React__default.createElement(HelmetDexteel, { title: "Settings" }),
|
|
8887
|
+
React__default.createElement(TableSettings, null)));
|
|
9141
8888
|
};
|
|
9142
8889
|
|
|
9143
|
-
const
|
|
9144
|
-
|
|
9145
|
-
|
|
9146
|
-
plantAssetId: 1,
|
|
8890
|
+
const UTLSettingsInitialState = {
|
|
8891
|
+
serverTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
8892
|
+
settings: {},
|
|
9147
8893
|
};
|
|
9148
|
-
const
|
|
8894
|
+
const UTLSettingsReducer = createSlice({
|
|
9149
8895
|
name: "__",
|
|
9150
|
-
initialState:
|
|
8896
|
+
initialState: UTLSettingsInitialState,
|
|
9151
8897
|
reducers: {
|
|
9152
|
-
|
|
9153
|
-
state.
|
|
8898
|
+
setServerTimeZone(state, { payload }) {
|
|
8899
|
+
state.serverTimeZone = payload;
|
|
9154
8900
|
},
|
|
9155
|
-
|
|
9156
|
-
state.
|
|
8901
|
+
setSetting(state, { payload }) {
|
|
8902
|
+
state.settings[payload.key] = payload.value;
|
|
9157
8903
|
},
|
|
9158
|
-
|
|
9159
|
-
state.
|
|
8904
|
+
initSettings(state, { payload }) {
|
|
8905
|
+
state.settings = payload.reduce((acc, cur) => {
|
|
8906
|
+
if (cur.SettingName.trim().toLowerCase() === "timezone") {
|
|
8907
|
+
const timeService = TimeService.getInstance();
|
|
8908
|
+
timeService.setTimeZone(cur.Value);
|
|
8909
|
+
}
|
|
8910
|
+
acc[cur.SettingName.trim()] = cur.Value;
|
|
8911
|
+
return acc;
|
|
8912
|
+
}, {});
|
|
9160
8913
|
},
|
|
9161
8914
|
},
|
|
9162
8915
|
});
|
|
9163
8916
|
|
|
9164
|
-
const
|
|
9165
|
-
state:
|
|
9166
|
-
actions:
|
|
8917
|
+
const UTLSettingsContext = createContext({
|
|
8918
|
+
state: UTLSettingsReducer.getInitialState(),
|
|
8919
|
+
actions: UTLSettingsReducer.actions,
|
|
8920
|
+
isLoading: true,
|
|
9167
8921
|
});
|
|
9168
|
-
const
|
|
9169
|
-
const
|
|
8922
|
+
const useUTLSettingsContext = () => useContext(UTLSettingsContext);
|
|
8923
|
+
const UTLSettingsProvider = ({ children }) => {
|
|
9170
8924
|
const [state, actions] = useComplexState({
|
|
9171
|
-
initialState:
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
8925
|
+
initialState: UTLSettingsReducer.getInitialState(),
|
|
8926
|
+
reducers: UTLSettingsReducer.caseReducers,
|
|
8927
|
+
});
|
|
8928
|
+
const { data: rows, isLoading, isError, error: e, isSuccess, refetch, } = searchSettings();
|
|
8929
|
+
useEffect(() => {
|
|
8930
|
+
if (isSuccess) {
|
|
8931
|
+
const settings = rows;
|
|
8932
|
+
const settingsTrimmed = settings.map((setting) => (Object.assign(Object.assign({}, setting), { SettingName: setting.SettingName.trim() })));
|
|
8933
|
+
actions.initSettings(settingsTrimmed);
|
|
8934
|
+
}
|
|
8935
|
+
}, [isSuccess]);
|
|
8936
|
+
useEffect(() => {
|
|
8937
|
+
if (e && isError) {
|
|
8938
|
+
console.error(e.message);
|
|
8939
|
+
}
|
|
8940
|
+
}, [e, isError]);
|
|
8941
|
+
useMesfRealtime({
|
|
8942
|
+
onReceiveMessage: (author, message) => {
|
|
8943
|
+
if (message === "UTL.GetSettings") {
|
|
8944
|
+
refetch();
|
|
8945
|
+
}
|
|
9175
8946
|
},
|
|
9176
|
-
reducers: AssetReducer.caseReducers,
|
|
9177
8947
|
});
|
|
9178
|
-
return (React__default.createElement(
|
|
8948
|
+
return (React__default.createElement(UTLSettingsContext.Provider, { value: { state, actions, isLoading } }, children));
|
|
9179
8949
|
};
|
|
9180
8950
|
|
|
9181
|
-
const
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9205
|
-
|
|
9206
|
-
|
|
9207
|
-
|
|
9208
|
-
|
|
9209
|
-
|
|
9210
|
-
|
|
8951
|
+
const getShiftParameters = (assetId, signal) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8952
|
+
const apiService = new MESApiService();
|
|
8953
|
+
const parameters = [{ name: "AssetId", value: assetId }];
|
|
8954
|
+
const resp = yield apiService.callV2("[MES].[GetShiftParameters]", parameters, signal);
|
|
8955
|
+
if (resp.ok) {
|
|
8956
|
+
return get(resp, "data.tables[0].rows", []);
|
|
8957
|
+
}
|
|
8958
|
+
else {
|
|
8959
|
+
throw new Error(resp.message || "Error fetching shifts");
|
|
8960
|
+
}
|
|
8961
|
+
});
|
|
8962
|
+
const upsertShiftParameters = (_a, assetId_1, ...args_1) => __awaiter(void 0, [_a, assetId_1, ...args_1], void 0, function* ({ PatternStart, ShiftCodes, Crews, CrewRotation, Comments }, assetId, isUpdate = false) {
|
|
8963
|
+
const apiService = new MESApiService();
|
|
8964
|
+
const parameters = [
|
|
8965
|
+
{ name: "AssetId", value: assetId },
|
|
8966
|
+
{ name: "PatternStart", value: PatternStart },
|
|
8967
|
+
{ name: "ShiftCodes", value: ShiftCodes },
|
|
8968
|
+
{ name: "Crews", value: Crews },
|
|
8969
|
+
{ name: "CrewRotation", value: CrewRotation },
|
|
8970
|
+
{ name: "Comments", value: Comments },
|
|
8971
|
+
{ name: "IsUpdate", value: isUpdate },
|
|
8972
|
+
];
|
|
8973
|
+
const resp = yield apiService.callV2("[MES].[UpsertShiftParameters]", parameters);
|
|
8974
|
+
if (!resp.ok) {
|
|
8975
|
+
throw new Error(resp.message || "Error when upsert shift");
|
|
8976
|
+
}
|
|
8977
|
+
});
|
|
8978
|
+
const deleteShiftParameters = (assetId, PatternStart) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8979
|
+
const apiService = new MESApiService();
|
|
8980
|
+
const parameters = [];
|
|
8981
|
+
parameters.push({ name: "AssetId", value: assetId });
|
|
8982
|
+
parameters.push({ name: "PatternStart", value: PatternStart });
|
|
8983
|
+
const resp = yield apiService.callV2("[MES].[DeleteShiftParameters]", parameters);
|
|
8984
|
+
if (!resp.ok) {
|
|
8985
|
+
throw new Error(resp.message || "Error when delete shift");
|
|
8986
|
+
}
|
|
8987
|
+
});
|
|
8988
|
+
|
|
8989
|
+
const INITIAL_VALUES = {
|
|
8990
|
+
PatternStart: new Date(),
|
|
8991
|
+
ShiftCodes: "",
|
|
8992
|
+
Crews: "",
|
|
8993
|
+
User: "",
|
|
8994
|
+
PatternDays: 5,
|
|
8995
|
+
CrewRotation: "",
|
|
8996
|
+
Comments: "",
|
|
8997
|
+
CanEdit: false,
|
|
8998
|
+
ShiftsPerDay: 1,
|
|
8999
|
+
NumberOfCrews: 1,
|
|
9000
|
+
};
|
|
9001
|
+
|
|
9002
|
+
const CreateShift = ({ shiftSelected, show, onHide, suffixTitle, assetId, assetName, }) => {
|
|
9003
|
+
var _a, _b;
|
|
9004
|
+
const theme = useTheme();
|
|
9005
|
+
const [open, setOpen] = useState(false);
|
|
9006
|
+
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
9007
|
+
const [error, setError] = useState("");
|
|
9008
|
+
const { control, handleSubmit, reset, watch, setValue, formState: { errors }, } = useForm({
|
|
9009
|
+
defaultValues: shiftSelected ? shiftSelected : INITIAL_VALUES,
|
|
9010
|
+
});
|
|
9011
|
+
// Progress bar
|
|
9012
|
+
const calculatePercentage = () => ((crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) / maxCrewRotationLength) * 100;
|
|
9013
|
+
const createShift = useMutation({
|
|
9014
|
+
mutationFn: (data) => upsertShiftParameters(data, assetId),
|
|
9015
|
+
onSuccess: () => {
|
|
9016
|
+
setOpen(true);
|
|
9017
|
+
onHide(true);
|
|
9018
|
+
},
|
|
9019
|
+
onError: (error) => {
|
|
9020
|
+
setError(error.message);
|
|
9021
|
+
},
|
|
9022
|
+
onSettled: () => {
|
|
9023
|
+
setIsSubmitLoading(false);
|
|
9024
|
+
},
|
|
9025
|
+
});
|
|
9026
|
+
const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9027
|
+
setIsSubmitLoading(true);
|
|
9028
|
+
yield createShift.mutate(data);
|
|
9029
|
+
});
|
|
9030
|
+
const handleClose = (event, reason) => {
|
|
9031
|
+
if (reason === "clickaway") {
|
|
9032
|
+
return;
|
|
9033
|
+
}
|
|
9034
|
+
setOpen(false);
|
|
9035
|
+
};
|
|
9036
|
+
// const patternStart = watch('PatternStart');
|
|
9037
|
+
const shiftsPerDay = watch("ShiftsPerDay");
|
|
9038
|
+
const shiftCodes = watch("ShiftCodes");
|
|
9039
|
+
const numberOfCrews = watch("NumberOfCrews");
|
|
9040
|
+
const crewsCodes = watch("Crews");
|
|
9041
|
+
const rotationPattern = watch("PatternDays");
|
|
9042
|
+
const crewRotation = watch("CrewRotation");
|
|
9043
|
+
const comments = watch("Comments");
|
|
9044
|
+
const maxCrewRotationLength = shiftsPerDay * rotationPattern;
|
|
9045
|
+
useEffect(() => {
|
|
9046
|
+
if (show) {
|
|
9047
|
+
reset();
|
|
9048
|
+
setValue("PatternStart", new Date());
|
|
9049
|
+
}
|
|
9050
|
+
}, [show]);
|
|
9051
|
+
return (React.createElement(React.Fragment, null,
|
|
9052
|
+
show && (React.createElement(HelmetDexteel, { title: `New Shift/Crew${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
9053
|
+
React.createElement(MesfModal, { title: "NEW SHIFT/CREW", open: show, handleClose: () => onHide(false), id: "create-shift-modal", maxWidth: "md" },
|
|
9054
|
+
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
9055
|
+
React.createElement(MesfModal.Content, null,
|
|
9056
|
+
React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
|
|
9057
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9058
|
+
React.createElement(TextField, { label: "Asset", value: assetName, disabled: true, fullWidth: true, variant: "outlined", margin: "dense" })),
|
|
9059
|
+
React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
9060
|
+
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9061
|
+
React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
|
|
9062
|
+
minWidth: "100%",
|
|
9063
|
+
borderTopLeftRadius: 3,
|
|
9064
|
+
borderTopRightRadius: 3,
|
|
9065
|
+
}, label: "Start", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
9066
|
+
textField: {
|
|
9067
|
+
fullWidth: true,
|
|
9068
|
+
variant: "standard",
|
|
9069
|
+
},
|
|
9070
|
+
} })),
|
|
9071
|
+
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9072
|
+
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
9073
|
+
textField: {
|
|
9074
|
+
fullWidth: true,
|
|
9075
|
+
variant: "standard",
|
|
9076
|
+
},
|
|
9077
|
+
} })))) }),
|
|
9078
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9079
|
+
React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
|
|
9080
|
+
min: 1,
|
|
9081
|
+
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${shiftsPerDay > 1 ? "Shifts" : "Shift"} per day`, variant: "outlined", error: !!errors.ShiftsPerDay, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: value, onChange: (evt) => parseInt(evt.target.value) >= 1 &&
|
|
9082
|
+
parseInt(evt.target.value) <= 10 &&
|
|
9083
|
+
onChange(evt) })) }),
|
|
9084
|
+
((_a = errors.ShiftsPerDay) === null || _a === void 0 ? void 0 : _a.type) === "min" && (React.createElement(ErrorLabel, { text: "Shift per day is required" }))),
|
|
9085
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9086
|
+
React.createElement(Controller, { name: "ShiftCodes", control: control, rules: {
|
|
9087
|
+
validate: (value) => value.length == shiftsPerDay,
|
|
9088
|
+
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: "Shifts Ids", variant: "outlined", error: !!errors.ShiftCodes, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
9089
|
+
// TODO: aquí podriamos hacer que no pueda haber dos valores iguales, para prevenir errores. Ej. dos DNN
|
|
9090
|
+
if (evt.target.value.length <= shiftsPerDay)
|
|
9091
|
+
onChange(evt.target.value.toString().toUpperCase());
|
|
9092
|
+
} })) }),
|
|
9093
|
+
!!errors.ShiftCodes && (React.createElement("span", { style: {
|
|
9094
|
+
fontSize: 12,
|
|
9095
|
+
} },
|
|
9096
|
+
"Please put ",
|
|
9097
|
+
shiftsPerDay,
|
|
9098
|
+
" shifts")),
|
|
9099
|
+
shiftCodes.length < shiftsPerDay &&
|
|
9100
|
+
!!errors.ShiftCodes === false && (React.createElement("span", { style: {
|
|
9101
|
+
fontSize: 12,
|
|
9102
|
+
color: theme.palette.info.main,
|
|
9103
|
+
} }, `Insert: ${shiftsPerDay} ${shiftsPerDay == 1 ? "Id" : "Ids"}. ${shiftsPerDay > 1 ? "The Ids must be differents" : ""}`))),
|
|
9104
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9105
|
+
React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
|
|
9106
|
+
min: 1,
|
|
9107
|
+
max: 9,
|
|
9108
|
+
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${numberOfCrews > 1 ? "Crews" : "Crew"}`, variant: "outlined", error: !!errors.NumberOfCrews, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", onChange: (evt) => {
|
|
9109
|
+
// max. crew 15
|
|
9110
|
+
if (parseInt(evt.target.value) >= 1 &&
|
|
9111
|
+
parseInt(evt.target.value) <= 15)
|
|
9112
|
+
onChange(evt);
|
|
9113
|
+
}, value: value })) }),
|
|
9114
|
+
((_b = errors.NumberOfCrews) === null || _b === void 0 ? void 0 : _b.type) === "min" && (React.createElement(ErrorLabel, { text: "# Crews days is required" }))),
|
|
9115
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9116
|
+
React.createElement(Controller, { name: "Crews", control: control, rules: {
|
|
9117
|
+
validate: (value) => value.length == numberOfCrews,
|
|
9118
|
+
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: "Crews Ids", variant: "outlined", error: !!errors.Crews, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
9119
|
+
if (evt.target.value.length <= numberOfCrews)
|
|
9120
|
+
onChange(evt.target.value.toString().toUpperCase());
|
|
9121
|
+
} })) }),
|
|
9122
|
+
!!errors.Crews && (React.createElement("span", { style: {
|
|
9123
|
+
fontSize: 12,
|
|
9124
|
+
} },
|
|
9125
|
+
"Please put ",
|
|
9126
|
+
numberOfCrews,
|
|
9127
|
+
" crews")),
|
|
9128
|
+
crewsCodes.length < numberOfCrews &&
|
|
9129
|
+
!!errors.Crews === false && (React.createElement("span", { style: {
|
|
9130
|
+
fontSize: 12,
|
|
9131
|
+
color: theme.palette.info.main,
|
|
9132
|
+
} }, `Insert: ${numberOfCrews} ${numberOfCrews == 1 ? "Crew" : "Crews"}. ${numberOfCrews > 1 ? "The Crews must be differents" : ""}`))),
|
|
9133
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9134
|
+
React.createElement(Controller, { name: "PatternDays", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { label: "Rotation Pattern", variant: "outlined", error: !!errors.PatternDays, fullWidth: true, type: "number", margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
9135
|
+
if (parseInt(evt.target.value) >= 5 &&
|
|
9136
|
+
parseInt(evt.target.value) <= 60)
|
|
9137
|
+
onChange(evt);
|
|
9138
|
+
} })) })),
|
|
9139
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9140
|
+
React.createElement(Controller, { name: "CrewRotation", control: control, rules: {
|
|
9141
|
+
validate: (value) => value.length == maxCrewRotationLength,
|
|
9142
|
+
}, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { value: value, onChange: (evt) => {
|
|
9143
|
+
if (evt.target.value.length <= maxCrewRotationLength)
|
|
9144
|
+
onChange(evt.target.value.toString().toUpperCase());
|
|
9145
|
+
}, label: "Crew rotation", variant: "outlined", fullWidth: true, error: !!errors.CrewRotation, margin: "dense", autoComplete: "off" })) }),
|
|
9146
|
+
React.createElement(Grid2, { container: true, height: 2 },
|
|
9147
|
+
React.createElement(Grid2, { style: {
|
|
9148
|
+
height: 2,
|
|
9149
|
+
width: `${calculatePercentage()}% `,
|
|
9150
|
+
backgroundColor: `${crewRotation.length == maxCrewRotationLength
|
|
9151
|
+
? "#4CAF50"
|
|
9152
|
+
: "#F44336"}`,
|
|
9153
|
+
transition: " 0.2s ease",
|
|
9154
|
+
margin: "0 5px",
|
|
9155
|
+
} })),
|
|
9156
|
+
React.createElement(Grid2, { container: true, style: { margin: "4px 0 0" } },
|
|
9157
|
+
React.createElement(Grid2, null, (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) >= 1 &&
|
|
9158
|
+
(crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) !==
|
|
9159
|
+
maxCrewRotationLength && (React.createElement("span", { style: {
|
|
9160
|
+
fontSize: 12,
|
|
9161
|
+
color: theme.palette.info.main,
|
|
9162
|
+
marginLeft: 5,
|
|
9163
|
+
} }, `${crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length}/${maxCrewRotationLength}`)))),
|
|
9164
|
+
!!errors.CrewRotation && (React.createElement(ErrorLabel, { text: `Please put ${maxCrewRotationLength} crews` })),
|
|
9165
|
+
numberOfCrews > 0 &&
|
|
9166
|
+
Number.isInteger(maxCrewRotationLength / numberOfCrews) ===
|
|
9167
|
+
false && (React.createElement(Grid2, { container: true, style: { padding: "0", marginLeft: 5 } },
|
|
9168
|
+
React.createElement(ErrorLabel, { text: `Rotation # not a multiple of Shifts (${maxCrewRotationLength}) / Crews (${numberOfCrews})` })))),
|
|
9169
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9170
|
+
React.createElement(Controller, { name: "Comments", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { style: { margin: "8px 0" }, size: "medium", maxRows: 5, label: "Comments", multiline: true, variant: "outlined", fullWidth: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
9171
|
+
if (evt.target.value.length <= 200)
|
|
9172
|
+
onChange(evt);
|
|
9173
|
+
} })) }),
|
|
9174
|
+
React.createElement(Grid2, { container: true, style: { marginBottom: 18 } },
|
|
9175
|
+
React.createElement(Grid2, null,
|
|
9176
|
+
(comments === null || comments === void 0 ? void 0 : comments.length) >= 1 &&
|
|
9177
|
+
(comments === null || comments === void 0 ? void 0 : comments.length) !== 200 && (React.createElement("span", { style: {
|
|
9178
|
+
fontSize: 12,
|
|
9179
|
+
color: theme.palette.info.main,
|
|
9180
|
+
marginLeft: 5,
|
|
9181
|
+
} }, `${comments === null || comments === void 0 ? void 0 : comments.length}/200 max.`)),
|
|
9182
|
+
(comments === null || comments === void 0 ? void 0 : comments.length) == 200 && (React.createElement("span", { style: {
|
|
9183
|
+
fontSize: 12,
|
|
9184
|
+
color: theme.palette.info.main,
|
|
9185
|
+
marginLeft: 5,
|
|
9186
|
+
} }, "Max. 200"))))))),
|
|
9187
|
+
React.createElement(MesfModal.Actions, null,
|
|
9188
|
+
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
9189
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9190
|
+
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
9191
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9192
|
+
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))),
|
|
9193
|
+
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error Creating Shift" }),
|
|
9194
|
+
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
9195
|
+
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The shift was created successfully"))));
|
|
9196
|
+
};
|
|
9197
|
+
|
|
9198
|
+
const DeleteShift = ({ shiftSelected, show, onHide, suffixTitle, assetId, assetName, }) => {
|
|
9199
|
+
var _a;
|
|
9200
|
+
const [open, setOpen] = useState(false);
|
|
9201
|
+
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
9202
|
+
const [deleteAlert, setDeleteAlert] = useState(false);
|
|
9203
|
+
const [error, setError] = useState("");
|
|
9204
|
+
const { control, setValue, reset, watch, formState: { errors }, } = useForm({ defaultValues: INITIAL_VALUES });
|
|
9205
|
+
const deleteShift = useMutation({
|
|
9206
|
+
mutationFn: (patternStart) => deleteShiftParameters(assetId, patternStart),
|
|
9207
|
+
onSuccess: () => {
|
|
9208
|
+
setOpen(true);
|
|
9209
|
+
onHide(true);
|
|
9210
|
+
},
|
|
9211
|
+
onError: (error) => {
|
|
9212
|
+
setError(error.message);
|
|
9213
|
+
},
|
|
9214
|
+
onSettled: () => {
|
|
9215
|
+
setIsSubmitLoading(false);
|
|
9216
|
+
setDeleteAlert(false);
|
|
9217
|
+
},
|
|
9218
|
+
});
|
|
9219
|
+
const onDelete = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9220
|
+
setIsSubmitLoading(true);
|
|
9221
|
+
yield deleteShift.mutate(data);
|
|
9222
|
+
});
|
|
9223
|
+
const handleClose = (event, reason) => {
|
|
9224
|
+
if (reason === "clickaway") {
|
|
9225
|
+
return;
|
|
9226
|
+
}
|
|
9227
|
+
setOpen(false);
|
|
9228
|
+
setDeleteAlert(false);
|
|
9229
|
+
};
|
|
9230
|
+
const patternStart = watch("PatternStart");
|
|
9231
|
+
const shiftsPerDay = watch("ShiftsPerDay");
|
|
9232
|
+
const crewRotation = watch("CrewRotation");
|
|
9233
|
+
const numberOfCrews = watch("NumberOfCrews");
|
|
9234
|
+
const crewsCodes = watch("Crews");
|
|
9235
|
+
const rotationPattern = watch("PatternDays");
|
|
9236
|
+
useEffect(() => {
|
|
9237
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9238
|
+
if (show) {
|
|
9239
|
+
reset();
|
|
9240
|
+
setValue("PatternStart", (_a = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) !== null && _a !== void 0 ? _a : new Date());
|
|
9241
|
+
setValue("ShiftCodes", (_b = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.ShiftCodes) !== null && _b !== void 0 ? _b : "");
|
|
9242
|
+
setValue("Crews", (_c = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Crews) !== null && _c !== void 0 ? _c : "");
|
|
9243
|
+
setValue("PatternDays", (_d = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternDays) !== null && _d !== void 0 ? _d : 0);
|
|
9244
|
+
setValue("CrewRotation", (_e = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.CrewRotation) !== null && _e !== void 0 ? _e : "");
|
|
9245
|
+
setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
|
|
9246
|
+
}
|
|
9247
|
+
}, [show]);
|
|
9248
|
+
return (React.createElement(React.Fragment, null,
|
|
9249
|
+
show && (React.createElement(HelmetDexteel, { title: `Delete Shift${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
9250
|
+
React.createElement(MesfModal, { title: "DELETE SHIFT", open: show, handleClose: () => onHide(false), id: "delete-shift-MesfModal", maxWidth: "md" },
|
|
9251
|
+
React.createElement("form", null,
|
|
9252
|
+
React.createElement(MesfModal.Content, null,
|
|
9253
|
+
React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
|
|
9254
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9255
|
+
React.createElement(TextField, { label: "Asset", value: assetName, disabled: true, fullWidth: true, variant: "outlined", margin: "dense" })),
|
|
9256
|
+
React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
9257
|
+
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9258
|
+
React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
|
|
9259
|
+
minWidth: "100%",
|
|
9260
|
+
borderTopLeftRadius: 3,
|
|
9261
|
+
borderTopRightRadius: 3,
|
|
9262
|
+
}, label: "Start", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
9263
|
+
textField: {
|
|
9264
|
+
fullWidth: true,
|
|
9265
|
+
variant: "standard",
|
|
9266
|
+
disabled: true,
|
|
9267
|
+
},
|
|
9268
|
+
} })),
|
|
9269
|
+
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9270
|
+
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
9271
|
+
textField: {
|
|
9272
|
+
fullWidth: true,
|
|
9273
|
+
variant: "standard",
|
|
9274
|
+
disabled: true,
|
|
9275
|
+
},
|
|
9276
|
+
} })))) }),
|
|
9277
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9278
|
+
React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
|
|
9279
|
+
min: 1,
|
|
9280
|
+
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${shiftsPerDay > 1 ? "Shifts" : "Shift"} per day`, variant: "outlined", error: !!errors.ShiftsPerDay, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: crewRotation.length / rotationPattern, disabled: !!shiftSelected })) }),
|
|
9281
|
+
((_a = errors.ShiftsPerDay) === null || _a === void 0 ? void 0 : _a.type) === "min" && (React.createElement(ErrorLabel, { text: "Shift per day is required" }))),
|
|
9282
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 }, style: { paddingBottom: "0" } },
|
|
9283
|
+
React.createElement(Controller, { name: "ShiftCodes", control: control, render: ({ field: { value } }) => (React.createElement(TextField, { label: "Shifts Ids", variant: "outlined", error: !!errors.ShiftCodes, fullWidth: true, margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
9284
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9285
|
+
React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
|
|
9286
|
+
min: 1,
|
|
9287
|
+
max: 9,
|
|
9288
|
+
}, render: ({ field: { value } }) => (React.createElement(TextField, { label: `# ${numberOfCrews > 1 ? "Crews" : "Crew"}`, variant: "outlined", error: !!errors.NumberOfCrews, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: crewsCodes.length, disabled: !!shiftSelected })) })),
|
|
9289
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 }, style: { paddingBottom: "0" } },
|
|
9290
|
+
React.createElement(Controller, { name: "Crews", control: control, render: ({ field: { value } }) => (React.createElement(TextField, { label: "Crews Ids", variant: "outlined", error: !!errors.Crews, fullWidth: true, margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
9291
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9292
|
+
React.createElement(Controller, { name: "PatternDays", control: control, render: ({ field: { value } }) => (React.createElement(TextField, { label: "Rotation Pattern", variant: "outlined", error: !!errors.PatternDays, fullWidth: true, type: "number", margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
9293
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9294
|
+
React.createElement(Controller, { name: "CrewRotation", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { label: "Crew rotation", variant: "outlined", fullWidth: true, margin: "dense", autoComplete: "off", value: value, disabled: !!shiftSelected })) })),
|
|
9295
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9296
|
+
React.createElement(Controller, { name: "Comments", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { style: { margin: "8px 0" }, size: "medium", maxRows: 5, label: "Comments", multiline: true, variant: "outlined", fullWidth: true, autoComplete: "off", value: value, disabled: !!shiftSelected })) })))),
|
|
9297
|
+
React.createElement(MesfModal.Actions, null,
|
|
9298
|
+
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
9299
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
|
|
9300
|
+
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
9301
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
|
|
9302
|
+
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading
|
|
9303
|
+
? isSubmitLoading
|
|
9304
|
+
: shiftSelected
|
|
9305
|
+
? new Date(shiftSelected.PatternStart) < new Date() &&
|
|
9306
|
+
true
|
|
9307
|
+
: false, variant: "contained", color: "secondary", onClick: () => setDeleteAlert(true) }, "Delete"),
|
|
9308
|
+
shiftSelected &&
|
|
9309
|
+
new Date(shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) < new Date() && (React.createElement(Grid2, null,
|
|
9310
|
+
React.createElement(ErrorLabel, { text: "Can not delete before the current date" })))))),
|
|
9311
|
+
React.createElement(Dialog$1, { open: deleteAlert, onClose: () => handleClose(), "aria-labelledby": "responsive-dialog-title" },
|
|
9312
|
+
React.createElement(DialogTitle$1, { id: "responsive-dialog-title" }, "WARNING"),
|
|
9313
|
+
React.createElement(DialogContent$1, null,
|
|
9314
|
+
React.createElement(DialogContentText, { style: { padding: 0, margin: 0 } }, "Be careful, once deleted you will not be able to recover this shift, are you sure you want to delete it?")),
|
|
9315
|
+
React.createElement(DialogActions$1, { style: { padding: "16px 24px" } },
|
|
9316
|
+
React.createElement(Button, { onClick: () => setDeleteAlert(false), autoFocus: true, color: "inherit" }, "CANCEL"),
|
|
9317
|
+
React.createElement(Button, { startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), autoFocus: true, color: "secondary", onClick: () => onDelete(patternStart) }, "Delete"))))),
|
|
9318
|
+
React.createElement(ErrorModal, { error: error, onHide: () => setError("") }),
|
|
9319
|
+
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
9320
|
+
React.createElement(Alert$1, { severity: "warning", onClose: handleClose }, "The shift was deleted successfully"))));
|
|
9211
9321
|
};
|
|
9212
9322
|
|
|
9213
|
-
const
|
|
9214
|
-
const
|
|
9215
|
-
const
|
|
9216
|
-
|
|
9217
|
-
const
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9323
|
+
const EditShift = ({ shiftSelected, show, onHide, suffixTitle, assetId, assetName, }) => {
|
|
9324
|
+
const theme = useTheme();
|
|
9325
|
+
const [open, setOpen] = useState(false);
|
|
9326
|
+
const [error, setError] = useState("");
|
|
9327
|
+
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
9328
|
+
const [initialShiftPerDayAndCrewsNumber, setInitialShiftPerDayAndCrewsNumber,] = useState(false);
|
|
9329
|
+
const { control, setValue, handleSubmit, reset, watch, formState: { errors }, } = useForm({ defaultValues: INITIAL_VALUES });
|
|
9330
|
+
// Progress bar
|
|
9331
|
+
const calculatePercentage = () => ((crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) / maxCrewRotationLength) * 100;
|
|
9332
|
+
const createShift = useMutation({
|
|
9333
|
+
mutationFn: ({ shiftData, isUpdate, }) => upsertShiftParameters(shiftData, assetId, isUpdate),
|
|
9334
|
+
onSuccess: () => {
|
|
9335
|
+
setOpen(true);
|
|
9336
|
+
onHide(true);
|
|
9337
|
+
},
|
|
9338
|
+
onError: (error) => {
|
|
9339
|
+
setError(error.message);
|
|
9340
|
+
},
|
|
9341
|
+
onSettled: () => {
|
|
9342
|
+
setIsSubmitLoading(false);
|
|
9343
|
+
},
|
|
9344
|
+
});
|
|
9345
|
+
const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9346
|
+
setIsSubmitLoading(true);
|
|
9347
|
+
yield createShift.mutate({ shiftData: data, isUpdate: true });
|
|
9348
|
+
});
|
|
9349
|
+
const handleClose = (event, reason) => {
|
|
9350
|
+
if (reason === "clickaway") {
|
|
9351
|
+
return;
|
|
9352
|
+
}
|
|
9353
|
+
setOpen(false);
|
|
9354
|
+
};
|
|
9355
|
+
// const patternStart = watch('PatternStart');
|
|
9356
|
+
const shiftsPerDay = watch("ShiftsPerDay");
|
|
9357
|
+
const shiftCodes = watch("ShiftCodes");
|
|
9358
|
+
const numberOfCrews = watch("NumberOfCrews");
|
|
9359
|
+
const crewsCodes = watch("Crews");
|
|
9360
|
+
const rotationPattern = watch("PatternDays");
|
|
9361
|
+
const comments = watch("Comments");
|
|
9362
|
+
const crewRotation = watch("CrewRotation");
|
|
9363
|
+
const maxCrewRotationLength = shiftsPerDay * rotationPattern;
|
|
9364
|
+
useEffect(() => {
|
|
9365
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9366
|
+
if (show) {
|
|
9367
|
+
reset();
|
|
9368
|
+
setValue("PatternStart", (_a = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) !== null && _a !== void 0 ? _a : new Date());
|
|
9369
|
+
setValue("ShiftCodes", (_b = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.ShiftCodes) !== null && _b !== void 0 ? _b : "");
|
|
9370
|
+
setValue("Crews", (_c = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Crews) !== null && _c !== void 0 ? _c : "");
|
|
9371
|
+
setValue("PatternDays", (_d = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternDays) !== null && _d !== void 0 ? _d : 0);
|
|
9372
|
+
setValue("CrewRotation", (_e = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.CrewRotation) !== null && _e !== void 0 ? _e : "");
|
|
9373
|
+
setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
|
|
9374
|
+
setInitialShiftPerDayAndCrewsNumber(!initialShiftPerDayAndCrewsNumber);
|
|
9375
|
+
}
|
|
9376
|
+
}, [show]);
|
|
9377
|
+
useEffect(() => {
|
|
9378
|
+
setValue("ShiftsPerDay", crewRotation.length / rotationPattern);
|
|
9379
|
+
setValue("NumberOfCrews", crewsCodes.length);
|
|
9380
|
+
}, [initialShiftPerDayAndCrewsNumber]);
|
|
9381
|
+
return (React.createElement(React.Fragment, null,
|
|
9382
|
+
show && (React.createElement(HelmetDexteel, { title: `Edit Shift${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
9383
|
+
React.createElement(MesfModal, { title: "EDIT SHIFT", open: show, handleClose: () => onHide(false), id: "edit-shift-modal", maxWidth: "md" },
|
|
9384
|
+
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
9385
|
+
React.createElement(MesfModal.Content, null,
|
|
9386
|
+
React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
|
|
9387
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9388
|
+
React.createElement(TextField, { label: "Asset", value: assetName, disabled: true, fullWidth: true, variant: "outlined", margin: "dense" })),
|
|
9389
|
+
React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
9390
|
+
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9391
|
+
React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
|
|
9392
|
+
minWidth: "100%",
|
|
9393
|
+
borderTopLeftRadius: 3,
|
|
9394
|
+
borderTopRightRadius: 3,
|
|
9395
|
+
}, label: "Start", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
9396
|
+
textField: {
|
|
9397
|
+
fullWidth: true,
|
|
9398
|
+
variant: "standard",
|
|
9399
|
+
},
|
|
9400
|
+
} })),
|
|
9401
|
+
React.createElement(Grid2, { size: { md: 6, xs: 12 } },
|
|
9402
|
+
React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
|
|
9403
|
+
textField: {
|
|
9404
|
+
fullWidth: true,
|
|
9405
|
+
variant: "standard",
|
|
9406
|
+
},
|
|
9407
|
+
} })))) }),
|
|
9408
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9409
|
+
React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
|
|
9410
|
+
min: 1,
|
|
9411
|
+
}, render: ({ field: { onChange, value } }) => (React.createElement(TextField, { label: `# ${shiftsPerDay > 1 ? "Shifts" : "Shift"} per day`, variant: "outlined", error: !!errors.ShiftsPerDay, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: value, onChange:
|
|
9412
|
+
// FIXME: límite de 10?
|
|
9413
|
+
(evt) => parseInt(evt.target.value) >= 1 &&
|
|
9414
|
+
parseInt(evt.target.value) <= 10 &&
|
|
9415
|
+
onChange(evt) })) })),
|
|
9416
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9417
|
+
React.createElement(Controller, { name: "ShiftCodes", control: control, rules: {
|
|
9418
|
+
required: `Please put ${shiftsPerDay} shifts`,
|
|
9419
|
+
validate: (value) => value.length == shiftsPerDay,
|
|
9420
|
+
}, render: ({ field: { onChange, value }, fieldState: { error }, }) => (React.createElement(TextField, { label: "Shifts Ids", variant: "outlined", error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
9421
|
+
// TODO: aquí deberíamos prevenir, que no pueda haber dos valores iguales, . Ej. dos DNN
|
|
9422
|
+
if (evt.target.value.length <= shiftsPerDay)
|
|
9423
|
+
onChange(evt.target.value.toString().toUpperCase());
|
|
9424
|
+
} })) }),
|
|
9425
|
+
shiftCodes.length < shiftsPerDay &&
|
|
9426
|
+
!!errors.ShiftCodes === false && (React.createElement(ErrorLabel, { text: `Insert: ${shiftsPerDay} ${shiftsPerDay == 1 ? "Id" : "Ids"}. ${shiftsPerDay > 1 ? "The Ids must be differents" : ""}` }))),
|
|
9427
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9428
|
+
React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
|
|
9429
|
+
required: "# Crews day is required",
|
|
9430
|
+
min: 1,
|
|
9431
|
+
max: 9,
|
|
9432
|
+
}, render: ({ field: { onChange, value }, fieldState: { error }, }) => (React.createElement(TextField, { label: `# ${numberOfCrews > 1 ? "Crews" : "Crew"}`, variant: "outlined", error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, fullWidth: true, margin: "dense", autoComplete: "off", type: "number", value: value, onChange: (evt) => {
|
|
9433
|
+
if (parseInt(evt.target.value) >= 1 &&
|
|
9434
|
+
parseInt(evt.target.value) <= 9)
|
|
9435
|
+
onChange(evt);
|
|
9436
|
+
} })) })),
|
|
9437
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9438
|
+
React.createElement(Controller, { name: "Crews", control: control, rules: {
|
|
9439
|
+
required: `Please put ${numberOfCrews} crews`,
|
|
9440
|
+
validate: (value) => value.length == numberOfCrews,
|
|
9441
|
+
}, render: ({ field: { onChange, value }, fieldState: { error }, }) => (React.createElement(TextField, { label: "Crews Ids", variant: "outlined", error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, disabled: numberOfCrews <= 0, fullWidth: true, margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
9442
|
+
if (evt.target.value.length <= numberOfCrews)
|
|
9443
|
+
onChange(evt.target.value.toString().toUpperCase());
|
|
9444
|
+
} })) }),
|
|
9445
|
+
crewsCodes.length < numberOfCrews &&
|
|
9446
|
+
!!errors.Crews === false && (React.createElement(ErrorLabel, { text: `Insert: ${numberOfCrews} ${numberOfCrews == 1 ? "Crew" : "Crews"}. ${numberOfCrews > 1 ? "The Crews must be differents" : ""}` }))),
|
|
9447
|
+
React.createElement(Grid2, { size: { md: 6, xs: 6 } },
|
|
9448
|
+
React.createElement(Controller, { name: "PatternDays", control: control,
|
|
9449
|
+
// rules={{
|
|
9450
|
+
// required: true
|
|
9451
|
+
// }}
|
|
9452
|
+
render: ({ field: { value, onChange } }) => (React.createElement(TextField, { label: "Rotation Pattern", variant: "outlined", error: !!errors.PatternDays, fullWidth: true, type: "number", margin: "dense", autoComplete: "off", value: value, onChange: (evt) => {
|
|
9453
|
+
// FIXME: consultar si estos valores están bien, son los limites del sP
|
|
9454
|
+
if (parseInt(evt.target.value) >= 5 &&
|
|
9455
|
+
parseInt(evt.target.value) <= 60)
|
|
9456
|
+
onChange(evt);
|
|
9457
|
+
} })) })),
|
|
9458
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9459
|
+
React.createElement(Controller, { name: "CrewRotation", control: control, rules: {
|
|
9460
|
+
validate: (value) => value.length == maxCrewRotationLength,
|
|
9461
|
+
}, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { value: value, onChange: (evt) => {
|
|
9462
|
+
if (evt.target.value.length <= maxCrewRotationLength)
|
|
9463
|
+
onChange(evt.target.value.toString().toUpperCase());
|
|
9464
|
+
}, error: !!errors.CrewRotation, label: "Crew rotation", variant: "outlined", fullWidth: true, margin: "dense", autoComplete: "off" })) }),
|
|
9465
|
+
React.createElement(Grid2, { container: true, height: 2 },
|
|
9466
|
+
React.createElement(Grid2, { style: {
|
|
9467
|
+
height: 2,
|
|
9468
|
+
width: `${calculatePercentage()}% `,
|
|
9469
|
+
backgroundColor: `${crewRotation.length == maxCrewRotationLength
|
|
9470
|
+
? "#4CAF50"
|
|
9471
|
+
: "#F44336"}`,
|
|
9472
|
+
transition: " 0.2s ease",
|
|
9473
|
+
margin: "0 5px",
|
|
9474
|
+
} })),
|
|
9475
|
+
React.createElement(Grid2, { container: true },
|
|
9476
|
+
React.createElement(Grid2, null, (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) >= 1 &&
|
|
9477
|
+
(crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) !==
|
|
9478
|
+
maxCrewRotationLength && (React.createElement("span", { style: {
|
|
9479
|
+
fontSize: 12,
|
|
9480
|
+
color: theme.palette.info.main,
|
|
9481
|
+
marginLeft: 5,
|
|
9482
|
+
} }, `${crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length}/${maxCrewRotationLength}`)))),
|
|
9483
|
+
!!errors.CrewRotation && (React.createElement(ErrorLabel, { text: `Please put ${maxCrewRotationLength} crews` })),
|
|
9484
|
+
numberOfCrews > 0 &&
|
|
9485
|
+
Number.isInteger(maxCrewRotationLength / numberOfCrews) ===
|
|
9486
|
+
false && (React.createElement(Grid2, { container: true, style: { padding: "0", marginLeft: 5 } },
|
|
9487
|
+
React.createElement(ErrorLabel, { text: `Rotation # not a multiple of Shifts (${maxCrewRotationLength}) / Crews (${numberOfCrews})` })))),
|
|
9488
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9489
|
+
React.createElement(Controller, { name: "Comments", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { style: { margin: "8px 0" }, size: "medium", maxRows: 5, label: "Comments", multiline: true, variant: "outlined", fullWidth: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
9490
|
+
if (evt.target.value.length <= 200)
|
|
9491
|
+
onChange(evt);
|
|
9492
|
+
} })) }),
|
|
9493
|
+
React.createElement(Grid2, { container: true, style: { marginBottom: 18 } },
|
|
9494
|
+
React.createElement(Grid2, null,
|
|
9495
|
+
(comments === null || comments === void 0 ? void 0 : comments.length) >= 1 &&
|
|
9496
|
+
(comments === null || comments === void 0 ? void 0 : comments.length) !== 200 && (React.createElement("span", { style: {
|
|
9497
|
+
fontSize: 12,
|
|
9498
|
+
color: theme.palette.info.main,
|
|
9499
|
+
marginLeft: 5,
|
|
9500
|
+
} }, `${comments === null || comments === void 0 ? void 0 : comments.length}/200`)),
|
|
9501
|
+
(comments === null || comments === void 0 ? void 0 : comments.length) == 200 && (React.createElement("span", { style: {
|
|
9502
|
+
fontSize: 12,
|
|
9503
|
+
color: theme.palette.info.main,
|
|
9504
|
+
marginLeft: 5,
|
|
9505
|
+
} }, "Max. 200"))))))),
|
|
9506
|
+
React.createElement(MesfModal.Actions, null,
|
|
9507
|
+
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
9508
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
|
|
9509
|
+
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
9510
|
+
React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
|
|
9511
|
+
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))),
|
|
9512
|
+
React.createElement(ErrorModal, { error: error, onHide: () => setError("") }),
|
|
9513
|
+
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
9514
|
+
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The shift was created successfully"))));
|
|
9223
9515
|
};
|
|
9224
9516
|
|
|
9225
|
-
const
|
|
9517
|
+
const useShiftsOptionsFunctions = ({ setShiftId, setShowDeleteModal, setShowCreateModal, setShowEditModal, }) => {
|
|
9226
9518
|
const getMenuOptions = (data) => {
|
|
9227
9519
|
let options = [];
|
|
9228
9520
|
if (!data) {
|
|
9229
9521
|
options = options.concat([
|
|
9230
9522
|
{
|
|
9231
|
-
name: "New
|
|
9232
|
-
key: "
|
|
9523
|
+
name: "New Shift",
|
|
9524
|
+
key: "new_shift",
|
|
9233
9525
|
onClick: () => {
|
|
9234
9526
|
setShowCreateModal(true);
|
|
9235
9527
|
},
|
|
@@ -9240,27 +9532,27 @@ const useSettingsOptionsFunctions = ({ setSettingId, setShowDeleteModal, setShow
|
|
|
9240
9532
|
else {
|
|
9241
9533
|
options = options.concat([
|
|
9242
9534
|
{
|
|
9243
|
-
name: "New
|
|
9244
|
-
key: "
|
|
9535
|
+
name: "New Shift",
|
|
9536
|
+
key: "new_shift",
|
|
9245
9537
|
onClick: () => {
|
|
9246
9538
|
setShowCreateModal(true);
|
|
9247
9539
|
},
|
|
9248
9540
|
icon: React__default.createElement(PlaylistAddIcon, null),
|
|
9249
9541
|
},
|
|
9250
9542
|
{
|
|
9251
|
-
name: "Edit
|
|
9252
|
-
key: "
|
|
9543
|
+
name: "Edit Shift",
|
|
9544
|
+
key: "edit_shift",
|
|
9253
9545
|
onClick: () => {
|
|
9254
|
-
|
|
9546
|
+
setShiftId(data);
|
|
9255
9547
|
setShowEditModal(true);
|
|
9256
9548
|
},
|
|
9257
9549
|
icon: React__default.createElement(EditIcon, null),
|
|
9258
9550
|
},
|
|
9259
9551
|
{
|
|
9260
|
-
name: "Delete
|
|
9261
|
-
key: "
|
|
9552
|
+
name: "Delete Shift",
|
|
9553
|
+
key: "delete_shift",
|
|
9262
9554
|
onClick: () => {
|
|
9263
|
-
|
|
9555
|
+
setShiftId(data);
|
|
9264
9556
|
setShowDeleteModal(true);
|
|
9265
9557
|
},
|
|
9266
9558
|
icon: React__default.createElement(DeleteIcon, null),
|
|
@@ -9274,33 +9566,62 @@ const useSettingsOptionsFunctions = ({ setSettingId, setShowDeleteModal, setShow
|
|
|
9274
9566
|
};
|
|
9275
9567
|
};
|
|
9276
9568
|
|
|
9277
|
-
const useTableData$4 = ({
|
|
9569
|
+
const useTableData$4 = ({ setShiftSelected, setOpenModalEditShift, setOpenModalDeleteShift, showContextMenu, }) => {
|
|
9278
9570
|
const columnDefs = [
|
|
9279
9571
|
{
|
|
9280
|
-
field: "
|
|
9281
|
-
headerName: "
|
|
9572
|
+
field: "PatternStart",
|
|
9573
|
+
headerName: "Pattern Start",
|
|
9574
|
+
valueFormatter: ({ value }) => `${moment$f(value).format("L")}, ${moment$f(value).format("LTS")}`,
|
|
9282
9575
|
minWidth: 180,
|
|
9283
9576
|
flex: 4,
|
|
9577
|
+
cellStyle: {
|
|
9578
|
+
display: "flex",
|
|
9579
|
+
alignItems: "center",
|
|
9580
|
+
justifyContent: "center",
|
|
9581
|
+
},
|
|
9582
|
+
},
|
|
9583
|
+
{
|
|
9584
|
+
field: "ShiftCodes",
|
|
9585
|
+
headerName: "Shift Codes",
|
|
9586
|
+
minWidth: 150,
|
|
9587
|
+
flex: 2,
|
|
9588
|
+
cellStyle: {
|
|
9589
|
+
display: "flex",
|
|
9590
|
+
alignItems: "center",
|
|
9591
|
+
justifyContent: "center",
|
|
9592
|
+
},
|
|
9284
9593
|
},
|
|
9285
9594
|
{
|
|
9286
|
-
field: "
|
|
9287
|
-
headerName: "
|
|
9288
|
-
minWidth:
|
|
9595
|
+
field: "Crews",
|
|
9596
|
+
headerName: "Crews",
|
|
9597
|
+
minWidth: 150,
|
|
9289
9598
|
flex: 2,
|
|
9599
|
+
cellStyle: {
|
|
9600
|
+
display: "flex",
|
|
9601
|
+
alignItems: "center",
|
|
9602
|
+
justifyContent: "center",
|
|
9603
|
+
},
|
|
9290
9604
|
},
|
|
9291
9605
|
{
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9606
|
+
sortable: false,
|
|
9607
|
+
field: "PatternDays",
|
|
9608
|
+
headerName: "Shifts",
|
|
9609
|
+
minWidth: 130,
|
|
9610
|
+
flex: 1,
|
|
9611
|
+
cellStyle: {
|
|
9612
|
+
display: "flex",
|
|
9613
|
+
alignItems: "center",
|
|
9614
|
+
justifyContent: "center",
|
|
9615
|
+
},
|
|
9296
9616
|
},
|
|
9297
9617
|
{
|
|
9298
9618
|
cellRenderer: (params) => {
|
|
9299
|
-
return (React__default.createElement(Grid2, { container: true,
|
|
9619
|
+
return (React__default.createElement(Grid2, { container: true, style: {
|
|
9300
9620
|
height: "100%",
|
|
9301
9621
|
display: "flex",
|
|
9302
9622
|
justifyContent: "center",
|
|
9303
9623
|
alignItems: "center",
|
|
9624
|
+
}, sx: {
|
|
9304
9625
|
opacity: 0,
|
|
9305
9626
|
transition: "opacity 0.1s ease-in-out",
|
|
9306
9627
|
".ag-row-hover &": {
|
|
@@ -9315,329 +9636,101 @@ const useTableData$4 = ({ setOpenModalEditSetting, setOpenModalDeleteSetting, sh
|
|
|
9315
9636
|
} },
|
|
9316
9637
|
React__default.createElement(Grid2, { size: { xs: 12, md: 12 }, style: {
|
|
9317
9638
|
display: "flex",
|
|
9318
|
-
justifyContent: "
|
|
9639
|
+
justifyContent: "center",
|
|
9319
9640
|
alignItems: "center",
|
|
9320
9641
|
} },
|
|
9321
|
-
React__default.createElement(
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
} },
|
|
9325
|
-
React__default.createElement(EditIcon, { color: "primary" })),
|
|
9326
|
-
React__default.createElement(
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
} },
|
|
9330
|
-
React__default.createElement(DeleteIcon, { color: "secondary" })),
|
|
9331
|
-
React__default.createElement(
|
|
9332
|
-
React__default.createElement(FormatListBulletedSharpIcon, { color: "action" })))));
|
|
9333
|
-
},
|
|
9334
|
-
field: "",
|
|
9335
|
-
flex:
|
|
9336
|
-
minWidth: 240,
|
|
9337
|
-
editable: false,
|
|
9338
|
-
autoHeight: false,
|
|
9339
|
-
suppressNavigable: true,
|
|
9340
|
-
},
|
|
9341
|
-
];
|
|
9342
|
-
const defaultColDef = useMemo(() => {
|
|
9343
|
-
return {
|
|
9344
|
-
sortable: true,
|
|
9345
|
-
wrapText: true,
|
|
9346
|
-
autoHeight: true,
|
|
9347
|
-
wrapHeaderText: true,
|
|
9348
|
-
suppressHeaderMenuButton: true,
|
|
9349
|
-
cellStyle: {
|
|
9350
|
-
display: "flex",
|
|
9351
|
-
alignItems: "center",
|
|
9352
|
-
justifyContent: "center",
|
|
9353
|
-
},
|
|
9354
|
-
};
|
|
9355
|
-
}, []);
|
|
9356
|
-
return { columnDefs, defaultColDef };
|
|
9357
|
-
};
|
|
9358
|
-
|
|
9359
|
-
const INITIAL_VALUES = {
|
|
9360
|
-
SettingName: "",
|
|
9361
|
-
Value: "",
|
|
9362
|
-
Description: "",
|
|
9363
|
-
};
|
|
9364
|
-
|
|
9365
|
-
const upsertSettings = (_a) => __awaiter(void 0, [_a], void 0, function* ({ oldName, newName, description, value, }) {
|
|
9366
|
-
const apiService = new MESApiService();
|
|
9367
|
-
const parameters = [
|
|
9368
|
-
{ name: "OldName", value: oldName },
|
|
9369
|
-
{ name: "NewName", value: newName },
|
|
9370
|
-
{ name: "Description", value: description },
|
|
9371
|
-
{ name: "Value", value: value },
|
|
9372
|
-
];
|
|
9373
|
-
const resp = yield apiService.callV2("[UTL].[SetSetting]", parameters);
|
|
9374
|
-
if (!resp.ok) {
|
|
9375
|
-
throw new Error(resp.message || "Error when upsert setting");
|
|
9376
|
-
}
|
|
9377
|
-
});
|
|
9378
|
-
const deleteSetting = (settingName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9379
|
-
const apiService = new MESApiService();
|
|
9380
|
-
const parameters = [
|
|
9381
|
-
{ name: "SettingName", value: settingName },
|
|
9382
|
-
];
|
|
9383
|
-
const resp = yield apiService.callV2("[UTL].[DeleteSetting]", parameters);
|
|
9384
|
-
if (!resp.ok) {
|
|
9385
|
-
throw new Error(resp.message || "Error when delete setting");
|
|
9386
|
-
}
|
|
9387
|
-
});
|
|
9388
|
-
|
|
9389
|
-
const CreateSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
|
|
9390
|
-
const [open, setOpen] = useState(false);
|
|
9391
|
-
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
9392
|
-
const [error, setError] = useState("");
|
|
9393
|
-
const { control, handleSubmit, reset } = useForm({
|
|
9394
|
-
defaultValues: settingSelected ? settingSelected : INITIAL_VALUES,
|
|
9395
|
-
});
|
|
9396
|
-
const updateSetting = useMutation({
|
|
9397
|
-
mutationFn: upsertSettings,
|
|
9398
|
-
onSuccess: () => {
|
|
9399
|
-
setOpen(true);
|
|
9400
|
-
onHide(true);
|
|
9401
|
-
},
|
|
9402
|
-
onError: (error) => {
|
|
9403
|
-
setError(error.message);
|
|
9404
|
-
},
|
|
9405
|
-
onSettled: () => {
|
|
9406
|
-
setIsSubmitLoading(false);
|
|
9407
|
-
},
|
|
9408
|
-
});
|
|
9409
|
-
const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9410
|
-
setIsSubmitLoading(true);
|
|
9411
|
-
yield updateSetting.mutate({
|
|
9412
|
-
oldName: "",
|
|
9413
|
-
newName: data.SettingName,
|
|
9414
|
-
description: data.Description,
|
|
9415
|
-
value: data.Value,
|
|
9416
|
-
});
|
|
9417
|
-
});
|
|
9418
|
-
const handleClose = (event, reason) => {
|
|
9419
|
-
if (reason === "clickaway") {
|
|
9420
|
-
return;
|
|
9421
|
-
}
|
|
9422
|
-
setOpen(false);
|
|
9423
|
-
};
|
|
9424
|
-
useEffect(() => {
|
|
9425
|
-
if (show) {
|
|
9426
|
-
reset();
|
|
9427
|
-
}
|
|
9428
|
-
}, [show]);
|
|
9429
|
-
return (React.createElement(React.Fragment, null,
|
|
9430
|
-
show && (React.createElement(HelmetDexteel, { title: `New Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
9431
|
-
React.createElement(Grid2, { container: true },
|
|
9432
|
-
React.createElement(Grid2, null,
|
|
9433
|
-
React.createElement(MesfModal, { title: "NEW SETTING", open: show, handleClose: () => onHide(false), id: "create-setting-modal", maxWidth: "md" },
|
|
9434
|
-
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
9435
|
-
React.createElement(MesfModal.Content, null,
|
|
9436
|
-
React.createElement(Grid2, { container: true, spacing: 2 },
|
|
9437
|
-
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
9438
|
-
React.createElement(Controller, { name: "SettingName", control: control, rules: { required: "Name is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Name", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
9439
|
-
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
9440
|
-
React.createElement(Controller, { name: "Value", control: control, rules: {
|
|
9441
|
-
required: "Value is required",
|
|
9442
|
-
}, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Value", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
9443
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9444
|
-
React.createElement(Controller, { name: "Description", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { size: "medium", maxRows: 5, label: "Description", multiline: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
9445
|
-
if (evt.target.value.length <= 200)
|
|
9446
|
-
onChange(evt);
|
|
9447
|
-
} })) })))),
|
|
9448
|
-
React.createElement(MesfModal.Actions, null,
|
|
9449
|
-
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
9450
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9451
|
-
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
9452
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9453
|
-
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))))),
|
|
9454
|
-
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error Creating Setting" }),
|
|
9455
|
-
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
9456
|
-
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was created successfully"))));
|
|
9457
|
-
};
|
|
9458
|
-
|
|
9459
|
-
const DeleteSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
|
|
9460
|
-
const [open, setOpen] = useState(false);
|
|
9461
|
-
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
9462
|
-
const [error, setError] = useState("");
|
|
9463
|
-
const { control, handleSubmit, reset, setValue } = useForm({
|
|
9464
|
-
defaultValues: settingSelected ? settingSelected : INITIAL_VALUES,
|
|
9465
|
-
});
|
|
9466
|
-
const removeSetting = useMutation({
|
|
9467
|
-
mutationFn: deleteSetting,
|
|
9468
|
-
onSuccess: () => {
|
|
9469
|
-
setOpen(true);
|
|
9470
|
-
onHide(true);
|
|
9471
|
-
},
|
|
9472
|
-
onError: (error) => {
|
|
9473
|
-
setError(error.message);
|
|
9474
|
-
},
|
|
9475
|
-
onSettled: () => {
|
|
9476
|
-
setIsSubmitLoading(false);
|
|
9477
|
-
},
|
|
9478
|
-
});
|
|
9479
|
-
const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
9480
|
-
setIsSubmitLoading(true);
|
|
9481
|
-
yield removeSetting.mutate(data.SettingName);
|
|
9482
|
-
});
|
|
9483
|
-
const handleClose = (event, reason) => {
|
|
9484
|
-
if (reason === "clickaway") {
|
|
9485
|
-
return;
|
|
9486
|
-
}
|
|
9487
|
-
setOpen(false);
|
|
9488
|
-
};
|
|
9489
|
-
useEffect(() => {
|
|
9490
|
-
if (show) {
|
|
9491
|
-
reset();
|
|
9492
|
-
if (settingSelected) {
|
|
9493
|
-
setValue("SettingName", settingSelected.SettingName);
|
|
9494
|
-
setValue("Value", settingSelected.Value);
|
|
9495
|
-
setValue("Description", settingSelected.Description);
|
|
9496
|
-
}
|
|
9497
|
-
}
|
|
9498
|
-
}, [show]);
|
|
9499
|
-
return (React.createElement(React.Fragment, null,
|
|
9500
|
-
show && (React.createElement(HelmetDexteel, { title: `Delete Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
9501
|
-
React.createElement(Grid2, { container: true },
|
|
9502
|
-
React.createElement(Grid2, null,
|
|
9503
|
-
React.createElement(MesfModal, { title: "DELETE SETTING", open: show, handleClose: () => onHide(false), id: "delete-setting-modal", maxWidth: "md" },
|
|
9504
|
-
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
9505
|
-
React.createElement(MesfModal.Content, null,
|
|
9506
|
-
React.createElement(Grid2, { container: true, spacing: 2 },
|
|
9507
|
-
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
9508
|
-
React.createElement(Controller, { name: "SettingName", control: control, rules: { required: "Name is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({ disabled: true }, field, { label: "Name", variant: "outlined", error: !!error, helperText: error ? error.message : null, fullWidth: true, margin: "dense", autoComplete: "off" }))) })),
|
|
9509
|
-
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
9510
|
-
React.createElement(Controller, { name: "Value", control: control, rules: { required: "Value is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({ disabled: true }, field, { label: "Value", variant: "outlined", error: !!error, helperText: error ? error.message : null, fullWidth: true, margin: "dense", autoComplete: "off" }))) })),
|
|
9511
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9512
|
-
React.createElement(Controller, { name: "Description", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { disabled: true, size: "medium", maxRows: 5, label: "Description", multiline: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
9513
|
-
if (evt.target.value.length <= 200)
|
|
9514
|
-
onChange(evt);
|
|
9515
|
-
} })) })))),
|
|
9516
|
-
React.createElement(MesfModal.Actions, null,
|
|
9517
|
-
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
9518
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9519
|
-
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
9520
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9521
|
-
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "secondary", type: "submit" }, "Delete")))))))),
|
|
9522
|
-
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error deleting Setting" }),
|
|
9523
|
-
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
9524
|
-
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was deleted successfully"))));
|
|
9525
|
-
};
|
|
9526
|
-
|
|
9527
|
-
const EditSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
|
|
9528
|
-
const [open, setOpen] = useState(false);
|
|
9529
|
-
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
9530
|
-
const [error, setError] = useState("");
|
|
9531
|
-
const { control, handleSubmit, reset, setValue } = useForm({
|
|
9532
|
-
defaultValues: settingSelected ? settingSelected : INITIAL_VALUES,
|
|
9533
|
-
});
|
|
9534
|
-
const updateSetting = useMutation({
|
|
9535
|
-
mutationFn: upsertSettings,
|
|
9536
|
-
onSuccess: () => {
|
|
9537
|
-
setOpen(true);
|
|
9538
|
-
onHide(true);
|
|
9539
|
-
},
|
|
9540
|
-
onError: (error) => {
|
|
9541
|
-
setError(error.message);
|
|
9542
|
-
},
|
|
9543
|
-
onSettled: () => {
|
|
9544
|
-
setIsSubmitLoading(false);
|
|
9642
|
+
React__default.createElement(Button, { style: {}, onClick: () => {
|
|
9643
|
+
setShiftSelected(params === null || params === void 0 ? void 0 : params.data);
|
|
9644
|
+
setOpenModalEditShift(true);
|
|
9645
|
+
} },
|
|
9646
|
+
React__default.createElement(EditIcon, { color: "primary" })),
|
|
9647
|
+
React__default.createElement(Button, { style: {}, onClick: () => {
|
|
9648
|
+
setShiftSelected(params === null || params === void 0 ? void 0 : params.data);
|
|
9649
|
+
setOpenModalDeleteShift(true);
|
|
9650
|
+
} },
|
|
9651
|
+
React__default.createElement(DeleteIcon, { color: "secondary" })),
|
|
9652
|
+
React__default.createElement(Button, { style: {}, onClick: (e) => showContextMenu(e, params.data, "TableShifts") },
|
|
9653
|
+
React__default.createElement(FormatListBulletedSharpIcon, { color: "action" })))));
|
|
9654
|
+
},
|
|
9655
|
+
field: "",
|
|
9656
|
+
flex: 3,
|
|
9657
|
+
minWidth: 240,
|
|
9658
|
+
editable: false,
|
|
9659
|
+
autoHeight: false,
|
|
9660
|
+
suppressNavigable: true,
|
|
9545
9661
|
},
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
var _a;
|
|
9549
|
-
setIsSubmitLoading(true);
|
|
9550
|
-
yield updateSetting.mutate({
|
|
9551
|
-
oldName: (_a = settingSelected === null || settingSelected === void 0 ? void 0 : settingSelected.SettingName) !== null && _a !== void 0 ? _a : null,
|
|
9552
|
-
newName: data.SettingName,
|
|
9553
|
-
description: data.Description,
|
|
9554
|
-
value: data.Value,
|
|
9555
|
-
});
|
|
9556
|
-
});
|
|
9557
|
-
const handleClose = (event, reason) => {
|
|
9558
|
-
if (reason === "clickaway") {
|
|
9559
|
-
return;
|
|
9560
|
-
}
|
|
9561
|
-
setOpen(false);
|
|
9562
|
-
};
|
|
9563
|
-
useEffect(() => {
|
|
9564
|
-
if (show) {
|
|
9565
|
-
reset();
|
|
9566
|
-
if (settingSelected) {
|
|
9567
|
-
setValue("SettingName", settingSelected.SettingName);
|
|
9568
|
-
setValue("Value", settingSelected.Value);
|
|
9569
|
-
setValue("Description", settingSelected.Description);
|
|
9570
|
-
}
|
|
9571
|
-
}
|
|
9572
|
-
}, [show]);
|
|
9573
|
-
return (React.createElement(React.Fragment, null,
|
|
9574
|
-
show && (React.createElement(HelmetDexteel, { title: `Edit Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
|
|
9575
|
-
React.createElement(MesfModal, { title: "EDIT SETTING", open: show, handleClose: () => onHide(false), id: "edit-setting-modal", maxWidth: "md" },
|
|
9576
|
-
React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
9577
|
-
React.createElement(MesfModal.Content, null,
|
|
9578
|
-
React.createElement(Grid2, { container: true, spacing: 2 },
|
|
9579
|
-
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
9580
|
-
React.createElement(Controller, { name: "SettingName", control: control, rules: { required: "Name is required" }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Name", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
9581
|
-
React.createElement(Grid2, { size: { xs: 12, md: 6 } },
|
|
9582
|
-
React.createElement(Controller, { name: "Value", control: control, rules: {
|
|
9583
|
-
required: "Value is required",
|
|
9584
|
-
}, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Value", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
|
|
9585
|
-
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9586
|
-
React.createElement(Controller, { name: "Description", control: control, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { size: "medium", maxRows: 5, label: "Description", multiline: true, variant: "outlined", fullWidth: true, autoComplete: "off", value: value, onChange: (evt) => {
|
|
9587
|
-
if (evt.target.value.length <= 200)
|
|
9588
|
-
onChange(evt);
|
|
9589
|
-
} })) })))),
|
|
9590
|
-
React.createElement(MesfModal.Actions, null,
|
|
9591
|
-
React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
|
|
9592
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9593
|
-
React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
|
|
9594
|
-
React.createElement(Grid2, { size: { md: 3, xs: 12 } },
|
|
9595
|
-
React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))),
|
|
9596
|
-
React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error updating Setting" }),
|
|
9597
|
-
React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
|
|
9598
|
-
React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was edited successfully"))));
|
|
9662
|
+
];
|
|
9663
|
+
return { columnDefs };
|
|
9599
9664
|
};
|
|
9600
9665
|
|
|
9601
|
-
const
|
|
9666
|
+
const useSearchShifts = (assetId) => {
|
|
9602
9667
|
return useQuery({
|
|
9603
|
-
queryKey: ["
|
|
9604
|
-
queryFn: ({ signal }) =>
|
|
9668
|
+
queryKey: ["shifts", assetId],
|
|
9669
|
+
queryFn: ({ signal }) => getShiftParameters(assetId, signal),
|
|
9605
9670
|
});
|
|
9606
9671
|
};
|
|
9607
|
-
const
|
|
9608
|
-
const
|
|
9609
|
-
const { showContextMenu, registerConfig } = useContextMenuMESF();
|
|
9672
|
+
const TableShiftsCrews = () => {
|
|
9673
|
+
const gridRef = useRef(null);
|
|
9610
9674
|
const [error, setError] = useState("");
|
|
9611
|
-
const [gridApi, setGridApi] = useState(null);
|
|
9612
|
-
const [filterValue, setFilterValue] = useState("");
|
|
9613
|
-
const [settingSelected, setSettingSelected] = useState(null);
|
|
9614
9675
|
const [openModalNew, setOpenModalNew] = useState(false);
|
|
9615
|
-
const [
|
|
9616
|
-
const [
|
|
9617
|
-
const
|
|
9618
|
-
const {
|
|
9619
|
-
|
|
9620
|
-
|
|
9676
|
+
const [openModalEditShift, setOpenModalEditShift] = useState(false);
|
|
9677
|
+
const [openModalDeleteShift, setOpenModalDeleteShift] = useState(false);
|
|
9678
|
+
const [shiftSelected, setShiftSelected] = useState(null);
|
|
9679
|
+
const { state: { settings }, } = useUTLSettingsContext();
|
|
9680
|
+
const defaultAssetId = Number(get(settings, "DefaultAssetId", null));
|
|
9681
|
+
const [selectedAssetId, setSelectedAssetId] = useState(defaultAssetId || null);
|
|
9682
|
+
const { data: assets } = useSearchAssets();
|
|
9683
|
+
const assetsList = useMemo(() => { var _a; return (_a = assets === null || assets === void 0 ? void 0 : assets.filter((a) => a.CanBeDefaultAsset)) !== null && _a !== void 0 ? _a : []; }, [assets]);
|
|
9684
|
+
const selectedAssetName = useMemo(() => { var _a, _b; return (_b = (_a = assetsList.find((a) => a.AssetId === selectedAssetId)) === null || _a === void 0 ? void 0 : _a.AssetName) !== null && _b !== void 0 ? _b : ""; }, [assetsList, selectedAssetId]);
|
|
9685
|
+
const { data: rows, isLoading, isError, error: e, refetch, } = useSearchShifts(selectedAssetId);
|
|
9686
|
+
const formattedRows = rows === null || rows === void 0 ? void 0 : rows.map(({ PatternStart, ShiftCodes, Crews, PatternDays, CrewRotation, Comments, CanEdit, }) => ({
|
|
9687
|
+
id: ShiftCodes,
|
|
9688
|
+
PatternStart,
|
|
9689
|
+
ShiftCodes,
|
|
9690
|
+
Crews,
|
|
9691
|
+
PatternDays,
|
|
9692
|
+
CrewRotation,
|
|
9693
|
+
Comments,
|
|
9694
|
+
CanEdit,
|
|
9695
|
+
}));
|
|
9696
|
+
const defaultColDef = useMemo(() => {
|
|
9697
|
+
return {
|
|
9698
|
+
sortable: true,
|
|
9699
|
+
wrapText: true,
|
|
9700
|
+
autoHeight: true,
|
|
9701
|
+
wrapHeaderText: true,
|
|
9702
|
+
suppressHeaderMenuButton: true,
|
|
9703
|
+
cellStyle: {
|
|
9704
|
+
display: "flex",
|
|
9705
|
+
alignItems: "center",
|
|
9706
|
+
justifyContent: "center",
|
|
9707
|
+
},
|
|
9708
|
+
};
|
|
9709
|
+
}, []);
|
|
9710
|
+
const { getMenuOptions } = useShiftsOptionsFunctions({
|
|
9711
|
+
setShiftId: setShiftSelected,
|
|
9621
9712
|
setShowCreateModal: setOpenModalNew,
|
|
9622
|
-
|
|
9713
|
+
setShowDeleteModal: setOpenModalDeleteShift,
|
|
9714
|
+
setShowEditModal: setOpenModalEditShift,
|
|
9623
9715
|
});
|
|
9624
|
-
const {
|
|
9625
|
-
|
|
9626
|
-
|
|
9716
|
+
const { showContextMenu, registerConfig } = useContextMenuMESF();
|
|
9717
|
+
const { columnDefs } = useTableData$4({
|
|
9718
|
+
setShiftSelected,
|
|
9719
|
+
setOpenModalEditShift,
|
|
9720
|
+
setOpenModalDeleteShift,
|
|
9627
9721
|
showContextMenu,
|
|
9628
|
-
setSettingSelected,
|
|
9629
9722
|
});
|
|
9630
9723
|
const getContextMenuItems = (params) => {
|
|
9631
9724
|
var _a, _b;
|
|
9632
9725
|
const data = (_a = params.node) === null || _a === void 0 ? void 0 : _a.data;
|
|
9633
9726
|
params.api.deselectAll();
|
|
9634
9727
|
(_b = params.node) === null || _b === void 0 ? void 0 : _b.setSelected(true);
|
|
9635
|
-
showContextMenu(event, data, "
|
|
9728
|
+
showContextMenu(event, data, "TableShifts");
|
|
9636
9729
|
return [];
|
|
9637
9730
|
};
|
|
9638
9731
|
useEffect(() => {
|
|
9639
9732
|
registerConfig({
|
|
9640
|
-
id: "
|
|
9733
|
+
id: "TableShifts",
|
|
9641
9734
|
getOptions: getMenuOptions,
|
|
9642
9735
|
});
|
|
9643
9736
|
}, []);
|
|
@@ -9646,124 +9739,219 @@ const TableSettings = () => {
|
|
|
9646
9739
|
setError(e.message);
|
|
9647
9740
|
}
|
|
9648
9741
|
}, [e, isError]);
|
|
9649
|
-
return (
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
} })),
|
|
9664
|
-
React__default.createElement(Grid2, { container: true, size: { md: 12, xs: 12 } },
|
|
9665
|
-
React__default.createElement(Grid2, { size: { md: 12, xs: 12 }, style: {
|
|
9666
|
-
height: "70vh",
|
|
9667
|
-
} },
|
|
9668
|
-
React__default.createElement(Paper, { style: { height: "100%", width: "100%" } },
|
|
9669
|
-
React__default.createElement(AgGridReact, { loading: isLoading, gridOptions: {
|
|
9742
|
+
return (React.createElement(React.Fragment, null,
|
|
9743
|
+
React.createElement(Grid2, { container: true, justifyContent: "flex-start", p: 1, spacing: 1 },
|
|
9744
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9745
|
+
React.createElement(Typography$1, { variant: "h5", fontWeight: 600 }, "Shifts / Crew")),
|
|
9746
|
+
React.createElement(Grid2, { size: { md: 12, xs: 12 } },
|
|
9747
|
+
React.createElement(FormControl, { size: "small", sx: { minWidth: 200 } },
|
|
9748
|
+
React.createElement(InputLabel, null, "Asset"),
|
|
9749
|
+
React.createElement(Select, { value: selectedAssetId !== null && selectedAssetId !== void 0 ? selectedAssetId : "", onChange: (e) => setSelectedAssetId(Number(e.target.value)), label: "Asset" }, assetsList.map((asset) => (React.createElement(MenuItem, { key: asset.AssetId, value: asset.AssetId }, asset.AssetName)))))),
|
|
9750
|
+
React.createElement(Grid2, { container: true, justifyContent: "center", alignItems: "center" },
|
|
9751
|
+
React.createElement(Grid2, { container: true, size: { md: 12, xs: 12 } },
|
|
9752
|
+
React.createElement(Grid2, { component: Paper, size: { md: 12, xs: 12 }, style: {
|
|
9753
|
+
height: "70vh",
|
|
9754
|
+
} },
|
|
9755
|
+
React.createElement(AgGridReact, { loading: isLoading, gridOptions: {
|
|
9670
9756
|
theme: themeDXT,
|
|
9671
|
-
}, rowData:
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
}
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9757
|
+
}, ref: gridRef, rowData: formattedRows || [], columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 34, headerHeight: 34, animateRows: true, loadingOverlayComponent: CenteredLazyLoading, getContextMenuItems: (e) => getContextMenuItems(e), rowSelection: "single", onRowDoubleClicked: (event) => {
|
|
9758
|
+
setShiftSelected(event.data);
|
|
9759
|
+
setOpenModalEditShift(true);
|
|
9760
|
+
} })),
|
|
9761
|
+
React.createElement(Grid2, { container: true, justifyContent: "flex-end" },
|
|
9762
|
+
React.createElement(Grid2, { size: { md: 2, xs: 12 } },
|
|
9763
|
+
React.createElement(Button, { variant: "contained", color: "primary", onClick: () => setOpenModalNew(!openModalNew), fullWidth: true }, "NEW SHIFT")))))),
|
|
9764
|
+
React.createElement(CreateShift, { shiftSelected: shiftSelected, show: openModalNew, onHide: (shouldUpdate) => {
|
|
9679
9765
|
setOpenModalNew(false);
|
|
9680
9766
|
if (shouldUpdate)
|
|
9681
|
-
|
|
9682
|
-
}
|
|
9683
|
-
|
|
9684
|
-
|
|
9767
|
+
refetch();
|
|
9768
|
+
}, suffixTitle: "Shifts / Crew", assetId: selectedAssetId, assetName: selectedAssetName }),
|
|
9769
|
+
React.createElement(EditShift, { shiftSelected: shiftSelected, show: openModalEditShift, onHide: (shouldUpdate) => {
|
|
9770
|
+
setOpenModalEditShift(false);
|
|
9685
9771
|
if (shouldUpdate)
|
|
9686
|
-
|
|
9687
|
-
}
|
|
9688
|
-
|
|
9689
|
-
|
|
9772
|
+
refetch();
|
|
9773
|
+
}, suffixTitle: "Shifts / Crew", assetId: selectedAssetId, assetName: selectedAssetName }),
|
|
9774
|
+
React.createElement(DeleteShift, { shiftSelected: shiftSelected, show: openModalDeleteShift, onHide: (shouldUpdate) => {
|
|
9775
|
+
setOpenModalDeleteShift(false);
|
|
9690
9776
|
if (shouldUpdate)
|
|
9691
|
-
|
|
9692
|
-
}
|
|
9693
|
-
|
|
9777
|
+
refetch();
|
|
9778
|
+
}, suffixTitle: "Shifts / Crew", assetId: selectedAssetId, assetName: selectedAssetName })));
|
|
9779
|
+
};
|
|
9780
|
+
|
|
9781
|
+
const ShiftsCrews = () => {
|
|
9782
|
+
return (React.createElement(React.Fragment, null,
|
|
9783
|
+
React.createElement(HelmetDexteel, { title: "Shifts and Crews" }),
|
|
9784
|
+
React.createElement(TableShiftsCrews, null)));
|
|
9785
|
+
};
|
|
9786
|
+
|
|
9787
|
+
const ShiftsCrewsPage = (props) => {
|
|
9788
|
+
return React.createElement(ShiftsCrews, null);
|
|
9789
|
+
};
|
|
9790
|
+
|
|
9791
|
+
const AssetPage = () => {
|
|
9792
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
9793
|
+
React__default.createElement(DndProvider, { backend: HTML5Backend },
|
|
9794
|
+
React__default.createElement(TreeAsset, null))));
|
|
9795
|
+
};
|
|
9796
|
+
|
|
9797
|
+
const Asset = (props) => {
|
|
9798
|
+
return React.createElement(AssetPage, null);
|
|
9799
|
+
};
|
|
9800
|
+
|
|
9801
|
+
const UsersPage = (props) => {
|
|
9802
|
+
return React.createElement(Users, null);
|
|
9694
9803
|
};
|
|
9695
9804
|
|
|
9696
|
-
const
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9805
|
+
const CurrencyFormatter = new Intl.NumberFormat("en-US", {
|
|
9806
|
+
style: "currency",
|
|
9807
|
+
currency: "USD",
|
|
9808
|
+
});
|
|
9809
|
+
const NumberFormatter = new Intl.NumberFormat("en-US", {
|
|
9810
|
+
style: "currency",
|
|
9811
|
+
currency: "USD",
|
|
9812
|
+
});
|
|
9813
|
+
const IntegerFormatter = new Intl.NumberFormat("en-US", {});
|
|
9814
|
+
const DateTimeFormatter = new Intl.DateTimeFormat("en-US-u-hc-h23", {
|
|
9815
|
+
year: "numeric",
|
|
9816
|
+
month: "2-digit",
|
|
9817
|
+
day: "2-digit",
|
|
9818
|
+
hour: "numeric",
|
|
9819
|
+
minute: "numeric",
|
|
9820
|
+
second: "numeric",
|
|
9821
|
+
hour12: false,
|
|
9822
|
+
// timeZone: 'America/Los_Angeles'
|
|
9823
|
+
});
|
|
9824
|
+
const DateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
9825
|
+
year: "numeric",
|
|
9826
|
+
month: "2-digit",
|
|
9827
|
+
day: "2-digit",
|
|
9828
|
+
// timeZone: 'America/Los_Angeles'
|
|
9829
|
+
});
|
|
9830
|
+
const TimeFormatter = new Intl.DateTimeFormat("en-US-u-hc-h23", {
|
|
9831
|
+
hour: "2-digit",
|
|
9832
|
+
minute: "numeric",
|
|
9833
|
+
second: "numeric",
|
|
9834
|
+
hour12: false,
|
|
9835
|
+
// timeZone: 'America/Los_Angeles'
|
|
9836
|
+
});
|
|
9837
|
+
|
|
9838
|
+
const getShiftStyle = (shift) => {
|
|
9839
|
+
if (shift === "D") {
|
|
9840
|
+
return { color: "#52a8b7" };
|
|
9841
|
+
}
|
|
9842
|
+
else if (shift === "N") {
|
|
9843
|
+
return { color: "#A5A5A5" };
|
|
9844
|
+
}
|
|
9845
|
+
else {
|
|
9846
|
+
return {};
|
|
9847
|
+
}
|
|
9701
9848
|
};
|
|
9702
|
-
const
|
|
9849
|
+
const getCrewStyle = (crew) => {
|
|
9850
|
+
if (crew === "A") {
|
|
9851
|
+
return { color: "#0070C0" };
|
|
9852
|
+
}
|
|
9853
|
+
else if (crew === "B") {
|
|
9854
|
+
return { color: "#FFD24A" };
|
|
9855
|
+
}
|
|
9856
|
+
else if (crew === "C") {
|
|
9857
|
+
return { color: "#FD8359" };
|
|
9858
|
+
}
|
|
9859
|
+
else if (crew === "D") {
|
|
9860
|
+
return { color: "#00B050" };
|
|
9861
|
+
}
|
|
9862
|
+
else {
|
|
9863
|
+
return {};
|
|
9864
|
+
}
|
|
9865
|
+
};
|
|
9866
|
+
const GetShiftColor = (props) => {
|
|
9703
9867
|
return (React__default.createElement(React__default.Fragment, null,
|
|
9704
|
-
React__default.createElement(
|
|
9705
|
-
|
|
9868
|
+
React__default.createElement(Square$1, { sx: Object.assign({ mr: 1 }, getShiftStyle(props.value)), fontSize: "small" })));
|
|
9869
|
+
};
|
|
9870
|
+
const GetCrewColor = (props) => {
|
|
9871
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
9872
|
+
React__default.createElement(Square$1, { sx: Object.assign({ mr: 1 }, getCrewStyle(props.value)), fontSize: "small" })));
|
|
9706
9873
|
};
|
|
9707
9874
|
|
|
9708
|
-
const
|
|
9709
|
-
|
|
9710
|
-
|
|
9875
|
+
const AssetInitialState = {
|
|
9876
|
+
areasList: [],
|
|
9877
|
+
allAssets: [],
|
|
9878
|
+
plantAssetId: 1,
|
|
9711
9879
|
};
|
|
9712
|
-
const
|
|
9880
|
+
const AssetReducer = createSlice({
|
|
9713
9881
|
name: "__",
|
|
9714
|
-
initialState:
|
|
9882
|
+
initialState: AssetInitialState,
|
|
9715
9883
|
reducers: {
|
|
9716
|
-
|
|
9717
|
-
state.
|
|
9884
|
+
setAreasList(state, { payload }) {
|
|
9885
|
+
state.areasList = payload;
|
|
9718
9886
|
},
|
|
9719
|
-
|
|
9720
|
-
state.
|
|
9887
|
+
setAllAssets(state, { payload }) {
|
|
9888
|
+
state.allAssets = payload;
|
|
9721
9889
|
},
|
|
9722
|
-
|
|
9723
|
-
state.
|
|
9724
|
-
if (cur.SettingName.trim().toLowerCase() === "timezone") {
|
|
9725
|
-
const timeService = TimeService.getInstance();
|
|
9726
|
-
timeService.setTimeZone(cur.Value);
|
|
9727
|
-
}
|
|
9728
|
-
acc[cur.SettingName.trim()] = cur.Value;
|
|
9729
|
-
return acc;
|
|
9730
|
-
}, {});
|
|
9890
|
+
setPlantAssetId(state, { payload }) {
|
|
9891
|
+
state.plantAssetId = payload;
|
|
9731
9892
|
},
|
|
9732
9893
|
},
|
|
9733
9894
|
});
|
|
9734
9895
|
|
|
9735
|
-
const
|
|
9736
|
-
state:
|
|
9737
|
-
actions:
|
|
9738
|
-
isLoading: true,
|
|
9896
|
+
const AssetContext = createContext({
|
|
9897
|
+
state: AssetReducer.getInitialState(),
|
|
9898
|
+
actions: AssetReducer.actions,
|
|
9739
9899
|
});
|
|
9740
|
-
const
|
|
9741
|
-
const
|
|
9900
|
+
const useAssetContext = () => useContext(AssetContext);
|
|
9901
|
+
const AssetProvider = ({ children, plantAssetId = 1, }) => {
|
|
9742
9902
|
const [state, actions] = useComplexState({
|
|
9743
|
-
initialState:
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
useEffect(() => {
|
|
9748
|
-
if (isSuccess) {
|
|
9749
|
-
const settings = rows;
|
|
9750
|
-
const settingsTrimmed = settings.map((setting) => (Object.assign(Object.assign({}, setting), { SettingName: setting.SettingName.trim() })));
|
|
9751
|
-
actions.initSettings(settingsTrimmed);
|
|
9752
|
-
}
|
|
9753
|
-
}, [isSuccess]);
|
|
9754
|
-
useEffect(() => {
|
|
9755
|
-
if (e && isError) {
|
|
9756
|
-
console.error(e.message);
|
|
9757
|
-
}
|
|
9758
|
-
}, [e, isError]);
|
|
9759
|
-
useMesfRealtime({
|
|
9760
|
-
onReceiveMessage: (author, message) => {
|
|
9761
|
-
if (message === "UTL.GetSettings") {
|
|
9762
|
-
refetch();
|
|
9763
|
-
}
|
|
9903
|
+
initialState: {
|
|
9904
|
+
areasList: [],
|
|
9905
|
+
allAssets: [],
|
|
9906
|
+
plantAssetId,
|
|
9764
9907
|
},
|
|
9908
|
+
reducers: AssetReducer.caseReducers,
|
|
9765
9909
|
});
|
|
9766
|
-
return (React__default.createElement(
|
|
9910
|
+
return (React__default.createElement(AssetContext.Provider, { value: { state, actions } }, children));
|
|
9911
|
+
};
|
|
9912
|
+
|
|
9913
|
+
const LogbookSettingsInitialState = {
|
|
9914
|
+
entry: {
|
|
9915
|
+
withAssetFilter: undefined,
|
|
9916
|
+
filterAssets: undefined,
|
|
9917
|
+
canEditAsset: false,
|
|
9918
|
+
allowAttachments: false,
|
|
9919
|
+
canEditShift: false,
|
|
9920
|
+
showShiftCrew: false,
|
|
9921
|
+
exportToExcel: false,
|
|
9922
|
+
shiftsRange: 7,
|
|
9923
|
+
presetAssetId: undefined,
|
|
9924
|
+
},
|
|
9925
|
+
report: {
|
|
9926
|
+
withAssetFilter: undefined,
|
|
9927
|
+
filterAssets: undefined,
|
|
9928
|
+
showAttachments: false,
|
|
9929
|
+
showAsset: false,
|
|
9930
|
+
showShiftCrew: false,
|
|
9931
|
+
exportToExcel: false,
|
|
9932
|
+
},
|
|
9933
|
+
section: {
|
|
9934
|
+
schema: undefined,
|
|
9935
|
+
withAssetFilter: undefined,
|
|
9936
|
+
filterAssets: undefined,
|
|
9937
|
+
canEditAsset: false,
|
|
9938
|
+
allowAttachments: false,
|
|
9939
|
+
showShiftCrew: false,
|
|
9940
|
+
exportToExcel: false,
|
|
9941
|
+
topSectionsCount: 5,
|
|
9942
|
+
},
|
|
9943
|
+
};
|
|
9944
|
+
|
|
9945
|
+
const LogbookSettingsContext = createContext(LogbookSettingsInitialState);
|
|
9946
|
+
const useLogbookSettings = () => useContext(LogbookSettingsContext);
|
|
9947
|
+
const LogbookSettingsProvider = ({ children, logbookSettings = {}, }) => {
|
|
9948
|
+
// Merge default settings with provided settings
|
|
9949
|
+
const settings = useMemo(() => ({
|
|
9950
|
+
entry: Object.assign(Object.assign({}, LogbookSettingsInitialState.entry), (logbookSettings.entry || {})),
|
|
9951
|
+
report: Object.assign(Object.assign({}, LogbookSettingsInitialState.report), (logbookSettings.report || {})),
|
|
9952
|
+
section: Object.assign(Object.assign({}, LogbookSettingsInitialState.section), (logbookSettings.section || {})),
|
|
9953
|
+
}), [logbookSettings]);
|
|
9954
|
+
return (React__default.createElement(LogbookSettingsContext.Provider, { value: settings }, children));
|
|
9767
9955
|
};
|
|
9768
9956
|
|
|
9769
9957
|
const useFrontendVersionCheck = ({ endpoint = "/frontend/version", intervalMs = 60000, enabled = true, onUpdate, } = {}) => {
|
|
@@ -10264,9 +10452,9 @@ const QueryCacheInvalidations = () => {
|
|
|
10264
10452
|
React__default.createElement(MesfModal.Content, { dividers: true },
|
|
10265
10453
|
React__default.createElement(Grid2, { container: true, spacing: 3 },
|
|
10266
10454
|
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
10267
|
-
React__default.createElement(Controller, { control: control, name: "source", render: (params) => (React__default.createElement(Autocomplete
|
|
10455
|
+
React__default.createElement(Controller, { control: control, name: "source", render: (params) => (React__default.createElement(Autocomplete, { options: actions, getOptionLabel: (option) => `${option.ActionName}`, value: params.field.value, onChange: (_, value) => params.field.onChange(value), renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: "Select Source Action", variant: "outlined", size: "medium" }))), disabled: modal === "edit" })) })),
|
|
10268
10456
|
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
10269
|
-
React__default.createElement(Controller, { control: control, name: "targets", render: (params) => (React__default.createElement(Autocomplete
|
|
10457
|
+
React__default.createElement(Controller, { control: control, name: "targets", render: (params) => (React__default.createElement(Autocomplete, { multiple: true, options: actions.filter((a) => { var _a; return a.ActionId !== ((_a = control._formValues.source) === null || _a === void 0 ? void 0 : _a.ActionId); }), getOptionLabel: (option) => {
|
|
10270
10458
|
if (typeof option === "string") {
|
|
10271
10459
|
return option;
|
|
10272
10460
|
}
|
|
@@ -10565,7 +10753,7 @@ const ResultsList = ({ results, onDeleteResult, onClearAll }) => {
|
|
|
10565
10753
|
};
|
|
10566
10754
|
|
|
10567
10755
|
const SPAutocomplete = ({ procedures, value, onChange, isLoading, disabled = false, }) => {
|
|
10568
|
-
return (React__default.createElement(Autocomplete, { options: procedures, value: value, onChange: (_, newValue) => onChange(newValue), getOptionLabel: (option) => option.FullName, groupBy: (option) => option.SchemaName, disabled: disabled, isOptionEqualToValue: (option, val) => option.FullName === val.FullName, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: "Select Stored Procedure", variant: "outlined", fullWidth: true, slotProps: {
|
|
10756
|
+
return (React__default.createElement(Autocomplete$1, { options: procedures, value: value, onChange: (_, newValue) => onChange(newValue), getOptionLabel: (option) => option.FullName, groupBy: (option) => option.SchemaName, disabled: disabled, isOptionEqualToValue: (option, val) => option.FullName === val.FullName, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: "Select Stored Procedure", variant: "outlined", fullWidth: true, slotProps: {
|
|
10569
10757
|
input: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null, isLoading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 20 })) : (params.InputProps.endAdornment))) }),
|
|
10570
10758
|
} }))), renderOption: (props, option) => (React__default.createElement("li", Object.assign({}, props, { key: option.FullName }),
|
|
10571
10759
|
option.SchemaName,
|
|
@@ -11454,7 +11642,7 @@ const SaveUpdateDeleteViewModalV2 = ({ open, mode, handleClose, view, }) => {
|
|
|
11454
11642
|
React__default.createElement("form", { onSubmit: handleSubmit(onSubmit) },
|
|
11455
11643
|
React__default.createElement(MesfModal.Content, { dividers: true, style: { padding: "15px 30px" } },
|
|
11456
11644
|
React__default.createElement(Grid2, { container: true, spacing: 1 },
|
|
11457
|
-
React__default.createElement(Grid2, { size: 12 }, mode === "create" && views.length > 0 && viewSelected ? (React__default.createElement(Autocomplete, { size: "small", id: "list-of-views", options: views, defaultValue: viewSelected, getOptionLabel: (option) => {
|
|
11645
|
+
React__default.createElement(Grid2, { size: 12 }, mode === "create" && views.length > 0 && viewSelected ? (React__default.createElement(Autocomplete$1, { size: "small", id: "list-of-views", options: views, defaultValue: viewSelected, getOptionLabel: (option) => {
|
|
11458
11646
|
if (typeof option === "string") {
|
|
11459
11647
|
return option;
|
|
11460
11648
|
}
|
|
@@ -11884,7 +12072,7 @@ const HeaderSectionV2 = React__default.memo(({ autoRefresh, setAutoRefresh, setC
|
|
|
11884
12072
|
backgroundColor: "white",
|
|
11885
12073
|
width: "100%",
|
|
11886
12074
|
} },
|
|
11887
|
-
React__default.createElement(Autocomplete, { size: "small", id: "view-selector", options: views, getOptionLabel: (option) => option.ViewName, value: viewSelected, isOptionEqualToValue: (option, value) => option.ViewId === (value === null || value === void 0 ? void 0 : value.ViewId), onChange: handleViewChange, noOptionsText: "No views available", renderOption: (props, option) => (React__default.createElement(Box, Object.assign({}, props, { component: "li", style: {
|
|
12075
|
+
React__default.createElement(Autocomplete$1, { size: "small", id: "view-selector", options: views, getOptionLabel: (option) => option.ViewName, value: viewSelected, isOptionEqualToValue: (option, value) => option.ViewId === (value === null || value === void 0 ? void 0 : value.ViewId), onChange: handleViewChange, noOptionsText: "No views available", renderOption: (props, option) => (React__default.createElement(Box, Object.assign({}, props, { component: "li", style: {
|
|
11888
12076
|
display: "flex",
|
|
11889
12077
|
justifyContent: "space-between",
|
|
11890
12078
|
width: "100%",
|
|
@@ -12806,7 +12994,7 @@ const BitSelectorModal = ({ open, handleClose, viewTags, onAddBits, existingBitT
|
|
|
12806
12994
|
React__default.createElement(Grid2, { container: true, spacing: 2 },
|
|
12807
12995
|
React__default.createElement(Grid2, { size: 12 },
|
|
12808
12996
|
React__default.createElement(Typography$1, { variant: "subtitle2", sx: { mb: 1 } }, "Select Source Tag"),
|
|
12809
|
-
React__default.createElement(Autocomplete, { size: "small", id: "source-tag-selector", options: availableTags, getOptionLabel: (option) => option.Alias || option.TagName, value: selectedTag, onChange: handleTagChange, noOptionsText: "No tags available in current view", renderOption: (props, option) => (React__default.createElement(Box, Object.assign({}, props, { component: "li" }),
|
|
12997
|
+
React__default.createElement(Autocomplete$1, { size: "small", id: "source-tag-selector", options: availableTags, getOptionLabel: (option) => option.Alias || option.TagName, value: selectedTag, onChange: handleTagChange, noOptionsText: "No tags available in current view", renderOption: (props, option) => (React__default.createElement(Box, Object.assign({}, props, { component: "li" }),
|
|
12810
12998
|
React__default.createElement(Box, { sx: {
|
|
12811
12999
|
display: "flex",
|
|
12812
13000
|
justifyContent: "space-between",
|
|
@@ -12916,7 +13104,7 @@ const LoadViewModalV2 = ({ open, handleClose }) => {
|
|
|
12916
13104
|
React__default.createElement("input", { type: "checkbox", checked: allViewsChecked, onChange: handleAllViewsCheckbox }),
|
|
12917
13105
|
React__default.createElement(Typography$1, null, "All Views")))),
|
|
12918
13106
|
React__default.createElement(Grid2, { size: 12 },
|
|
12919
|
-
React__default.createElement(Autocomplete, { size: "small", id: "list-of-views", noOptionsText: allViewsChecked
|
|
13107
|
+
React__default.createElement(Autocomplete$1, { size: "small", id: "list-of-views", noOptionsText: allViewsChecked
|
|
12920
13108
|
? "No views detected, please create a new view"
|
|
12921
13109
|
: "No public views detected, please create a new view", options: displayedViews, getOptionLabel: (option) => option.ViewName, onChange: (ev, val) => setOptionSelected(val), defaultValue: optionSelected || viewSelected, style: { width: "100%" }, renderOption: (props, option) => (React__default.createElement(Box, Object.assign({}, props, { component: "li" }),
|
|
12922
13110
|
React__default.createElement(Box, { sx: {
|
|
@@ -15747,7 +15935,7 @@ const useGridDefinitions$1 = ({ OnEdit, OnSend }) => {
|
|
|
15747
15935
|
};
|
|
15748
15936
|
};
|
|
15749
15937
|
|
|
15750
|
-
const moment$
|
|
15938
|
+
const moment$c = getMomentTz();
|
|
15751
15939
|
const getEntries$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ shiftId, assetId, signal, }) {
|
|
15752
15940
|
const apiService = new MESApiService();
|
|
15753
15941
|
const parameters = [
|
|
@@ -15760,9 +15948,9 @@ const getEntries$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ shiftI
|
|
|
15760
15948
|
if (resp.ok) {
|
|
15761
15949
|
let rows = get(resp, "data.tables[0].rows", []);
|
|
15762
15950
|
rows = rows.map((entry) => (Object.assign(Object.assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
|
|
15763
|
-
? moment$
|
|
15951
|
+
? moment$c.utc(entry["CreateTimestamp"]).toDate()
|
|
15764
15952
|
: null, UpdateTimestamp: entry.UpdateTimestamp
|
|
15765
|
-
? moment$
|
|
15953
|
+
? moment$c.utc(entry["UpdateTimestamp"]).toDate()
|
|
15766
15954
|
: null })));
|
|
15767
15955
|
return rows;
|
|
15768
15956
|
}
|
|
@@ -15856,7 +16044,7 @@ const getEntryAttachments$1 = (params, signal) => __awaiter(void 0, void 0, void
|
|
|
15856
16044
|
if (resp.ok) {
|
|
15857
16045
|
let rows = get(resp, "data.tables[0].rows", []);
|
|
15858
16046
|
rows = rows.map((attachment) => (Object.assign(Object.assign({}, attachment), { CreationTime: attachment.CreationTime
|
|
15859
|
-
? moment$
|
|
16047
|
+
? moment$c.utc(attachment.CreationTime).toDate()
|
|
15860
16048
|
: new Date() })));
|
|
15861
16049
|
return rows;
|
|
15862
16050
|
}
|
|
@@ -15877,7 +16065,7 @@ const upsertEntryAttachment$1 = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
15877
16065
|
const attachment = get(resp, "data.tables[0].rows[0]", null);
|
|
15878
16066
|
if (attachment) {
|
|
15879
16067
|
return Object.assign(Object.assign({}, attachment), { CreationTime: attachment.CreationTime
|
|
15880
|
-
? moment$
|
|
16068
|
+
? moment$c.utc(attachment.CreationTime).toDate()
|
|
15881
16069
|
: new Date() });
|
|
15882
16070
|
}
|
|
15883
16071
|
return null;
|
|
@@ -16173,7 +16361,7 @@ const AssetsFilter = ({ label = "Asset", value, onChange, filterAreaAssets = fal
|
|
|
16173
16361
|
];
|
|
16174
16362
|
const selectedOption = options.find((option) => option.value === (value || null)) || options[0];
|
|
16175
16363
|
return (React__default.createElement(React__default.Fragment, null,
|
|
16176
|
-
React__default.createElement(Autocomplete, { size: "small", options: filterAreaAssets ? options.filter((o) => o.isAreaAsset) : options, value: selectedOption, onChange: (event, newValue) => {
|
|
16364
|
+
React__default.createElement(Autocomplete$1, { size: "small", options: filterAreaAssets ? options.filter((o) => o.isAreaAsset) : options, value: selectedOption, onChange: (event, newValue) => {
|
|
16177
16365
|
var _a;
|
|
16178
16366
|
if (newValue) {
|
|
16179
16367
|
onChange((_a = newValue.value) !== null && _a !== void 0 ? _a : null);
|
|
@@ -16182,124 +16370,6 @@ const AssetsFilter = ({ label = "Asset", value, onChange, filterAreaAssets = fal
|
|
|
16182
16370
|
React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
|
|
16183
16371
|
};
|
|
16184
16372
|
|
|
16185
|
-
const moment$d = getMomentTz();
|
|
16186
|
-
const getShifts = (params, signal) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16187
|
-
var _a;
|
|
16188
|
-
const apiService = new MESApiService();
|
|
16189
|
-
const parameters = [
|
|
16190
|
-
{
|
|
16191
|
-
name: "ShiftId",
|
|
16192
|
-
value: (_a = params.shiftId) !== null && _a !== void 0 ? _a : null,
|
|
16193
|
-
},
|
|
16194
|
-
];
|
|
16195
|
-
const resp = yield apiService.callV2(`[MES].[GetShiftByParameters]`, parameters, signal);
|
|
16196
|
-
if (resp.ok) {
|
|
16197
|
-
let rows = get(resp, "data.tables[0].rows", []);
|
|
16198
|
-
rows = rows.map((row) => {
|
|
16199
|
-
(row.CurrentProductionDate = moment$d
|
|
16200
|
-
.utc(row["CurrentProductionDate"])
|
|
16201
|
-
.toDate()),
|
|
16202
|
-
(row.CurrentStart = moment$d.utc(row["CurrentStart"]).toDate()),
|
|
16203
|
-
(row.CurrentEnd = moment$d.utc(row["CurrentEnd"]).toDate()),
|
|
16204
|
-
(row.PreviousProductionDate = moment$d
|
|
16205
|
-
.utc(row["PreviousProductionDate"])
|
|
16206
|
-
.toDate()),
|
|
16207
|
-
(row.PreviousStart = moment$d.utc(row["PreviousStart"]).toDate()),
|
|
16208
|
-
(row.PreviousEnd = moment$d.utc(row["PreviousEnd"]).toDate()),
|
|
16209
|
-
(row.NextProductionDate = moment$d
|
|
16210
|
-
.utc(row["NextProductionDate"])
|
|
16211
|
-
.toDate()),
|
|
16212
|
-
(row.NextStart = moment$d.utc(row["NextStart"]).toDate()),
|
|
16213
|
-
(row.NextEnd = moment$d.utc(row["NextEnd"]).toDate()),
|
|
16214
|
-
(row.LastProductionDate = moment$d
|
|
16215
|
-
.utc(row["LastProductionDate"])
|
|
16216
|
-
.toDate()),
|
|
16217
|
-
(row.LastStart = moment$d.utc(row["LastStart"]).toDate()),
|
|
16218
|
-
(row.LastEnd = moment$d.utc(row["LastEnd"]).toDate());
|
|
16219
|
-
return row;
|
|
16220
|
-
});
|
|
16221
|
-
return rows;
|
|
16222
|
-
}
|
|
16223
|
-
else {
|
|
16224
|
-
throw new Error(resp.message || "Error fetching shifts");
|
|
16225
|
-
}
|
|
16226
|
-
});
|
|
16227
|
-
const getShiftsAroundCurrent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ currentShiftId, shiftsRange, }) {
|
|
16228
|
-
const apiService = new MESApiService();
|
|
16229
|
-
const parameters = [
|
|
16230
|
-
{ name: "CurrentShiftId", value: currentShiftId || null },
|
|
16231
|
-
];
|
|
16232
|
-
if (shiftsRange) {
|
|
16233
|
-
parameters.push({ name: "ShiftsRange", value: shiftsRange });
|
|
16234
|
-
}
|
|
16235
|
-
const resp = yield apiService.callV2("[MES].[GetShiftsAroundCurrent]", parameters);
|
|
16236
|
-
if (resp.ok) {
|
|
16237
|
-
let rows = get(resp, "data.tables[0].rows", []);
|
|
16238
|
-
rows = rows.map((row) => (Object.assign(Object.assign({}, row), { Start: moment$d.utc(row.Start).toDate(), End: moment$d.utc(row.End).toDate() })));
|
|
16239
|
-
return rows;
|
|
16240
|
-
}
|
|
16241
|
-
else {
|
|
16242
|
-
throw new Error(resp.message || "Error fetching shifts");
|
|
16243
|
-
}
|
|
16244
|
-
});
|
|
16245
|
-
|
|
16246
|
-
const moment$c = getMomentTz();
|
|
16247
|
-
const useShiftsAroundCurrent = ({ currentShiftId, shiftsRange, }) => {
|
|
16248
|
-
return useQuery({
|
|
16249
|
-
queryKey: ["shiftsAroundCurrent", currentShiftId, shiftsRange],
|
|
16250
|
-
queryFn: ({ signal }) => getShiftsAroundCurrent({ currentShiftId, shiftsRange }),
|
|
16251
|
-
});
|
|
16252
|
-
};
|
|
16253
|
-
const ShiftAutocomplete = ({ currentShiftId, value, onShiftSelected, disabled, shiftsRange, }) => {
|
|
16254
|
-
const [error, setError] = useState("");
|
|
16255
|
-
const { data: rows, isLoading, error: e, isError, } = useShiftsAroundCurrent({
|
|
16256
|
-
currentShiftId,
|
|
16257
|
-
shiftsRange: shiftsRange,
|
|
16258
|
-
});
|
|
16259
|
-
const selectedShift = (rows === null || rows === void 0 ? void 0 : rows.find((type) => type.ShiftId === value)) || null;
|
|
16260
|
-
useEffect(() => {
|
|
16261
|
-
if (e && isError) {
|
|
16262
|
-
setError(e.message);
|
|
16263
|
-
}
|
|
16264
|
-
}, [e, isError]);
|
|
16265
|
-
return (React__default.createElement(React__default.Fragment, null,
|
|
16266
|
-
React__default.createElement(Grid2, { container: true },
|
|
16267
|
-
React__default.createElement(Grid2, { size: { xs: 12 } },
|
|
16268
|
-
React__default.createElement(Autocomplete$1, { loading: isLoading, options: rows || [], getOptionLabel: (option) => {
|
|
16269
|
-
return `${moment$c
|
|
16270
|
-
.utc(option.ProductionDate)
|
|
16271
|
-
.format("MM/DD/YYYY")} - ${option.Shift} - ${option.Crew}`;
|
|
16272
|
-
}, value: selectedShift, onChange: (event, newValue) => {
|
|
16273
|
-
if (newValue) {
|
|
16274
|
-
onShiftSelected(newValue);
|
|
16275
|
-
}
|
|
16276
|
-
}, disabled: disabled, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: "Shift", variant: "outlined", size: "small", fullWidth: true, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null, isLoading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 20 })) : null)) }) }))) }))),
|
|
16277
|
-
React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
|
|
16278
|
-
};
|
|
16279
|
-
|
|
16280
|
-
const useShifts = (shiftId) => {
|
|
16281
|
-
return useQuery({
|
|
16282
|
-
queryKey: ["shifts", shiftId],
|
|
16283
|
-
queryFn: ({ signal }) => getShifts({ shiftId }, signal),
|
|
16284
|
-
});
|
|
16285
|
-
};
|
|
16286
|
-
const ShiftSelector = ({ label = "Shift - Crew", value, onChange = () => { }, fieldError, disabled = false, }) => {
|
|
16287
|
-
const [error, setError] = useState("");
|
|
16288
|
-
const { data: shifts, isLoading, isError, error: e } = useShifts(value);
|
|
16289
|
-
const selectedShift = (shifts === null || shifts === void 0 ? void 0 : shifts.find((s) => s.CurrentShiftId === value)) || null;
|
|
16290
|
-
useEffect(() => {
|
|
16291
|
-
if (isError) {
|
|
16292
|
-
setError(e.message);
|
|
16293
|
-
}
|
|
16294
|
-
}, [isError, e]);
|
|
16295
|
-
return (React__default.createElement(React__default.Fragment, null,
|
|
16296
|
-
React__default.createElement(Autocomplete$1, { id: "clear-on-escape", clearOnEscape: true, options: shifts || [], getOptionLabel: (option) => `${option.CurrentShift} - ${option.CurrentCrew}`, disabled: disabled, renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: label, variant: "outlined", fullWidth: true, size: "small", error: !!fieldError, helperText: fieldError === null || fieldError === void 0 ? void 0 : fieldError.message, InputProps: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null, isLoading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 20 })) : (React__default.createElement(React__default.Fragment, null, params.InputProps.endAdornment)))) }) }))), value: selectedShift, onChange: (event, newValue) => {
|
|
16297
|
-
var _a;
|
|
16298
|
-
onChange((_a = newValue === null || newValue === void 0 ? void 0 : newValue.CurrentShiftId) !== null && _a !== void 0 ? _a : null);
|
|
16299
|
-
} }),
|
|
16300
|
-
React__default.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error loading shifts" })));
|
|
16301
|
-
};
|
|
16302
|
-
|
|
16303
16373
|
const useEntrySubmission$1 = ({ onSuccess, onError, isNewEntry = false, onHide = () => { }, } = {}) => {
|
|
16304
16374
|
const [isSubmitLoading, setIsSubmitLoading] = useState(false);
|
|
16305
16375
|
const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);
|
|
@@ -18533,7 +18603,7 @@ const SectionSelector = ({ value, onChange, topSectionsCount = 5, disabled = fal
|
|
|
18533
18603
|
gap: 1,
|
|
18534
18604
|
flexWrap: "wrap",
|
|
18535
18605
|
} },
|
|
18536
|
-
React__default.createElement(Autocomplete, { open: open, onOpen: () => setOpen(true), onClose: () => setOpen(false), value: value, onChange: (_, newValue) => onChange(newValue), inputValue: inputValue, onInputChange: (_, newInputValue) => setInputValue(newInputValue), options: options, loading: loading, disabled: disabled, getOptionLabel: (option) => option.SectionName, isOptionEqualToValue: (option, value) => option.SectionId === value.SectionId, sx: { minWidth: 120, maxWidth: 150 }, renderOption: (props, option) => (React__default.createElement(Box, Object.assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
|
|
18606
|
+
React__default.createElement(Autocomplete$1, { open: open, onOpen: () => setOpen(true), onClose: () => setOpen(false), value: value, onChange: (_, newValue) => onChange(newValue), inputValue: inputValue, onInputChange: (_, newInputValue) => setInputValue(newInputValue), options: options, loading: loading, disabled: disabled, getOptionLabel: (option) => option.SectionName, isOptionEqualToValue: (option, value) => option.SectionId === value.SectionId, sx: { minWidth: 120, maxWidth: 150 }, renderOption: (props, option) => (React__default.createElement(Box, Object.assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
|
|
18537
18607
|
React__default.createElement(Typography$1, { fontWeight: 500 }, option.SectionName))), renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: label, placeholder: "####", size: "small", slotProps: {
|
|
18538
18608
|
input: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
|
|
18539
18609
|
loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
|
|
@@ -18579,7 +18649,7 @@ const SectionMultiSelect = ({ value, onChange, topSectionsCount = 5, disabled =
|
|
|
18579
18649
|
gap: 1,
|
|
18580
18650
|
flexWrap: "wrap",
|
|
18581
18651
|
} },
|
|
18582
|
-
React__default.createElement(Autocomplete, { multiple: true, open: open, onOpen: () => setOpen(true), onClose: () => setOpen(false), value: value, onChange: (_, newValue) => onChange(newValue), inputValue: inputValue, onInputChange: (_, newInputValue) => setInputValue(newInputValue), options: options, loading: loading, disabled: disabled, getOptionLabel: (option) => option.SectionName, isOptionEqualToValue: (option, val) => option.SectionId === val.SectionId, limitTags: 2, size: "small", sx: { minWidth: 200, flex: 1 }, renderOption: (props, option) => (React__default.createElement(Box, Object.assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
|
|
18652
|
+
React__default.createElement(Autocomplete$1, { multiple: true, open: open, onOpen: () => setOpen(true), onClose: () => setOpen(false), value: value, onChange: (_, newValue) => onChange(newValue), inputValue: inputValue, onInputChange: (_, newInputValue) => setInputValue(newInputValue), options: options, loading: loading, disabled: disabled, getOptionLabel: (option) => option.SectionName, isOptionEqualToValue: (option, val) => option.SectionId === val.SectionId, limitTags: 2, size: "small", sx: { minWidth: 200, flex: 1 }, renderOption: (props, option) => (React__default.createElement(Box, Object.assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
|
|
18583
18653
|
React__default.createElement(Typography$1, { fontWeight: 500 }, option.SectionName))), renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: label, placeholder: value.length === 0 ? "All sections" : "", size: "small", slotProps: {
|
|
18584
18654
|
input: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
|
|
18585
18655
|
loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
|
|
@@ -20474,5 +20544,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
|
|
|
20474
20544
|
AreaSelector: AreaSelector
|
|
20475
20545
|
});
|
|
20476
20546
|
|
|
20477
|
-
export { Account, AssetProvider, AssetTreePicker, AuthContext, AuthProvider, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CreateNewAssetDialog, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ENTRY_INITIAL_VALUES$1 as ENTRY_INITIAL_VALUES, EditAssetDialog, ErrorModal, ExcelIcon, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HelmetDexteel, IntegerFormatter, LogbookSettingsInitialState, LogbookSettingsProvider, Login, Logout, LongFilterPanel, MESApiService, MESFLogbookEntry$1 as MESFLogbookEntry, MESFLogbookReport$1 as MESFLogbookReport, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NavbarMenuBar, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, USER_LABELS, UTLSettingsProvider, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getEntries$1 as getEntries, getError, getMomentTz, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUserPermissionsFromAPI, getUsers, logbookNavbar, logbookRoutesMESF, renewToken, routeLogbookEntry$1 as routeLogbookEntry, routeLogbookReport, useSearchAssets as searchAssets, sectionLogbookNavbar, sectionLogbookRoutesMESF, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useEntries$1 as useEntries, useFrontendVersionCheck, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useToken, useUTLSettingsContext, useUserContext };
|
|
20547
|
+
export { Account, AssetProvider, AssetTreePicker, AuthContext, AuthProvider, ButtonWithLoading, ChangePassword, CheckBoxControl, Configuration$1 as Configuration, ContextMenu$1 as ContextMenu, ContextMenuMESFProvider, CreateNewAssetDialog, CurrencyFormatter, DataGridControl, DateFormatter, DateTimeFormatter, ENTRY_INITIAL_VALUES$1 as ENTRY_INITIAL_VALUES, EditAssetDialog, ErrorModal, ExcelIcon, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HelmetDexteel, IntegerFormatter, LogbookSettingsInitialState, LogbookSettingsProvider, Login, Logout, LongFilterPanel, MESApiService, MESFLogbookEntry$1 as MESFLogbookEntry, MESFLogbookReport$1 as MESFLogbookReport, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NavbarMenuBar, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftAutocomplete, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, ShiftSelector, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, USER_LABELS, UTLSettingsProvider, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getEntries$1 as getEntries, getError, getMomentTz, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUserPermissionsFromAPI, getUsers, logbookNavbar, logbookRoutesMESF, renewToken, routeLogbookEntry$1 as routeLogbookEntry, routeLogbookReport, useSearchAssets as searchAssets, sectionLogbookNavbar, sectionLogbookRoutesMESF, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useEntries$1 as useEntries, useFrontendVersionCheck, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useShifts, useShiftsAroundCurrent, useShiftsByRange, useToken, useUTLSettingsContext, useUserContext };
|
|
20478
20548
|
//# sourceMappingURL=index.esm.js.map
|