@dexteel/mesf-core 7.17.2 → 7.19.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/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, AlertTitle, Autocomplete as Autocomplete$1 } from '@mui/lab';
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';
@@ -25,7 +25,7 @@ import DeleteIcon from '@mui/icons-material/Delete';
25
25
  import EditIcon from '@mui/icons-material/Edit';
26
26
  import FindInPageIcon from '@mui/icons-material/FindInPage';
27
27
  import PlaylistAddIcon from '@mui/icons-material/PlaylistAdd';
28
- import { ArrowRight, ArrowBackRounded, ArrowForwardRounded, SkipNext, ChevronLeft, ChevronRight, Cloud, ExpandLess, ExpandMore, Square as Square$1, Timeline, Send, Menu as Menu$1, People, Storage, Group, Assignment, Chat, ViewList, Build, Settings as Settings$2, Code as Code$1, FastRewind, FastForward, ZoomIn, Restore, Lock, Create, Delete, Folder, InsertChart, Search, PlaylistAdd, DragIndicator, Save, AttachFile, CloudUpload, GetApp } from '@mui/icons-material';
28
+ import { ArrowRight, ArrowBackRounded, ArrowForwardRounded, SkipNext, ChevronLeft, ChevronRight, Cloud, ExpandLess, ExpandMore, Square as Square$1, Timeline, Send, Menu as Menu$1, People, Storage, Group as Group$1, Assignment, Chat, ViewList, Build, Settings as Settings$2, Code as Code$1, FastRewind, FastForward, ZoomIn, Restore, Lock, Create, Delete, Folder, InsertChart, Search, PlaylistAdd, DragIndicator, Save, AttachFile, CloudUpload, GetApp } from '@mui/icons-material';
29
29
  import ContentCopyIcon from '@mui/icons-material/ContentCopy';
30
30
  import FormatListBulletedSharpIcon from '@mui/icons-material/FormatListBulletedSharp';
31
31
  import LockOutlinedIcon from '@mui/icons-material/LockOutlined';
@@ -35,9 +35,9 @@ import { DataGrid, GridOverlay } from '@mui/x-data-grid';
35
35
  import PropTypes from 'prop-types';
36
36
  import GetAppIcon from '@mui/icons-material/GetApp';
37
37
  import { DatePicker } from '@mui/x-date-pickers/DatePicker';
38
- import moment$g from 'moment-timezone';
38
+ import moment$h from 'moment-timezone';
39
39
  import { useParams, useNavigate, useSearchParams, Link, Navigate, Routes, Route, useLocation, BrowserRouter } from 'react-router-dom';
40
- import moment$f from 'moment';
40
+ import moment$g from 'moment';
41
41
  import SkipNextIcon from '@mui/icons-material/SkipNext';
42
42
  import PersonOutlineIcon from '@mui/icons-material/PersonOutline';
43
43
  import LockIcon from '@mui/icons-material/Lock';
@@ -45,10 +45,12 @@ import PersonIcon from '@mui/icons-material/Person';
45
45
  import { LogLevel as LogLevel$1, PublicClientApplication } from '@azure/msal-browser';
46
46
  import { useMsal, MsalProvider } from '@azure/msal-react';
47
47
  import AccountCircleIcon from '@mui/icons-material/AccountCircle';
48
+ import { Group, Panel, Separator, useDefaultLayout } from 'react-resizable-panels';
48
49
  import RefreshIcon from '@mui/icons-material/Refresh';
49
50
  import ReplayIcon from '@mui/icons-material/Replay';
50
51
  import ToggleOfIcon from '@mui/icons-material/ToggleOff';
51
52
  import ToggleOnIcon from '@mui/icons-material/ToggleOn';
53
+ import 'moment-duration-format';
52
54
  import { useComplexState } from 'use-complex-state';
53
55
  import { createSlice } from '@reduxjs/toolkit';
54
56
  import CheckBoxIcon from '@mui/icons-material/CheckBox';
@@ -61,7 +63,6 @@ import { DateTimePicker as DateTimePicker$1 } from '@mui/x-date-pickers/DateTime
61
63
  import ClearAllIcon from '@mui/icons-material/ClearAll';
62
64
  import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
63
65
  import axios from 'axios';
64
- import { Group as Group$1, Panel, Separator, useDefaultLayout } from 'react-resizable-panels';
65
66
  import { LocalizationProvider as LocalizationProvider$1 } from '@mui/x-date-pickers/LocalizationProvider';
66
67
  import InsertChartIcon from '@mui/icons-material/InsertChart';
67
68
  import ReactECharts from 'echarts-for-react';
@@ -794,7 +795,7 @@ class MESApiService {
794
795
  data.dataBaseName = database;
795
796
  data.parameters = formattedParameters;
796
797
  Date.prototype.toJSON = function () {
797
- return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
798
+ return moment$g(this).format("YYYY-MM-DDTHH:mm:ss");
798
799
  }; // eslint-disable-line
799
800
  let isError = { ok: true };
800
801
  return fetch(this.config.API_PROCEDURE_URL + "/Execute", {
@@ -848,7 +849,7 @@ class MESApiService {
848
849
  data.method = procedure;
849
850
  data.parameters = formattedParameters;
850
851
  Date.prototype.toJSON = function () {
851
- return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
852
+ return moment$g(this).format("YYYY-MM-DDTHH:mm:ss");
852
853
  }; // eslint-disable-line
853
854
  const curatedMethod = procedure.replace(/[\[\]]/g, ""); // remove brackets from method name
854
855
  try {
@@ -892,7 +893,7 @@ class MESApiService {
892
893
  data.dataBaseName = database;
893
894
  data.parameters = formattedParameters;
894
895
  Date.prototype.toJSON = function () {
895
- return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
896
+ return moment$g(this).format("YYYY-MM-DDTHH:mm:ss");
896
897
  }; // eslint-disable-line
897
898
  let isError = { ok: true };
898
899
  return fetch(this.config.API_PROCEDURE_URL + "/ExecuteJSON", {
@@ -944,7 +945,7 @@ class MESApiService {
944
945
  formattedParameters.push(formattedParameter);
945
946
  });
946
947
  Date.prototype.toJSON = function () {
947
- return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
948
+ return moment$g(this).format("YYYY-MM-DDTHH:mm:ss");
948
949
  }; // eslint-disable-line
949
950
  let isError = { ok: true };
950
951
  files.forEach((element) => {
@@ -1006,7 +1007,7 @@ class MESApiService {
1006
1007
  data.parameters = formattedParameters;
1007
1008
  data.fileName = fileName || "Default.xlsx";
1008
1009
  Date.prototype.toJSON = function () {
1009
- return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
1010
+ return moment$g(this).format("YYYY-MM-DDTHH:mm:ss");
1010
1011
  }; // eslint-disable-line
1011
1012
  let isError = { ok: true };
1012
1013
  return fetch(this.config.API_PROCEDURE_URL + "/Export", {
@@ -1080,7 +1081,7 @@ class MESApiService {
1080
1081
  data.parameters = formattedParameters;
1081
1082
  data.fileName = fileName || "Default.xlsx";
1082
1083
  Date.prototype.toJSON = function () {
1083
- return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
1084
+ return moment$g(this).format("YYYY-MM-DDTHH:mm:ss");
1084
1085
  }; // eslint-disable-line
1085
1086
  let isError = { ok: true };
1086
1087
  return fetch(this.config.API_PROCEDURE_URL + "/ExportExcel", {
@@ -1489,7 +1490,7 @@ class TimeService {
1489
1490
  else {
1490
1491
  this.timeZone = timeZone;
1491
1492
  }
1492
- moment$g.tz.setDefault(this.timeZone);
1493
+ moment$h.tz.setDefault(this.timeZone);
1493
1494
  }
1494
1495
  toUTC(datetime, format$1) {
1495
1496
  try {
@@ -1527,7 +1528,7 @@ class TimeService {
1527
1528
  return this.timeZone;
1528
1529
  }
1529
1530
  }
1530
- const getMomentTz = () => moment$g;
1531
+ const getMomentTz = () => moment$h;
1531
1532
  const dxtServerTimeZone = () => TimeService.getInstance().getServerTimeZone;
1532
1533
  const dxtToUTC = TimeService.getInstance().toUTC;
1533
1534
  const dxtToLocalServerTime = TimeService.getInstance().toLocalServerTime;
@@ -5568,7 +5569,7 @@ const LongFilterPanel = (props) => {
5568
5569
  };
5569
5570
 
5570
5571
  const getShiftByParameters = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
5571
- var _a;
5572
+ var _a, _b;
5572
5573
  const utcString = (_a = parameters.productionDate) === null || _a === void 0 ? void 0 : _a.toISOString();
5573
5574
  try {
5574
5575
  const sqlParameters = [];
@@ -5580,6 +5581,10 @@ const getShiftByParameters = (parameters) => __awaiter(void 0, void 0, void 0, f
5580
5581
  name: "@ProductionDate",
5581
5582
  value: utcString,
5582
5583
  });
5584
+ sqlParameters.push({
5585
+ name: "@AssetId",
5586
+ value: (_b = parameters.assetId) !== null && _b !== void 0 ? _b : null,
5587
+ });
5583
5588
  const apiService = new MESApiService();
5584
5589
  const resp = yield apiService.callV2("[MES].[GetShiftByParameters]", sqlParameters);
5585
5590
  if (resp.ok) {
@@ -5604,7 +5609,7 @@ const useShiftNavigatorManager = () => {
5604
5609
  const [shiftInfo, setShiftInfo] = useState(null);
5605
5610
  const [isShiftInfoLoading, setIsShiftInfoLoading] = useState(false);
5606
5611
  const [error, setError] = useState("");
5607
- const moveShift = (direction) => __awaiter(void 0, void 0, void 0, function* () {
5612
+ const moveShift = (direction, assetId) => __awaiter(void 0, void 0, void 0, function* () {
5608
5613
  if (isNil(shiftInfo)) {
5609
5614
  return;
5610
5615
  }
@@ -5623,31 +5628,33 @@ const useShiftNavigatorManager = () => {
5623
5628
  const resp = yield getShiftByParameters({
5624
5629
  productionDate: null,
5625
5630
  shiftId: shiftId,
5631
+ assetId,
5626
5632
  });
5627
5633
  if (resp.ok) {
5628
- const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$f
5634
+ const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$g
5629
5635
  .utc(resp.data.CurrentProductionDate)
5630
- .toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
5636
+ .toDate(), CurrentStart: moment$g.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$g.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$g
5631
5637
  .utc(resp.data.PreviousProductionDate)
5632
- .toDate(), PreviousStart: moment$f.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$f.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$f.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$f.utc(resp.data.LastStart).toDate(), LastEnd: moment$f.utc(resp.data.LastEnd).toDate() });
5638
+ .toDate(), PreviousStart: moment$g.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$g.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$g.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$g.utc(resp.data.LastStart).toDate(), LastEnd: moment$g.utc(resp.data.LastEnd).toDate() });
5633
5639
  setShiftInfo(shift);
5634
5640
  return shift;
5635
5641
  }
5636
5642
  }
5637
5643
  });
5638
- const getShiftDataFromAPI = (productionDate, shiftId) => __awaiter(void 0, void 0, void 0, function* () {
5644
+ const getShiftDataFromAPI = (productionDate, shiftId, assetId) => __awaiter(void 0, void 0, void 0, function* () {
5639
5645
  setIsShiftInfoLoading(true);
5640
5646
  try {
5641
5647
  const resp = yield getShiftByParameters({
5642
5648
  productionDate: productionDate,
5643
5649
  shiftId: shiftId,
5650
+ assetId,
5644
5651
  });
5645
5652
  if (resp.ok) {
5646
- const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$f
5653
+ const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$g
5647
5654
  .utc(resp.data.CurrentProductionDate)
5648
- .toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
5655
+ .toDate(), CurrentStart: moment$g.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$g.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$g
5649
5656
  .utc(resp.data.PreviousProductionDate)
5650
- .toDate(), PreviousStart: moment$f.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$f.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$f.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$f.utc(resp.data.LastStart).toDate(), LastEnd: moment$f.utc(resp.data.LastEnd).toDate() });
5657
+ .toDate(), PreviousStart: moment$g.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$g.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$g.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$g.utc(resp.data.LastStart).toDate(), LastEnd: moment$g.utc(resp.data.LastEnd).toDate() });
5651
5658
  setShiftInfo(shift);
5652
5659
  return shift;
5653
5660
  }
@@ -5657,17 +5664,18 @@ const useShiftNavigatorManager = () => {
5657
5664
  }
5658
5665
  setIsShiftInfoLoading(false);
5659
5666
  });
5660
- const initShiftNavigator = () => __awaiter(void 0, void 0, void 0, function* () {
5667
+ const initShiftNavigator = (assetId) => __awaiter(void 0, void 0, void 0, function* () {
5661
5668
  const resp = yield getShiftByParameters({
5662
5669
  productionDate: new Date(),
5663
5670
  shiftId: 0,
5671
+ assetId,
5664
5672
  });
5665
5673
  if (resp.ok) {
5666
- const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$f
5674
+ const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$g
5667
5675
  .utc(resp.data.CurrentProductionDate)
5668
- .toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
5676
+ .toDate(), CurrentStart: moment$g.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$g.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$g
5669
5677
  .utc(resp.data.PreviousProductionDate)
5670
- .toDate(), PreviousStart: moment$f.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$f.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$f.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$f.utc(resp.data.LastStart).toDate(), LastEnd: moment$f.utc(resp.data.LastEnd).toDate() });
5678
+ .toDate(), PreviousStart: moment$g.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$g.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$g.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$g.utc(resp.data.LastStart).toDate(), LastEnd: moment$g.utc(resp.data.LastEnd).toDate() });
5671
5679
  setShiftInfo(shift);
5672
5680
  return shift;
5673
5681
  }
@@ -5723,7 +5731,7 @@ const ShiftNavigatorProvider = ({ children }) => {
5723
5731
 
5724
5732
  const ShiftDayNavigatorControl = (_a) => {
5725
5733
  var _b;
5726
- var { useRouter, onShiftChange, preventInit, withPaper = true, margin = "1rem 1rem 1rem 1rem" } = _a, props = __rest(_a, ["useRouter", "onShiftChange", "preventInit", "withPaper", "margin"]);
5734
+ var { useRouter, onShiftChange, preventInit, withPaper = true, margin = "1rem 1rem 1rem 1rem", assetId } = _a, props = __rest(_a, ["useRouter", "onShiftChange", "preventInit", "withPaper", "margin", "assetId"]);
5727
5735
  const { shiftInfo, initShiftNavigator, moveShift, getShiftDataFromAPI } = useShiftNavigator();
5728
5736
  const [shiftInfoCopy, setShiftInfoCopy] = useState(shiftInfo);
5729
5737
  const [error, setError] = useState("");
@@ -5747,13 +5755,13 @@ const ShiftDayNavigatorControl = (_a) => {
5747
5755
  shiftId: shiftInfo.CurrentShiftId,
5748
5756
  });
5749
5757
  if (resp.ok) {
5750
- const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$g
5758
+ const shift = Object.assign(Object.assign({}, resp.data), { CurrentProductionDate: moment$h
5751
5759
  .utc(resp.data.CurrentProductionDate)
5752
- .toDate(), CurrentStart: moment$g.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$g.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$g
5760
+ .toDate(), CurrentStart: moment$h.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$h.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$h
5753
5761
  .utc(resp.data.PreviousProductionDate)
5754
- .toDate(), PreviousStart: moment$g.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$g.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$g
5762
+ .toDate(), PreviousStart: moment$h.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$h.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$h
5755
5763
  .utc(resp.data.LastProductionDate)
5756
- .toDate(), LastStart: moment$g.utc(resp.data.LastStart).toDate(), LastEnd: moment$g.utc(resp.data.LastEnd).toDate() });
5764
+ .toDate(), LastStart: moment$h.utc(resp.data.LastStart).toDate(), LastEnd: moment$h.utc(resp.data.LastEnd).toDate() });
5757
5765
  setShiftInfoCopy(shift);
5758
5766
  }
5759
5767
  }
@@ -5775,12 +5783,12 @@ const ShiftDayNavigatorControl = (_a) => {
5775
5783
  return;
5776
5784
  }
5777
5785
  if (useRouter && shiftId) {
5778
- getShiftDataFromAPI(null, Number(shiftId)).then(() => {
5786
+ getShiftDataFromAPI(null, Number(shiftId), assetId).then(() => {
5779
5787
  onShiftChange && onShiftChange(Number(shiftId));
5780
5788
  });
5781
5789
  }
5782
5790
  else {
5783
- initShiftNavigator().then(() => {
5791
+ initShiftNavigator(assetId).then(() => {
5784
5792
  onShiftChange && onShiftChange(Number(shiftId));
5785
5793
  });
5786
5794
  }
@@ -5790,13 +5798,13 @@ const ShiftDayNavigatorControl = (_a) => {
5790
5798
  React__default.createElement(Grid2, { size: "auto" },
5791
5799
  React__default.createElement(Tooltip, { title: "Previous Shift" },
5792
5800
  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(() => { });
5801
+ moveShift("Previous", assetId).then(() => { });
5794
5802
  }, size: "small" },
5795
5803
  React__default.createElement(ArrowBackRounded, null)))),
5796
5804
  React__default.createElement(Grid2, { size: "auto" },
5797
- 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) => {
5805
+ React__default.createElement(DatePicker, { label: "Current Date", timezone: "UTC", format: "MM/DD/YYYY", maxDate: moment$h(), closeOnSelect: true, formatDensity: "dense", value: moment$h(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentProductionDate), onChange: (date) => {
5798
5806
  if (date) {
5799
- getShiftDataFromAPI(date.toDate(), 0).then(() => { });
5807
+ getShiftDataFromAPI(date.toDate(), 0, assetId).then(() => { });
5800
5808
  }
5801
5809
  }, slots: {
5802
5810
  textField: TextField,
@@ -5817,13 +5825,13 @@ const ShiftDayNavigatorControl = (_a) => {
5817
5825
  React__default.createElement(Grid2, { size: "auto" },
5818
5826
  React__default.createElement(Tooltip, { title: "Next Shift" },
5819
5827
  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(() => { });
5828
+ moveShift("Next", assetId).then(() => { });
5821
5829
  }, size: "small" },
5822
5830
  React__default.createElement(ArrowForwardRounded, null)))),
5823
5831
  React__default.createElement(Grid2, null,
5824
5832
  React__default.createElement(Tooltip, { title: "Last Shift" },
5825
5833
  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(() => { });
5834
+ moveShift("Last", assetId).then(() => { });
5827
5835
  }, size: "small" },
5828
5836
  React__default.createElement(SkipNext, null))))));
5829
5837
  return withPaper !== false ? React__default.createElement(Paper, null, gridContent) : gridContent;
@@ -5860,8 +5868,8 @@ const getShiftsRangeByParameters = (period_1, ...args_1) => __awaiter(void 0, [p
5860
5868
  if (resp.ok) {
5861
5869
  const data = resp.data;
5862
5870
  data.tables[0].rows.map((shift) => {
5863
- shift.Start = moment$g.utc(shift["Start"]).toDate();
5864
- shift.End = moment$g.utc(shift["End"]).toDate();
5871
+ shift.Start = moment$h.utc(shift["Start"]).toDate();
5872
+ shift.End = moment$h.utc(shift["End"]).toDate();
5865
5873
  });
5866
5874
  return {
5867
5875
  ok: true,
@@ -5901,10 +5909,10 @@ const ShiftPeriodNavigatorControl = ({ value, actualPeriod, onChange, showShiftA
5901
5909
  return;
5902
5910
  try {
5903
5911
  if (direction === "prev" && (startShift === null || startShift === void 0 ? void 0 : startShift.Start)) {
5904
- yield searchShiftsRangeByParameters(period, moment$g(startShift.Start).toDate(), null, false, "prev");
5912
+ yield searchShiftsRangeByParameters(period, moment$h(startShift.Start).toDate(), null, false, "prev");
5905
5913
  }
5906
5914
  else if (direction === "next" && (endShift === null || endShift === void 0 ? void 0 : endShift.End)) {
5907
- yield searchShiftsRangeByParameters(period, null, moment$g(endShift.End).toDate(), false, "next");
5915
+ yield searchShiftsRangeByParameters(period, null, moment$h(endShift.End).toDate(), false, "next");
5908
5916
  }
5909
5917
  }
5910
5918
  catch (error) {
@@ -6004,8 +6012,8 @@ const ShiftPeriodNavigatorControl = ({ value, actualPeriod, onChange, showShiftA
6004
6012
  const newPeriod = event.target.value;
6005
6013
  setPeriod(newPeriod);
6006
6014
  if (newPeriod === "Custom") {
6007
- const today = moment$g();
6008
- const yesterday = moment$g().subtract(1, "day");
6015
+ const today = moment$h();
6016
+ const yesterday = moment$h().subtract(1, "day");
6009
6017
  setCustomStartDate(yesterday);
6010
6018
  setCustomEndDate(today);
6011
6019
  yield searchShiftsRangeByParameters("Custom", yesterday.toDate(), today.toDate(), false);
@@ -6013,7 +6021,7 @@ const ShiftPeriodNavigatorControl = ({ value, actualPeriod, onChange, showShiftA
6013
6021
  else {
6014
6022
  setCustomStartDate(null);
6015
6023
  setCustomEndDate(null);
6016
- yield searchShiftsRangeByParameters(newPeriod, null, (endShift === null || endShift === void 0 ? void 0 : endShift.Start) ? moment$g(endShift.Start).toDate() : null, false);
6024
+ yield searchShiftsRangeByParameters(newPeriod, null, (endShift === null || endShift === void 0 ? void 0 : endShift.Start) ? moment$h(endShift.Start).toDate() : null, false);
6017
6025
  }
6018
6026
  });
6019
6027
  useEffect(() => {
@@ -6072,8 +6080,8 @@ const ShiftPeriodNavigatorControl = ({ value, actualPeriod, onChange, showShiftA
6072
6080
  },
6073
6081
  } },
6074
6082
  React__default.createElement(DatePicker$1, { label: "Start", format: dateFormat, value: isCustomMode
6075
- ? customStartDate || moment$g().subtract(1, "day")
6076
- : moment$g((startShift === null || startShift === void 0 ? void 0 : startShift.Start) || moment$g().subtract(1, "day")), onChange: (value) => handleDateChange(value ? moment$g(value) : null, "start"), disabled: loadingShiftPeriodList, maxDate: isCustomMode ? moment$g() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6083
+ ? customStartDate || moment$h().subtract(1, "day")
6084
+ : moment$h((startShift === null || startShift === void 0 ? void 0 : startShift.Start) || moment$h().subtract(1, "day")), onChange: (value) => handleDateChange(value ? moment$h(value) : null, "start"), disabled: loadingShiftPeriodList, maxDate: isCustomMode ? moment$h() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6077
6085
  textField: (props) => (React__default.createElement(TextField, Object.assign({}, props, { size: "small", variant: "outlined", fullWidth: true, style: { width: "100%" }, InputProps: Object.assign(Object.assign({}, props.InputProps), { style: { paddingTop: "2px" } }) }))),
6078
6086
  openPickerIcon: () => (React__default.createElement("div", { style: {
6079
6087
  display: "flex",
@@ -6115,8 +6123,8 @@ const ShiftPeriodNavigatorControl = ({ value, actualPeriod, onChange, showShiftA
6115
6123
  },
6116
6124
  } },
6117
6125
  React__default.createElement(DatePicker$1, { label: "End", format: dateFormat, value: isCustomMode
6118
- ? customEndDate || moment$g()
6119
- : moment$g((endShift === null || endShift === void 0 ? void 0 : endShift.End) || (endShift === null || endShift === void 0 ? void 0 : endShift.Start) || moment$g()), onChange: (value) => handleDateChange(value ? moment$g(value) : null, "end"), disabled: loadingShiftPeriodList, minDate: isCustomMode && customStartDate ? customStartDate : undefined, maxDate: isCustomMode ? moment$g() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6126
+ ? customEndDate || moment$h()
6127
+ : moment$h((endShift === null || endShift === void 0 ? void 0 : endShift.End) || (endShift === null || endShift === void 0 ? void 0 : endShift.Start) || moment$h()), onChange: (value) => handleDateChange(value ? moment$h(value) : null, "end"), disabled: loadingShiftPeriodList, minDate: isCustomMode && customStartDate ? customStartDate : undefined, maxDate: isCustomMode ? moment$h() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6120
6128
  textField: (props) => (React__default.createElement(TextField, Object.assign({}, props, { size: "small", variant: "outlined", fullWidth: true, style: { width: "100%" }, InputProps: Object.assign(Object.assign({}, props.InputProps), { style: { paddingTop: "2px" } }) }))),
6121
6129
  openPickerIcon: () => (React__default.createElement("div", { style: {
6122
6130
  display: "flex",
@@ -6142,6 +6150,170 @@ const ShiftPeriodNavigatorControl = ({ value, actualPeriod, onChange, showShiftA
6142
6150
  React__default.createElement(SkipNextIcon, null)))));
6143
6151
  };
6144
6152
 
6153
+ const moment$f = getMomentTz();
6154
+ const getShifts = (params, signal) => __awaiter(void 0, void 0, void 0, function* () {
6155
+ var _a;
6156
+ const apiService = new MESApiService();
6157
+ const parameters = [
6158
+ {
6159
+ name: "ShiftId",
6160
+ value: (_a = params.shiftId) !== null && _a !== void 0 ? _a : null,
6161
+ },
6162
+ ];
6163
+ const resp = yield apiService.callV2(`[MES].[GetShiftByParameters]`, parameters, signal);
6164
+ if (resp.ok) {
6165
+ let rows = get(resp, "data.tables[0].rows", []);
6166
+ rows = rows.map((row) => {
6167
+ (row.CurrentProductionDate = moment$f
6168
+ .utc(row["CurrentProductionDate"])
6169
+ .toDate()),
6170
+ (row.CurrentStart = moment$f.utc(row["CurrentStart"]).toDate()),
6171
+ (row.CurrentEnd = moment$f.utc(row["CurrentEnd"]).toDate()),
6172
+ (row.PreviousProductionDate = moment$f
6173
+ .utc(row["PreviousProductionDate"])
6174
+ .toDate()),
6175
+ (row.PreviousStart = moment$f.utc(row["PreviousStart"]).toDate()),
6176
+ (row.PreviousEnd = moment$f.utc(row["PreviousEnd"]).toDate()),
6177
+ (row.NextProductionDate = moment$f
6178
+ .utc(row["NextProductionDate"])
6179
+ .toDate()),
6180
+ (row.NextStart = moment$f.utc(row["NextStart"]).toDate()),
6181
+ (row.NextEnd = moment$f.utc(row["NextEnd"]).toDate()),
6182
+ (row.LastProductionDate = moment$f
6183
+ .utc(row["LastProductionDate"])
6184
+ .toDate()),
6185
+ (row.LastStart = moment$f.utc(row["LastStart"]).toDate()),
6186
+ (row.LastEnd = moment$f.utc(row["LastEnd"]).toDate());
6187
+ return row;
6188
+ });
6189
+ return rows;
6190
+ }
6191
+ else {
6192
+ throw new Error(resp.message || "Error fetching shifts");
6193
+ }
6194
+ });
6195
+ const getShiftsByRange = (_a) => __awaiter(void 0, [_a], void 0, function* ({ shiftId, assetId, shiftsBefore, shiftsAfter, }) {
6196
+ const apiService = new MESApiService();
6197
+ const parameters = [
6198
+ { name: "ShiftId", value: shiftId !== null && shiftId !== void 0 ? shiftId : null },
6199
+ { name: "AssetId", value: assetId !== null && assetId !== void 0 ? assetId : null },
6200
+ ];
6201
+ if (shiftsBefore !== undefined) {
6202
+ parameters.push({ name: "ShiftsBefore", value: shiftsBefore });
6203
+ }
6204
+ if (shiftsAfter !== undefined) {
6205
+ parameters.push({ name: "ShiftsAfter", value: shiftsAfter });
6206
+ }
6207
+ const resp = yield apiService.callV2("[MES].[GetShiftsByRange]", parameters);
6208
+ if (resp.ok) {
6209
+ let rows = get(resp, "data.tables[0].rows", []);
6210
+ rows = rows.map((row) => (Object.assign(Object.assign({}, row), { Start: moment$f.utc(row.Start).toDate(), End: moment$f.utc(row.End).toDate() })));
6211
+ return rows;
6212
+ }
6213
+ else {
6214
+ throw new Error(resp.message || "Error fetching shifts by range");
6215
+ }
6216
+ });
6217
+ const getShiftsAroundCurrent = (_a) => __awaiter(void 0, [_a], void 0, function* ({ currentShiftId, shiftsRange, }) {
6218
+ const apiService = new MESApiService();
6219
+ const parameters = [
6220
+ { name: "CurrentShiftId", value: currentShiftId || null },
6221
+ ];
6222
+ if (shiftsRange) {
6223
+ parameters.push({ name: "ShiftsRange", value: shiftsRange });
6224
+ }
6225
+ const resp = yield apiService.callV2("[MES].[GetShiftsAroundCurrent]", parameters);
6226
+ if (resp.ok) {
6227
+ let rows = get(resp, "data.tables[0].rows", []);
6228
+ rows = rows.map((row) => (Object.assign(Object.assign({}, row), { Start: moment$f.utc(row.Start).toDate(), End: moment$f.utc(row.End).toDate() })));
6229
+ return rows;
6230
+ }
6231
+ else {
6232
+ throw new Error(resp.message || "Error fetching shifts");
6233
+ }
6234
+ });
6235
+
6236
+ const moment$e = getMomentTz();
6237
+ const useShiftsAroundCurrent = ({ currentShiftId, shiftsRange, enabled = true, }) => {
6238
+ return useQuery({
6239
+ queryKey: ["shiftsAroundCurrent", currentShiftId, shiftsRange],
6240
+ queryFn: ({ signal }) => getShiftsAroundCurrent({ currentShiftId, shiftsRange }),
6241
+ enabled,
6242
+ });
6243
+ };
6244
+ const useShiftsByRange = ({ shiftId, assetId, shiftsBefore, shiftsAfter, enabled = true, }) => {
6245
+ return useQuery({
6246
+ queryKey: ["shiftsByRange", shiftId, assetId, shiftsBefore, shiftsAfter],
6247
+ queryFn: () => getShiftsByRange({ shiftId, assetId, shiftsBefore, shiftsAfter }),
6248
+ enabled,
6249
+ });
6250
+ };
6251
+ const ShiftAutocomplete = ({ currentShiftId, value, onShiftSelected, disabled, shiftsRange, assetId, shiftsAfter, }) => {
6252
+ const [error, setError] = useState("");
6253
+ const useNewPath = assetId !== undefined;
6254
+ // Legacy path (existing consumers)
6255
+ const { data: legacyRows, isLoading: legacyLoading, error: legacyError, isError: legacyIsError, } = useShiftsAroundCurrent({
6256
+ currentShiftId,
6257
+ shiftsRange,
6258
+ enabled: !useNewPath,
6259
+ });
6260
+ // New path (asset-filtered, count-based)
6261
+ const { data: rangeRows, isLoading: rangeLoading, error: rangeError, isError: rangeIsError, } = useShiftsByRange({
6262
+ shiftId: currentShiftId,
6263
+ assetId,
6264
+ shiftsBefore: shiftsRange !== null && shiftsRange !== void 0 ? shiftsRange : 10,
6265
+ shiftsAfter: shiftsAfter !== null && shiftsAfter !== void 0 ? shiftsAfter : 0,
6266
+ enabled: useNewPath,
6267
+ });
6268
+ // Unified variables
6269
+ const rows = useNewPath ? rangeRows : legacyRows;
6270
+ const isLoading = useNewPath ? rangeLoading : legacyLoading;
6271
+ const e = useNewPath ? rangeError : legacyError;
6272
+ const isError = useNewPath ? rangeIsError : legacyIsError;
6273
+ const selectedShift = (rows === null || rows === void 0 ? void 0 : rows.find((type) => type.ShiftId === value)) || null;
6274
+ useEffect(() => {
6275
+ if (e && isError) {
6276
+ setError(e.message);
6277
+ }
6278
+ }, [e, isError]);
6279
+ return (React__default.createElement(React__default.Fragment, null,
6280
+ React__default.createElement(Grid2, { container: true },
6281
+ React__default.createElement(Grid2, { size: { xs: 12 } },
6282
+ React__default.createElement(Autocomplete, { loading: isLoading, options: rows || [], getOptionLabel: (option) => {
6283
+ return `${moment$e
6284
+ .utc(option.ProductionDate)
6285
+ .format("MM/DD/YYYY")} - ${option.Shift} - ${option.Crew}`;
6286
+ }, value: selectedShift, onChange: (event, newValue) => {
6287
+ if (newValue) {
6288
+ onShiftSelected(newValue);
6289
+ }
6290
+ }, 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)) }) }))) }))),
6291
+ React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
6292
+ };
6293
+
6294
+ const useShifts = (shiftId) => {
6295
+ return useQuery({
6296
+ queryKey: ["shifts", shiftId],
6297
+ queryFn: ({ signal }) => getShifts({ shiftId }, signal),
6298
+ });
6299
+ };
6300
+ const ShiftSelector = ({ label = "Shift - Crew", value, onChange = () => { }, fieldError, disabled = false, }) => {
6301
+ const [error, setError] = useState("");
6302
+ const { data: shifts, isLoading, isError, error: e } = useShifts(value);
6303
+ const selectedShift = (shifts === null || shifts === void 0 ? void 0 : shifts.find((s) => s.CurrentShiftId === value)) || null;
6304
+ useEffect(() => {
6305
+ if (isError) {
6306
+ setError(e.message);
6307
+ }
6308
+ }, [isError, e]);
6309
+ return (React__default.createElement(React__default.Fragment, null,
6310
+ 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) => {
6311
+ var _a;
6312
+ onChange((_a = newValue === null || newValue === void 0 ? void 0 : newValue.CurrentShiftId) !== null && _a !== void 0 ? _a : null);
6313
+ } }),
6314
+ React__default.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error loading shifts" })));
6315
+ };
6316
+
6145
6317
  function ChangePassword(props) {
6146
6318
  const { onClose, userId, open } = props;
6147
6319
  //states
@@ -6936,15 +7108,15 @@ const getJobs = (signal) => __awaiter(void 0, void 0, void 0, function* () {
6936
7108
  if (resp.ok) {
6937
7109
  let rows = get(resp, "data.tables[0].rows", []);
6938
7110
  rows = rows.map((job) => (Object.assign(Object.assign({}, job), { LastStarted: job.LastStarted
6939
- ? moment$f.utc(job["LastStarted"]).toDate()
7111
+ ? moment$g.utc(job["LastStarted"]).toDate()
6940
7112
  : null, LastContact: job.LastContact
6941
- ? moment$f.utc(job["LastContact"]).toDate()
7113
+ ? moment$g.utc(job["LastContact"]).toDate()
6942
7114
  : null, LastCounter: job.LastCounter
6943
- ? moment$f.utc(job["LastCounter"]).toDate()
6944
- : null, StartTime: job.StartTime ? moment$f.utc(job["StartTime"]).toDate() : null, NextExecutionTime: job.NextExecutionTime
6945
- ? moment$f.utc(job["NextExecutionTime"]).toDate()
7115
+ ? moment$g.utc(job["LastCounter"]).toDate()
7116
+ : null, StartTime: job.StartTime ? moment$g.utc(job["StartTime"]).toDate() : null, NextExecutionTime: job.NextExecutionTime
7117
+ ? moment$g.utc(job["NextExecutionTime"]).toDate()
6946
7118
  : null, LastExecutionTime: job.LastExecutionTime
6947
- ? moment$f.utc(job["LastExecutionTime"]).toDate()
7119
+ ? moment$g.utc(job["LastExecutionTime"]).toDate()
6948
7120
  : null })));
6949
7121
  return rows;
6950
7122
  }
@@ -7138,7 +7310,7 @@ const JobDetails = ({ job, modal, onHide, suffixTitle }) => {
7138
7310
  } })),
7139
7311
  React__default.createElement(Grid2, { size: { xs: 12, md: 6 } },
7140
7312
  React__default.createElement(Controller, { name: "StartTime", control: control, render: ({ field, fieldState: { error } }) => (React__default.createElement(React__default.Fragment, null,
7141
- React__default.createElement(DateTimePicker, { label: "Start Time", value: field.value ? moment$g(field.value) : null, onChange: field.onChange, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), slotProps: {
7313
+ React__default.createElement(DateTimePicker, { label: "Start Time", value: field.value ? moment$h(field.value) : null, onChange: field.onChange, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), slotProps: {
7142
7314
  textField: {
7143
7315
  size: "small",
7144
7316
  margin: "none",
@@ -7152,7 +7324,7 @@ const JobDetails = ({ job, modal, onHide, suffixTitle }) => {
7152
7324
  return (React__default.createElement(TextField, { label: "Last Status", value: (_a = field.value) !== null && _a !== void 0 ? _a : "", variant: "outlined", size: "small", fullWidth: true, disabled: true }));
7153
7325
  } })),
7154
7326
  React__default.createElement(Grid2, { size: { xs: 12, md: 6 } },
7155
- React__default.createElement(Controller, { name: "LastExecutionTime", control: control, render: ({ field }) => (React__default.createElement(DateTimePicker, { label: "Last Execution Time", value: field.value ? moment$g(field.value) : null, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), disabled: true, slotProps: {
7327
+ React__default.createElement(Controller, { name: "LastExecutionTime", control: control, render: ({ field }) => (React__default.createElement(DateTimePicker, { label: "Last Execution Time", value: field.value ? moment$h(field.value) : null, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), disabled: true, slotProps: {
7156
7328
  textField: {
7157
7329
  size: "small",
7158
7330
  margin: "none",
@@ -7160,7 +7332,7 @@ const JobDetails = ({ job, modal, onHide, suffixTitle }) => {
7160
7332
  },
7161
7333
  } })) })),
7162
7334
  React__default.createElement(Grid2, { size: { xs: 12, md: 6 } },
7163
- React__default.createElement(Controller, { name: "NextExecutionTime", control: control, render: ({ field }) => (React__default.createElement(DateTimePicker, { label: "Next Execution Time", value: field.value ? moment$g(field.value) : null, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), disabled: true, slotProps: {
7335
+ React__default.createElement(Controller, { name: "NextExecutionTime", control: control, render: ({ field }) => (React__default.createElement(DateTimePicker, { label: "Next Execution Time", value: field.value ? moment$h(field.value) : null, format: "MM/DD/YYYY HH:mm:ss", views: ["year", "month", "day", "hours", "minutes"], ampm: false, timezone: TimeService.getInstance().getServerTimeZone(), disabled: true, slotProps: {
7164
7336
  textField: {
7165
7337
  size: "small",
7166
7338
  margin: "none",
@@ -7246,6 +7418,7 @@ const useJobsOptionsFunctions = ({ setShowModal, setJobSelected, }) => {
7246
7418
  };
7247
7419
  };
7248
7420
 
7421
+ const moment$d = getMomentTz();
7249
7422
  const useJobsTableData = ({ setShowModal, setJobSelected, showContextMenu, }) => {
7250
7423
  const renderButtonMenu = (params) => {
7251
7424
  return (React__default.createElement(IconButton$1, { style: {}, onClick: (e) => showContextMenu(e, params.data, "jobsContext"), size: "small" },
@@ -7265,19 +7438,20 @@ const useJobsTableData = ({ setShowModal, setJobSelected, showContextMenu, }) =>
7265
7438
  field: "PeriodTime",
7266
7439
  headerName: "Period Time",
7267
7440
  flex: 2,
7268
- valueFormatter: ({ value }) => {
7269
- if (value === null || value === undefined)
7270
- return "";
7271
- const horas = Math.floor(value / 3600);
7272
- const minutos = Math.floor((value % 3600) / 60);
7273
- const segundos = value % 60;
7274
- return `${horas}h ${minutos}min ${segundos}s`;
7275
- },
7441
+ valueGetter: (params) => moment$d
7442
+ .duration(params.data.PeriodTime, "seconds")
7443
+ .format("h[h] m[m] s[s]"),
7444
+ },
7445
+ {
7446
+ field: "LastExecutionTime",
7447
+ headerName: "Last Execution",
7448
+ valueGetter: (params) => dxtToLocalServerTime(params.data.LastExecutionTime, "MM/dd HH:mm"),
7449
+ flex: 2,
7276
7450
  },
7277
7451
  {
7278
7452
  field: "NextExecutionTime",
7279
7453
  headerName: "Next Execution",
7280
- valueFormatter: ({ value }) => value === null ? "" : moment$f(value).format("DD/MM/YY HH:mm"),
7454
+ valueGetter: (params) => dxtToLocalServerTime(params.data.NextExecutionTime, "MM/dd HH:mm"),
7281
7455
  flex: 2,
7282
7456
  },
7283
7457
  {
@@ -7305,6 +7479,7 @@ const useJobsTableData = ({ setShowModal, setJobSelected, showContextMenu, }) =>
7305
7479
  return { columnDefs };
7306
7480
  };
7307
7481
 
7482
+ const jobStorageKey = "job-table-panel-sizes";
7308
7483
  const useSearchJobs = () => {
7309
7484
  return useQuery({
7310
7485
  queryKey: ["jobs"],
@@ -7315,6 +7490,8 @@ const CustomStatusPanel$1 = ({ handleNew }) => (React.createElement(IconButton$1
7315
7490
  React.createElement(PlaylistAddIcon, { style: { width: 30, height: 30 } })));
7316
7491
  const TableJobs = () => {
7317
7492
  const queryClient = useQueryClient();
7493
+ const groupRef = useRef(null);
7494
+ const [hover, setHover] = useState(false);
7318
7495
  const [jobSelected, setJobSelected] = useState(null);
7319
7496
  const [gridApi, setGridApi] = useState(null);
7320
7497
  const [errorMessage, setErrorMessage] = useState("");
@@ -7410,6 +7587,44 @@ const TableJobs = () => {
7410
7587
  }
7411
7588
  }
7412
7589
  };
7590
+ const getSavedPanelLayout = () => {
7591
+ try {
7592
+ const saved = localStorage.getItem(jobStorageKey);
7593
+ if (saved) {
7594
+ const layout = JSON.parse(saved);
7595
+ if (layout && typeof layout === "object") {
7596
+ return layout;
7597
+ }
7598
+ }
7599
+ }
7600
+ catch (e) {
7601
+ console.error("Error loading panel layout:", e);
7602
+ }
7603
+ return { table: 50, details: 50 };
7604
+ };
7605
+ const handlePanelResize = (layout) => {
7606
+ try {
7607
+ localStorage.setItem(jobStorageKey, JSON.stringify(layout));
7608
+ }
7609
+ catch (e) {
7610
+ console.error("Error saving panel layout:", e);
7611
+ }
7612
+ };
7613
+ const resetPanelLayout = () => {
7614
+ if (groupRef.current) {
7615
+ const defaultLayout = { table: 50, details: 50 };
7616
+ groupRef.current.setLayout(defaultLayout);
7617
+ try {
7618
+ localStorage.setItem(jobStorageKey, JSON.stringify(defaultLayout));
7619
+ }
7620
+ catch (e) {
7621
+ console.error("Error saving default layout:", e);
7622
+ }
7623
+ }
7624
+ };
7625
+ const handleSeparatorDoubleClick = () => {
7626
+ resetPanelLayout();
7627
+ };
7413
7628
  useEffect(() => {
7414
7629
  if (e && isError) {
7415
7630
  setErrorMessage(e.message);
@@ -7425,36 +7640,47 @@ const TableJobs = () => {
7425
7640
  React.createElement(Grid2, { container: true, justifyContent: "flex-start", p: 1, spacing: 1 },
7426
7641
  React.createElement(Grid2, { size: { md: 12, xs: 12 } },
7427
7642
  React.createElement(Typography$1, { variant: "h5", fontWeight: 600 }, "System Jobs")),
7428
- React.createElement(Grid2, { container: true, justifyContent: "flex-start", alignItems: "center", sx: {
7429
- width: "100%",
7430
- "& .MuiDataGrid-row": {
7431
- cursor: "pointer",
7432
- },
7433
- "& .MuiDataGrid-columnHeaderTitle, & .MuiTablePagination-caption": {
7434
- fontWeight: "bold",
7435
- fontColor: "black",
7436
- },
7437
- }, spacing: 2 },
7438
- React.createElement(Grid2, { size: { md: 6, xs: 12 } },
7439
- React.createElement(Paper, { elevation: 2, style: { height: "70vh", width: "100%" } },
7440
- React.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, getContextMenuItems: getContextMenuItems, loadingOverlayComponent: CenteredLazyLoading, rowHeight: 34, headerHeight: 34, animateRows: true, rowSelection: "single", onGridReady: (params) => setGridApi(params.api), getRowId: (params) => `${params.data.JobId}`, onRowClicked: onRowClicked, onCellKeyDown: onCellKeyDown, gridOptions: {
7441
- theme: themeDXT,
7442
- statusBar: {
7443
- statusPanels: [
7444
- {
7445
- statusPanel: (params) => (React.createElement(CustomStatusPanel$1, { handleNew: handleNewJob })),
7446
- align: "left",
7447
- },
7448
- {
7449
- statusPanel: "agTotalRowCountComponent",
7450
- align: "right",
7451
- },
7452
- ],
7453
- },
7454
- } }))),
7455
- React.createElement(Grid2, { size: { md: 6, xs: 12 } },
7456
- React.createElement(Paper, { elevation: 2, style: { height: "70vh", width: "100%" }, className: `ag-theme-material` },
7457
- React.createElement(JobDetails, { job: jobSelected, modal: showModal, onHide: onDetailsHide, suffixTitle: "System Jobs" }))))),
7643
+ React.createElement(Grid2, { sx: { width: "100%" } },
7644
+ React.createElement(Group, { orientation: "horizontal", defaultLayout: getSavedPanelLayout(), onLayoutChange: handlePanelResize, groupRef: groupRef, style: { height: "100%" } },
7645
+ React.createElement(Panel, { id: "table", minSize: 20 },
7646
+ React.createElement(Paper, { elevation: 2, style: { height: "70vh", width: "100%" } },
7647
+ React.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, getContextMenuItems: getContextMenuItems, loadingOverlayComponent: CenteredLazyLoading, rowHeight: 34, headerHeight: 34, animateRows: true, rowSelection: "single", onGridReady: (params) => setGridApi(params.api), getRowId: (params) => `${params.data.JobId}`, onRowClicked: onRowClicked, onCellKeyDown: onCellKeyDown, gridOptions: {
7648
+ theme: themeDXT,
7649
+ statusBar: {
7650
+ statusPanels: [
7651
+ {
7652
+ statusPanel: (params) => (React.createElement(CustomStatusPanel$1, { handleNew: handleNewJob })),
7653
+ align: "left",
7654
+ },
7655
+ {
7656
+ statusPanel: "agTotalRowCountComponent",
7657
+ align: "right",
7658
+ },
7659
+ ],
7660
+ },
7661
+ } }))),
7662
+ React.createElement(Separator, { onDoubleClick: handleSeparatorDoubleClick, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), style: {
7663
+ width: hover ? "10px" : "8px",
7664
+ background: hover ? "#bdbdbd" : "#e0e0e0",
7665
+ position: "relative",
7666
+ cursor: "col-resize",
7667
+ marginLeft: 5,
7668
+ marginRight: 5,
7669
+ borderRadius: 10,
7670
+ } },
7671
+ React.createElement("div", { style: {
7672
+ position: "absolute",
7673
+ top: "50%",
7674
+ left: "50%",
7675
+ transform: "translate(-50%, -50%)",
7676
+ width: "3px",
7677
+ height: "40px",
7678
+ background: hover ? "#616161" : "#9e9e9e",
7679
+ borderRadius: "2px",
7680
+ } })),
7681
+ React.createElement(Panel, { id: "details", minSize: 20 },
7682
+ React.createElement(Paper, { elevation: 2, style: { height: "70vh", width: "100%" } },
7683
+ React.createElement(JobDetails, { job: jobSelected, modal: showModal, onHide: onDetailsHide, suffixTitle: "System Jobs" })))))),
7458
7684
  React.createElement(ResetJob, { show: showModal === "reset", onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
7459
7685
  setShowModal("");
7460
7686
  setJobSelected(null);
@@ -7739,14 +7965,14 @@ const TagFilter = ({ tagFilters, setTagFilters, filterContext, }) => {
7739
7965
  } },
7740
7966
  React__default.createElement(Typography$1, { variant: "subtitle2" }, selectedTag ? "Edit Tag Filter" : "Add Tag Filter"),
7741
7967
  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) => {
7968
+ React__default.createElement(Autocomplete$1, { size: "small", options: availableTagsForSelection, getOptionLabel: (option) => option.TagName, value: selectedTag, onChange: (_, newValue) => {
7743
7969
  setSelectedTag(newValue);
7744
7970
  setSelectedValues([]);
7745
7971
  }, renderOption: (props, option) => (React__default.createElement("li", Object.assign({}, props, { style: {
7746
7972
  opacity: option.HasData ? 1 : 0.8,
7747
7973
  } }), option.TagName)), renderInput: (params) => (React__default.createElement(TextField, Object.assign({}, params, { label: "Tag Name", variant: "outlined" }))) }),
7748
7974
  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: {
7975
+ 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
7976
  opacity: option.HasData ? 1 : 0.8,
7751
7977
  } }),
7752
7978
  React__default.createElement(Checkbox, { icon: icon, checkedIcon: checkedIcon, style: { marginRight: 8 }, checked: selected, size: "small" }),
@@ -7809,7 +8035,7 @@ const CodeFilter = ({ LogTypeCode, setLogTypeCodeFilter }) => {
7809
8035
 
7810
8036
  const DateFilter = ({ date, setDate, label = "Date", minDate, maxDate, }) => {
7811
8037
  return (React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
7812
- React__default.createElement(DatePicker$1, { format: "MM/DD/YYYY", minDate: minDate ? moment$f(minDate) : undefined, maxDate: maxDate ? moment$f(maxDate) : undefined, sx: {
8038
+ React__default.createElement(DatePicker$1, { format: "MM/DD/YYYY", minDate: minDate ? moment$g(minDate) : undefined, maxDate: maxDate ? moment$g(maxDate) : undefined, sx: {
7813
8039
  minWidth: "100%",
7814
8040
  borderTopLeftRadius: 3,
7815
8041
  borderTopRightRadius: 3,
@@ -7819,7 +8045,7 @@ const DateFilter = ({ date, setDate, label = "Date", minDate, maxDate, }) => {
7819
8045
  size: "small",
7820
8046
  fullWidth: true,
7821
8047
  },
7822
- }, label: label, value: date ? moment$f(date) : null, onChange: (newDate) => setDate(newDate ? newDate.toDate() : null) })));
8048
+ }, label: label, value: date ? moment$g(date) : null, onChange: (newDate) => setDate(newDate ? newDate.toDate() : null) })));
7823
8049
  };
7824
8050
 
7825
8051
  const SearchFilter = ({ search, setSearch }) => {
@@ -7924,7 +8150,7 @@ const getLogs = (params, signal) => __awaiter(void 0, void 0, void 0, function*
7924
8150
  const resp = yield apiService.callV2("[MES].[GetLogs]", parameters);
7925
8151
  if (resp.ok) {
7926
8152
  let rows = get(resp, "data.tables[0].rows", []);
7927
- rows = rows.map((log) => (Object.assign(Object.assign({}, log), { Timestamp: log.Timestamp ? moment$f.utc(log["Timestamp"]).toDate() : null })));
8153
+ rows = rows.map((log) => (Object.assign(Object.assign({}, log), { Timestamp: log.Timestamp ? moment$g.utc(log["Timestamp"]).toDate() : null })));
7928
8154
  return rows;
7929
8155
  }
7930
8156
  else {
@@ -8054,8 +8280,8 @@ const getLogTypeByCodeId = (logTypeCodeId) => {
8054
8280
  return get(LOG_TYPE_CODES, `${logTypeCodeId}.description`, " -");
8055
8281
  };
8056
8282
  const TableLogs = () => {
8057
- const [startDate, setStartDate] = useState(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate());
8058
- const [endDate, setEndDate] = useState(moment$f().hour(23).minute(59).second(59).toDate());
8283
+ const [startDate, setStartDate] = useState(moment$g().add(-5, "days").hour(0).minute(0).second(0).toDate());
8284
+ const [endDate, setEndDate] = useState(moment$g().hour(23).minute(59).second(59).toDate());
8059
8285
  const [timezone, setTimezone] = useState("UTC");
8060
8286
  const [search, setSearch] = useState("");
8061
8287
  const [logTypeCode, setLogTypeCode] = useState(["I", "W", "E"]);
@@ -8078,7 +8304,7 @@ const TableLogs = () => {
8078
8304
  const formattedRows = rows === null || rows === void 0 ? void 0 : rows.map(({ LogId, Timestamp, Source, Message, LogTypeCode, User }) => ({
8079
8305
  id: LogId,
8080
8306
  Timestamp: timezone === "UTC"
8081
- ? moment$f(Timestamp).utc().format("YYYY-MM-DD HH:mm:ss z")
8307
+ ? moment$g(Timestamp).utc().format("YYYY-MM-DD HH:mm:ss z")
8082
8308
  : dxtToLocalServerTime(Timestamp, "yyyy-MM-dd HH:mm:ss z"),
8083
8309
  Source,
8084
8310
  Message: isNil(Message) ? "" : Message.replaceAll("Added", " Added"),
@@ -8102,8 +8328,8 @@ const TableLogs = () => {
8102
8328
  }, []);
8103
8329
  const { showContextMenu, registerConfig } = useContextMenuMESF();
8104
8330
  const handleResetButtonClick = () => {
8105
- setStartDate(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate());
8106
- setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
8331
+ setStartDate(moment$g().add(-5, "days").hour(0).minute(0).second(0).toDate());
8332
+ setEndDate(moment$g().hour(23).minute(59).second(59).toDate());
8107
8333
  setSearch("");
8108
8334
  gridAPI === null || gridAPI === void 0 ? void 0 : gridAPI.setGridOption("quickFilterText", "");
8109
8335
  setLogTypeCode(["I", "W", "E"]);
@@ -8193,7 +8419,7 @@ const TableLogs = () => {
8193
8419
  setEndDate(null);
8194
8420
  }
8195
8421
  else {
8196
- setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
8422
+ setEndDate(moment$g().hour(23).minute(59).second(59).toDate());
8197
8423
  }
8198
8424
  setAutoRefresh(checked);
8199
8425
  } })),
@@ -8233,69 +8459,179 @@ const ProfilesPage = (props) => {
8233
8459
  return React.createElement(Profiles, null);
8234
8460
  };
8235
8461
 
8236
- const getShiftParameters = (signal) => __awaiter(void 0, void 0, void 0, function* () {
8237
- const apiService = new MESApiService();
8238
- const resp = yield apiService.callV2("[MES].[GetShiftParameters]", [], signal);
8239
- if (resp.ok) {
8240
- return get(resp, "data.tables[0].rows", []);
8241
- }
8242
- else {
8243
- throw new Error(resp.message || "Error fetching shifts");
8244
- }
8245
- });
8246
- const upsertShiftParameters = (_a, ...args_1) => __awaiter(void 0, [_a, ...args_1], void 0, function* ({ PatternStart, ShiftCodes, Crews, CrewRotation, Comments }, isUpdate = false) {
8247
- const apiService = new MESApiService();
8248
- const parameters = [
8249
- { name: "AssetId", value: null },
8250
- { name: "PatternStart", value: PatternStart },
8251
- { name: "ShiftCodes", value: ShiftCodes },
8252
- { name: "Crews", value: Crews },
8253
- { name: "CrewRotation", value: CrewRotation },
8254
- { name: "Comments", value: Comments },
8255
- { name: "IsUpdate", value: isUpdate },
8256
- ];
8257
- const resp = yield apiService.callV2("[MES].[UpsertShiftParameters]", parameters);
8258
- if (!resp.ok) {
8259
- throw new Error(resp.message || "Error when upsert shift");
8260
- }
8261
- });
8262
- const deleteShiftParameters = (PatternStart) => __awaiter(void 0, void 0, void 0, function* () {
8263
- const apiService = new MESApiService();
8264
- const parameters = [];
8265
- parameters.push({ name: "AssetId", value: null });
8266
- parameters.push({ name: "PatternStart", value: PatternStart });
8267
- const resp = yield apiService.callV2("[MES].[DeleteShiftParameters]", parameters);
8268
- if (!resp.ok) {
8269
- throw new Error(resp.message || "Error when delete shift");
8270
- }
8271
- });
8462
+ const useSettingsOptionsFunctions = ({ setSettingId, setShowDeleteModal, setShowCreateModal, setShowEditModal, }) => {
8463
+ const getMenuOptions = (data) => {
8464
+ let options = [];
8465
+ if (!data) {
8466
+ options = options.concat([
8467
+ {
8468
+ name: "New Setting",
8469
+ key: "new_setting",
8470
+ onClick: () => {
8471
+ setShowCreateModal(true);
8472
+ },
8473
+ icon: React__default.createElement(PlaylistAddIcon, null),
8474
+ },
8475
+ ]);
8476
+ }
8477
+ else {
8478
+ options = options.concat([
8479
+ {
8480
+ name: "New Setting",
8481
+ key: "new_setting",
8482
+ onClick: () => {
8483
+ setShowCreateModal(true);
8484
+ },
8485
+ icon: React__default.createElement(PlaylistAddIcon, null),
8486
+ },
8487
+ {
8488
+ name: "Edit Setting",
8489
+ key: "edit_setting",
8490
+ onClick: () => {
8491
+ setSettingId(data);
8492
+ setShowEditModal(true);
8493
+ },
8494
+ icon: React__default.createElement(EditIcon, null),
8495
+ },
8496
+ {
8497
+ name: "Delete Setting",
8498
+ key: "delete_setting",
8499
+ onClick: () => {
8500
+ setSettingId(data);
8501
+ setShowDeleteModal(true);
8502
+ },
8503
+ icon: React__default.createElement(DeleteIcon, null),
8504
+ },
8505
+ ]);
8506
+ }
8507
+ return options;
8508
+ };
8509
+ return {
8510
+ getMenuOptions,
8511
+ };
8512
+ };
8272
8513
 
8273
- const INITIAL_VALUES$1 = {
8274
- PatternStart: new Date(),
8275
- ShiftCodes: "",
8276
- Crews: "",
8277
- User: "",
8278
- PatternDays: 5,
8279
- CrewRotation: "",
8280
- Comments: "",
8281
- CanEdit: false,
8282
- ShiftsPerDay: 1,
8283
- NumberOfCrews: 1,
8514
+ const useTableData$5 = ({ setOpenModalEditSetting, setOpenModalDeleteSetting, showContextMenu, setSettingSelected, }) => {
8515
+ const columnDefs = [
8516
+ {
8517
+ field: "SettingName",
8518
+ headerName: "Name",
8519
+ minWidth: 180,
8520
+ flex: 4,
8521
+ },
8522
+ {
8523
+ field: "Value",
8524
+ headerName: "Value",
8525
+ minWidth: 180,
8526
+ flex: 2,
8527
+ },
8528
+ {
8529
+ field: "Description",
8530
+ headerName: "Description",
8531
+ minWidth: 150,
8532
+ flex: 4,
8533
+ },
8534
+ {
8535
+ cellRenderer: (params) => {
8536
+ return (React__default.createElement(Grid2, { container: true, sx: {
8537
+ height: "100%",
8538
+ display: "flex",
8539
+ justifyContent: "center",
8540
+ alignItems: "center",
8541
+ opacity: 0,
8542
+ transition: "opacity 0.1s ease-in-out",
8543
+ ".ag-row-hover &": {
8544
+ opacity: 1,
8545
+ },
8546
+ ".ag-row-focus &": {
8547
+ opacity: 1,
8548
+ },
8549
+ ".ag-row-selected &": {
8550
+ opacity: 1,
8551
+ },
8552
+ } },
8553
+ React__default.createElement(Grid2, { size: { xs: 12, md: 12 }, style: {
8554
+ display: "flex",
8555
+ justifyContent: "space-evenly",
8556
+ alignItems: "center",
8557
+ } },
8558
+ React__default.createElement(IconButton$1, { size: "small", onClick: () => {
8559
+ setSettingSelected(params === null || params === void 0 ? void 0 : params.data);
8560
+ setOpenModalEditSetting(true);
8561
+ } },
8562
+ React__default.createElement(EditIcon, { color: "primary" })),
8563
+ React__default.createElement(IconButton$1, { size: "small", onClick: () => {
8564
+ setSettingSelected(params === null || params === void 0 ? void 0 : params.data);
8565
+ setOpenModalDeleteSetting(true);
8566
+ } },
8567
+ React__default.createElement(DeleteIcon, { color: "secondary" })),
8568
+ React__default.createElement(IconButton$1, { size: "small", onClick: (e) => showContextMenu(e, params.data, "TableSettings") },
8569
+ React__default.createElement(FormatListBulletedSharpIcon, { color: "action" })))));
8570
+ },
8571
+ field: "",
8572
+ flex: 1,
8573
+ minWidth: 240,
8574
+ editable: false,
8575
+ autoHeight: false,
8576
+ suppressNavigable: true,
8577
+ },
8578
+ ];
8579
+ const defaultColDef = useMemo(() => {
8580
+ return {
8581
+ sortable: true,
8582
+ wrapText: true,
8583
+ autoHeight: true,
8584
+ wrapHeaderText: true,
8585
+ suppressHeaderMenuButton: true,
8586
+ cellStyle: {
8587
+ display: "flex",
8588
+ alignItems: "center",
8589
+ justifyContent: "center",
8590
+ },
8591
+ };
8592
+ }, []);
8593
+ return { columnDefs, defaultColDef };
8284
8594
  };
8285
8595
 
8286
- const CreateShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8287
- var _a, _b;
8288
- const theme = useTheme();
8596
+ const INITIAL_VALUES$1 = {
8597
+ SettingName: "",
8598
+ Value: "",
8599
+ Description: "",
8600
+ };
8601
+
8602
+ const upsertSettings = (_a) => __awaiter(void 0, [_a], void 0, function* ({ oldName, newName, description, value, }) {
8603
+ const apiService = new MESApiService();
8604
+ const parameters = [
8605
+ { name: "OldName", value: oldName },
8606
+ { name: "NewName", value: newName },
8607
+ { name: "Description", value: description },
8608
+ { name: "Value", value: value },
8609
+ ];
8610
+ const resp = yield apiService.callV2("[UTL].[SetSetting]", parameters);
8611
+ if (!resp.ok) {
8612
+ throw new Error(resp.message || "Error when upsert setting");
8613
+ }
8614
+ });
8615
+ const deleteSetting = (settingName) => __awaiter(void 0, void 0, void 0, function* () {
8616
+ const apiService = new MESApiService();
8617
+ const parameters = [
8618
+ { name: "SettingName", value: settingName },
8619
+ ];
8620
+ const resp = yield apiService.callV2("[UTL].[DeleteSetting]", parameters);
8621
+ if (!resp.ok) {
8622
+ throw new Error(resp.message || "Error when delete setting");
8623
+ }
8624
+ });
8625
+
8626
+ const CreateSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
8289
8627
  const [open, setOpen] = useState(false);
8290
8628
  const [isSubmitLoading, setIsSubmitLoading] = useState(false);
8291
8629
  const [error, setError] = useState("");
8292
- const { control, handleSubmit, reset, watch, setValue, formState: { errors }, } = useForm({
8293
- defaultValues: shiftSelected ? shiftSelected : INITIAL_VALUES$1,
8630
+ const { control, handleSubmit, reset } = useForm({
8631
+ defaultValues: settingSelected ? settingSelected : INITIAL_VALUES$1,
8294
8632
  });
8295
- // Progress bar
8296
- const calculatePercentage = () => ((crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) / maxCrewRotationLength) * 100;
8297
- const createShift = useMutation({
8298
- mutationFn: upsertShiftParameters,
8633
+ const updateSetting = useMutation({
8634
+ mutationFn: upsertSettings,
8299
8635
  onSuccess: () => {
8300
8636
  setOpen(true);
8301
8637
  onHide(true);
@@ -8309,7 +8645,12 @@ const CreateShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8309
8645
  });
8310
8646
  const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
8311
8647
  setIsSubmitLoading(true);
8312
- yield createShift.mutate(data);
8648
+ yield updateSetting.mutate({
8649
+ oldName: "",
8650
+ newName: data.SettingName,
8651
+ description: data.Description,
8652
+ value: data.Value,
8653
+ });
8313
8654
  });
8314
8655
  const handleClose = (event, reason) => {
8315
8656
  if (reason === "clickaway") {
@@ -8317,175 +8658,50 @@ const CreateShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8317
8658
  }
8318
8659
  setOpen(false);
8319
8660
  };
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
8661
  useEffect(() => {
8330
8662
  if (show) {
8331
8663
  reset();
8332
- setValue("PatternStart", new Date());
8333
8664
  }
8334
8665
  }, [show]);
8335
8666
  return (React.createElement(React.Fragment, null,
8336
- show && (React.createElement(HelmetDexteel, { title: `New Shift/Crew${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
8337
- React.createElement(MesfModal, { title: "NEW SHIFT/CREW", open: show, handleClose: () => onHide(false), id: "create-shift-modal", maxWidth: "md" },
8338
- React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
8339
- React.createElement(MesfModal.Content, null,
8340
- React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
8341
- React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
8342
- React.createElement(Grid2, { size: { md: 6, xs: 12 } },
8343
- React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
8344
- minWidth: "100%",
8345
- borderTopLeftRadius: 3,
8346
- borderTopRightRadius: 3,
8347
- }, label: "Start", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
8348
- textField: {
8349
- fullWidth: true,
8350
- variant: "standard",
8351
- },
8352
- } })),
8353
- React.createElement(Grid2, { size: { md: 6, xs: 12 } },
8354
- 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: {
8355
- textField: {
8356
- fullWidth: true,
8357
- variant: "standard",
8358
- },
8359
- } })))) }),
8360
- React.createElement(Grid2, { size: { md: 6, xs: 6 } },
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" }),
8667
+ show && (React.createElement(HelmetDexteel, { title: `New Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
8668
+ React.createElement(Grid2, { container: true },
8669
+ React.createElement(Grid2, null,
8670
+ React.createElement(MesfModal, { title: "NEW SETTING", open: show, handleClose: () => onHide(false), id: "create-setting-modal", maxWidth: "md" },
8671
+ React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
8672
+ React.createElement(MesfModal.Content, null,
8673
+ React.createElement(Grid2, { container: true, spacing: 2 },
8674
+ React.createElement(Grid2, { size: { xs: 12, md: 6 } },
8675
+ 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" }))) })),
8676
+ React.createElement(Grid2, { size: { xs: 12, md: 6 } },
8677
+ React.createElement(Controller, { name: "Value", control: control, rules: {
8678
+ required: "Value is required",
8679
+ }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Value", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
8680
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
8681
+ 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) => {
8682
+ if (evt.target.value.length <= 200)
8683
+ onChange(evt);
8684
+ } })) })))),
8685
+ React.createElement(MesfModal.Actions, null,
8686
+ React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
8687
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
8688
+ React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
8689
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
8690
+ React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))))),
8691
+ React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error Creating Setting" }),
8476
8692
  React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
8477
- React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The shift was created successfully"))));
8693
+ React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was created successfully"))));
8478
8694
  };
8479
8695
 
8480
- const DeleteShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8481
- var _a;
8696
+ const DeleteSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
8482
8697
  const [open, setOpen] = useState(false);
8483
8698
  const [isSubmitLoading, setIsSubmitLoading] = useState(false);
8484
- const [deleteAlert, setDeleteAlert] = useState(false);
8485
8699
  const [error, setError] = useState("");
8486
- const { control, setValue, reset, watch, formState: { errors }, } = useForm({ defaultValues: INITIAL_VALUES$1 });
8487
- const deleteShift = useMutation({
8488
- mutationFn: deleteShiftParameters,
8700
+ const { control, handleSubmit, reset, setValue } = useForm({
8701
+ defaultValues: settingSelected ? settingSelected : INITIAL_VALUES$1,
8702
+ });
8703
+ const removeSetting = useMutation({
8704
+ mutationFn: deleteSetting,
8489
8705
  onSuccess: () => {
8490
8706
  setOpen(true);
8491
8707
  onHide(true);
@@ -8495,122 +8711,65 @@ const DeleteShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8495
8711
  },
8496
8712
  onSettled: () => {
8497
8713
  setIsSubmitLoading(false);
8498
- setDeleteAlert(false);
8499
8714
  },
8500
8715
  });
8501
- const onDelete = (data) => __awaiter(void 0, void 0, void 0, function* () {
8716
+ const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
8502
8717
  setIsSubmitLoading(true);
8503
- yield deleteShift.mutate(data);
8718
+ yield removeSetting.mutate(data.SettingName);
8504
8719
  });
8505
8720
  const handleClose = (event, reason) => {
8506
8721
  if (reason === "clickaway") {
8507
8722
  return;
8508
8723
  }
8509
8724
  setOpen(false);
8510
- setDeleteAlert(false);
8511
8725
  };
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
8726
  useEffect(() => {
8519
- var _a, _b, _c, _d, _e, _f;
8520
8727
  if (show) {
8521
8728
  reset();
8522
- setValue("PatternStart", (_a = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) !== null && _a !== void 0 ? _a : new Date());
8523
- setValue("ShiftCodes", (_b = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.ShiftCodes) !== null && _b !== void 0 ? _b : "");
8524
- setValue("Crews", (_c = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Crews) !== null && _c !== void 0 ? _c : "");
8525
- setValue("PatternDays", (_d = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternDays) !== null && _d !== void 0 ? _d : 0);
8526
- setValue("CrewRotation", (_e = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.CrewRotation) !== null && _e !== void 0 ? _e : "");
8527
- setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
8729
+ if (settingSelected) {
8730
+ setValue("SettingName", settingSelected.SettingName);
8731
+ setValue("Value", settingSelected.Value);
8732
+ setValue("Description", settingSelected.Description);
8733
+ }
8528
8734
  }
8529
8735
  }, [show]);
8530
8736
  return (React.createElement(React.Fragment, null,
8531
- show && (React.createElement(HelmetDexteel, { title: `Delete Shift${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
8532
- React.createElement(MesfModal, { title: "DELETE SHIFT", open: show, handleClose: () => onHide(false), id: "delete-shift-MesfModal", maxWidth: "md" },
8533
- React.createElement("form", null,
8534
- React.createElement(MesfModal.Content, null,
8535
- React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
8536
- React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
8537
- React.createElement(Grid2, { size: { md: 6, xs: 12 } },
8538
- React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
8539
- minWidth: "100%",
8540
- borderTopLeftRadius: 3,
8541
- borderTopRightRadius: 3,
8542
- }, label: "Start", value: value ? moment$f(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
8543
- textField: {
8544
- fullWidth: true,
8545
- variant: "standard",
8546
- disabled: true,
8547
- },
8548
- } })),
8549
- React.createElement(Grid2, { size: { md: 6, xs: 12 } },
8550
- 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: {
8551
- textField: {
8552
- fullWidth: true,
8553
- variant: "standard",
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("") }),
8737
+ show && (React.createElement(HelmetDexteel, { title: `Delete Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
8738
+ React.createElement(Grid2, { container: true },
8739
+ React.createElement(Grid2, null,
8740
+ React.createElement(MesfModal, { title: "DELETE SETTING", open: show, handleClose: () => onHide(false), id: "delete-setting-modal", maxWidth: "md" },
8741
+ React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
8742
+ React.createElement(MesfModal.Content, null,
8743
+ React.createElement(Grid2, { container: true, spacing: 2 },
8744
+ React.createElement(Grid2, { size: { xs: 12, md: 6 } },
8745
+ 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" }))) })),
8746
+ React.createElement(Grid2, { size: { xs: 12, md: 6 } },
8747
+ 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" }))) })),
8748
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
8749
+ 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) => {
8750
+ if (evt.target.value.length <= 200)
8751
+ onChange(evt);
8752
+ } })) })))),
8753
+ React.createElement(MesfModal.Actions, null,
8754
+ React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
8755
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
8756
+ React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
8757
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
8758
+ React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "secondary", type: "submit" }, "Delete")))))))),
8759
+ React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error deleting Setting" }),
8599
8760
  React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
8600
- React.createElement(Alert$1, { severity: "warning", onClose: handleClose }, "The shift was deleted successfully"))));
8761
+ React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was deleted successfully"))));
8601
8762
  };
8602
8763
 
8603
- const EditShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8604
- const theme = useTheme();
8764
+ const EditSetting = ({ settingSelected, show, onHide, suffixTitle, }) => {
8605
8765
  const [open, setOpen] = useState(false);
8606
- const [error, setError] = useState("");
8607
8766
  const [isSubmitLoading, setIsSubmitLoading] = useState(false);
8608
- const [initialShiftPerDayAndCrewsNumber, setInitialShiftPerDayAndCrewsNumber,] = useState(false);
8609
- const { control, setValue, handleSubmit, reset, watch, formState: { errors }, } = useForm({ defaultValues: INITIAL_VALUES$1 });
8610
- // Progress bar
8611
- const calculatePercentage = () => ((crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) / maxCrewRotationLength) * 100;
8612
- const createShift = useMutation({
8613
- mutationFn: ({ shiftData, isUpdate, }) => upsertShiftParameters(shiftData, isUpdate),
8767
+ const [error, setError] = useState("");
8768
+ const { control, handleSubmit, reset, setValue } = useForm({
8769
+ defaultValues: settingSelected ? settingSelected : INITIAL_VALUES$1,
8770
+ });
8771
+ const updateSetting = useMutation({
8772
+ mutationFn: upsertSettings,
8614
8773
  onSuccess: () => {
8615
8774
  setOpen(true);
8616
8775
  onHide(true);
@@ -8623,8 +8782,14 @@ const EditShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8623
8782
  },
8624
8783
  });
8625
8784
  const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
8785
+ var _a;
8626
8786
  setIsSubmitLoading(true);
8627
- yield createShift.mutate({ shiftData: data, isUpdate: true });
8787
+ yield updateSetting.mutate({
8788
+ oldName: (_a = settingSelected === null || settingSelected === void 0 ? void 0 : settingSelected.SettingName) !== null && _a !== void 0 ? _a : null,
8789
+ newName: data.SettingName,
8790
+ description: data.Description,
8791
+ value: data.Value,
8792
+ });
8628
8793
  });
8629
8794
  const handleClose = (event, reason) => {
8630
8795
  if (reason === "clickaway") {
@@ -8632,377 +8797,84 @@ const EditShift = ({ shiftSelected, show, onHide, suffixTitle, }) => {
8632
8797
  }
8633
8798
  setOpen(false);
8634
8799
  };
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
8800
  useEffect(() => {
8645
- var _a, _b, _c, _d, _e, _f;
8646
8801
  if (show) {
8647
8802
  reset();
8648
- setValue("PatternStart", (_a = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) !== null && _a !== void 0 ? _a : new Date());
8649
- setValue("ShiftCodes", (_b = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.ShiftCodes) !== null && _b !== void 0 ? _b : "");
8650
- setValue("Crews", (_c = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Crews) !== null && _c !== void 0 ? _c : "");
8651
- setValue("PatternDays", (_d = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternDays) !== null && _d !== void 0 ? _d : 0);
8652
- setValue("CrewRotation", (_e = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.CrewRotation) !== null && _e !== void 0 ? _e : "");
8653
- setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
8654
- setInitialShiftPerDayAndCrewsNumber(!initialShiftPerDayAndCrewsNumber);
8803
+ if (settingSelected) {
8804
+ setValue("SettingName", settingSelected.SettingName);
8805
+ setValue("Value", settingSelected.Value);
8806
+ setValue("Description", settingSelected.Description);
8807
+ }
8655
8808
  }
8656
8809
  }, [show]);
8657
- useEffect(() => {
8658
- setValue("ShiftsPerDay", crewRotation.length / rotationPattern);
8659
- setValue("NumberOfCrews", crewsCodes.length);
8660
- }, [initialShiftPerDayAndCrewsNumber]);
8661
8810
  return (React.createElement(React.Fragment, null,
8662
- show && (React.createElement(HelmetDexteel, { title: `Edit Shift${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
8663
- React.createElement(MesfModal, { title: "EDIT SHIFT", open: show, handleClose: () => onHide(false), id: "edit-shift-modal", maxWidth: "md" },
8811
+ show && (React.createElement(HelmetDexteel, { title: `Edit Setting${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
8812
+ React.createElement(MesfModal, { title: "EDIT SETTING", open: show, handleClose: () => onHide(false), id: "edit-setting-modal", maxWidth: "md" },
8664
8813
  React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
8665
8814
  React.createElement(MesfModal.Content, null,
8666
- React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
8667
- React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
8668
- React.createElement(Grid2, { size: { md: 6, xs: 12 } },
8669
- React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
8670
- minWidth: "100%",
8671
- borderTopLeftRadius: 3,
8672
- borderTopRightRadius: 3,
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})` })))),
8815
+ React.createElement(Grid2, { container: true, spacing: 2 },
8816
+ React.createElement(Grid2, { size: { xs: 12, md: 6 } },
8817
+ 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" }))) })),
8818
+ React.createElement(Grid2, { size: { xs: 12, md: 6 } },
8819
+ React.createElement(Controller, { name: "Value", control: control, rules: {
8820
+ required: "Value is required",
8821
+ }, render: ({ field, fieldState: { error } }) => (React.createElement(TextField, Object.assign({}, field, { label: "Value", error: !!error, helperText: error ? error.message : null, autoComplete: "off" }))) })),
8766
8822
  React.createElement(Grid2, { size: { md: 12, xs: 12 } },
8767
- 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) => {
8823
+ 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
8824
  if (evt.target.value.length <= 200)
8769
8825
  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"))))))),
8826
+ } })) })))),
8784
8827
  React.createElement(MesfModal.Actions, null,
8785
8828
  React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
8786
- React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
8829
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
8787
8830
  React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
8788
- React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
8831
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
8789
8832
  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("") }),
8833
+ React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error updating Setting" }),
8791
8834
  React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
8792
- React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The shift was created successfully"))));
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 };
8835
+ React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The setting was edited successfully"))));
8942
8836
  };
8943
8837
 
8944
- const useSearchShifts = () => {
8838
+ const useSearchSettings = () => {
8945
8839
  return useQuery({
8946
- queryKey: ["shifts"],
8947
- queryFn: ({ signal }) => getShiftParameters(signal),
8840
+ queryKey: ["settings"],
8841
+ queryFn: ({ signal }) => getUTLSettings(signal),
8948
8842
  });
8949
8843
  };
8950
- const TableShiftsCrews = () => {
8951
- const gridRef = useRef(null);
8952
- const [error, setError] = useState("");
8953
- const [openModalNew, setOpenModalNew] = useState(false);
8954
- const [openModalEditShift, setOpenModalEditShift] = useState(false);
8955
- const [openModalDeleteShift, setOpenModalDeleteShift] = useState(false);
8956
- const [shiftSelected, setShiftSelected] = useState(null);
8957
- const { data: rows, isLoading, isError, error: e, refetch, } = useSearchShifts();
8958
- const formattedRows = rows === null || rows === void 0 ? void 0 : rows.map(({ PatternStart, ShiftCodes, Crews, PatternDays, CrewRotation, Comments, CanEdit, }) => ({
8959
- id: ShiftCodes,
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,
8844
+ const TableSettings = () => {
8845
+ const queryClient = useQueryClient();
8846
+ const { showContextMenu, registerConfig } = useContextMenuMESF();
8847
+ const [error, setError] = useState("");
8848
+ const [gridApi, setGridApi] = useState(null);
8849
+ const [filterValue, setFilterValue] = useState("");
8850
+ const [settingSelected, setSettingSelected] = useState(null);
8851
+ const [openModalNew, setOpenModalNew] = useState(false);
8852
+ const [openModalEditSetting, setOpenModalEditSetting] = useState(false);
8853
+ const [openModalDeleteSetting, setOpenModalDeleteSetting] = useState(false);
8854
+ const { data: rows, isLoading, isError, error: e } = useSearchSettings();
8855
+ const { getMenuOptions } = useSettingsOptionsFunctions({
8856
+ setSettingId: setSettingSelected,
8857
+ setShowDeleteModal: setOpenModalDeleteSetting,
8984
8858
  setShowCreateModal: setOpenModalNew,
8985
- setShowDeleteModal: setOpenModalDeleteShift,
8986
- setShowEditModal: setOpenModalEditShift,
8859
+ setShowEditModal: setOpenModalEditSetting,
8987
8860
  });
8988
- const { showContextMenu, registerConfig } = useContextMenuMESF();
8989
- const { columnDefs } = useTableData$5({
8990
- setShiftSelected,
8991
- setOpenModalEditShift,
8992
- setOpenModalDeleteShift,
8861
+ const { columnDefs, defaultColDef } = useTableData$5({
8862
+ setOpenModalEditSetting,
8863
+ setOpenModalDeleteSetting,
8993
8864
  showContextMenu,
8865
+ setSettingSelected,
8994
8866
  });
8995
8867
  const getContextMenuItems = (params) => {
8996
8868
  var _a, _b;
8997
8869
  const data = (_a = params.node) === null || _a === void 0 ? void 0 : _a.data;
8998
8870
  params.api.deselectAll();
8999
8871
  (_b = params.node) === null || _b === void 0 ? void 0 : _b.setSelected(true);
9000
- showContextMenu(event, data, "TableShifts");
8872
+ showContextMenu(event, data, "TableSettings");
9001
8873
  return [];
9002
8874
  };
9003
8875
  useEffect(() => {
9004
8876
  registerConfig({
9005
- id: "TableShifts",
8877
+ id: "TableSettings",
9006
8878
  getOptions: getMenuOptions,
9007
8879
  });
9008
8880
  }, []);
@@ -9011,225 +8883,700 @@ const TableShiftsCrews = () => {
9011
8883
  setError(e.message);
9012
8884
  }
9013
8885
  }, [e, isError]);
9014
- return (React.createElement(React.Fragment, null,
9015
- React.createElement(Grid2, { container: true, justifyContent: "center", alignItems: "center", p: 1, spacing: 1 },
9016
- React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9017
- React.createElement(Typography$1, { variant: "h5", fontWeight: 600 }, "Shifts / Crew")),
9018
- React.createElement(Grid2, { container: true, justifyContent: "center", alignItems: "center" },
9019
- React.createElement(Grid2, { container: true, size: { md: 12, xs: 12 } },
9020
- React.createElement(Grid2, { component: Paper, size: { md: 12, xs: 12 }, style: {
9021
- height: "70vh",
9022
- } },
9023
- React.createElement(AgGridReact, { loading: isLoading, gridOptions: {
8886
+ return (React__default.createElement(React__default.Fragment, null,
8887
+ React__default.createElement(Grid2, { container: true, justifyContent: "center", p: 1, spacing: 1 },
8888
+ React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
8889
+ React__default.createElement(Typography$1, { variant: "h5", fontWeight: 600 }, "Settings")),
8890
+ React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
8891
+ React__default.createElement(TextField, { fullWidth: true, label: "Search", variant: "outlined", size: "small", margin: "dense", value: filterValue, onChange: (event) => {
8892
+ setFilterValue(event.target.value);
8893
+ gridApi === null || gridApi === void 0 ? void 0 : gridApi.setGridOption("quickFilterText", event.target.value);
8894
+ }, slotProps: {
8895
+ input: {
8896
+ startAdornment: (React__default.createElement(InputAdornment, { position: "start" },
8897
+ React__default.createElement(IconButton$1, { edge: "start", type: "submit" },
8898
+ React__default.createElement(SearchIcon, null)))),
8899
+ },
8900
+ } })),
8901
+ React__default.createElement(Grid2, { container: true, size: { md: 12, xs: 12 } },
8902
+ React__default.createElement(Grid2, { size: { md: 12, xs: 12 }, style: {
8903
+ height: "70vh",
8904
+ } },
8905
+ React__default.createElement(Paper, { style: { height: "100%", width: "100%" } },
8906
+ React__default.createElement(AgGridReact, { loading: isLoading, gridOptions: {
9024
8907
  theme: themeDXT,
9025
- }, ref: gridRef, rowData: formattedRows || [], columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 34, headerHeight: 34, animateRows: true, loadingOverlayComponent: CenteredLazyLoading, getContextMenuItems: (e) => getContextMenuItems(e), rowSelection: "single", onRowDoubleClicked: (event) => {
9026
- setShiftSelected(event.data);
9027
- setOpenModalEditShift(true);
9028
- } })),
9029
- React.createElement(Grid2, { container: true, justifyContent: "flex-end" },
9030
- React.createElement(Grid2, { size: { md: 2, xs: 12 } },
9031
- React.createElement(Button, { variant: "contained", color: "primary", onClick: () => setOpenModalNew(!openModalNew), fullWidth: true }, "NEW SHIFT")))))),
9032
- React.createElement(CreateShift, { shiftSelected: shiftSelected, show: openModalNew, onHide: (shouldUpdate) => {
8908
+ }, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 34, headerHeight: 34, animateRows: true, loadingOverlayComponent: CenteredLazyLoading, getContextMenuItems: (e) => getContextMenuItems(e), rowSelection: "single", onRowDoubleClicked: (event) => {
8909
+ setSettingSelected(event.data);
8910
+ setOpenModalEditSetting(true);
8911
+ }, onGridReady: (params) => setGridApi(params.api) }))),
8912
+ React__default.createElement(Grid2, { container: true, justifyContent: "flex-end" },
8913
+ React__default.createElement(Grid2, { size: { md: 2, xs: 12 } },
8914
+ React__default.createElement(Button, { variant: "contained", color: "primary", onClick: () => setOpenModalNew(!openModalNew), fullWidth: true }, "NEW SETTING"))))),
8915
+ React__default.createElement(CreateSetting, { settingSelected: settingSelected, show: openModalNew, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
9033
8916
  setOpenModalNew(false);
9034
8917
  if (shouldUpdate)
9035
- refetch();
9036
- }, suffixTitle: "Shifts / Crew" }),
9037
- React.createElement(EditShift, { shiftSelected: shiftSelected, show: openModalEditShift, onHide: (shouldUpdate) => {
9038
- setOpenModalEditShift(false);
8918
+ yield queryClient.invalidateQueries({ queryKey: ["settings"] });
8919
+ }), suffixTitle: "Settings" }),
8920
+ React__default.createElement(EditSetting, { settingSelected: settingSelected, show: openModalEditSetting, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
8921
+ setOpenModalEditSetting(false);
9039
8922
  if (shouldUpdate)
9040
- refetch();
9041
- }, suffixTitle: "Shifts / Crew" }),
9042
- React.createElement(DeleteShift, { shiftSelected: shiftSelected, show: openModalDeleteShift, onHide: (shouldUpdate) => {
9043
- setOpenModalDeleteShift(false);
8923
+ yield queryClient.invalidateQueries({ queryKey: ["settings"] });
8924
+ }), suffixTitle: "Settings" }),
8925
+ React__default.createElement(DeleteSetting, { settingSelected: settingSelected, show: openModalDeleteSetting, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
8926
+ setOpenModalDeleteSetting(false);
9044
8927
  if (shouldUpdate)
9045
- refetch();
9046
- }, suffixTitle: "Shifts / Crew" })));
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);
8928
+ yield queryClient.invalidateQueries({ queryKey: ["settings"] });
8929
+ }), suffixTitle: "Settings" }),
8930
+ React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
9071
8931
  };
9072
8932
 
9073
- const CurrencyFormatter = new Intl.NumberFormat("en-US", {
9074
- style: "currency",
9075
- currency: "USD",
9076
- });
9077
- const NumberFormatter = new Intl.NumberFormat("en-US", {
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" })));
8933
+ const searchSettings = () => {
8934
+ return useQuery({
8935
+ queryKey: ["settings"],
8936
+ queryFn: ({ signal }) => getUTLSettings(signal),
8937
+ });
9137
8938
  };
9138
- const GetCrewColor = (props) => {
8939
+ const SettingsPage = () => {
9139
8940
  return (React__default.createElement(React__default.Fragment, null,
9140
- React__default.createElement(Square$1, { sx: Object.assign({ mr: 1 }, getCrewStyle(props.value)), fontSize: "small" })));
8941
+ React__default.createElement(HelmetDexteel, { title: "Settings" }),
8942
+ React__default.createElement(TableSettings, null)));
9141
8943
  };
9142
8944
 
9143
- const AssetInitialState = {
9144
- areasList: [],
9145
- allAssets: [],
9146
- plantAssetId: 1,
8945
+ const UTLSettingsInitialState = {
8946
+ serverTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
8947
+ settings: {},
9147
8948
  };
9148
- const AssetReducer = createSlice({
8949
+ const UTLSettingsReducer = createSlice({
9149
8950
  name: "__",
9150
- initialState: AssetInitialState,
8951
+ initialState: UTLSettingsInitialState,
9151
8952
  reducers: {
9152
- setAreasList(state, { payload }) {
9153
- state.areasList = payload;
8953
+ setServerTimeZone(state, { payload }) {
8954
+ state.serverTimeZone = payload;
9154
8955
  },
9155
- setAllAssets(state, { payload }) {
9156
- state.allAssets = payload;
8956
+ setSetting(state, { payload }) {
8957
+ state.settings[payload.key] = payload.value;
9157
8958
  },
9158
- setPlantAssetId(state, { payload }) {
9159
- state.plantAssetId = payload;
8959
+ initSettings(state, { payload }) {
8960
+ state.settings = payload.reduce((acc, cur) => {
8961
+ if (cur.SettingName.trim().toLowerCase() === "timezone") {
8962
+ const timeService = TimeService.getInstance();
8963
+ timeService.setTimeZone(cur.Value);
8964
+ }
8965
+ acc[cur.SettingName.trim()] = cur.Value;
8966
+ return acc;
8967
+ }, {});
9160
8968
  },
9161
8969
  },
9162
8970
  });
9163
8971
 
9164
- const AssetContext = createContext({
9165
- state: AssetReducer.getInitialState(),
9166
- actions: AssetReducer.actions,
8972
+ const UTLSettingsContext = createContext({
8973
+ state: UTLSettingsReducer.getInitialState(),
8974
+ actions: UTLSettingsReducer.actions,
8975
+ isLoading: true,
9167
8976
  });
9168
- const useAssetContext = () => useContext(AssetContext);
9169
- const AssetProvider = ({ children, plantAssetId = 1, }) => {
8977
+ const useUTLSettingsContext = () => useContext(UTLSettingsContext);
8978
+ const UTLSettingsProvider = ({ children }) => {
9170
8979
  const [state, actions] = useComplexState({
9171
- initialState: {
9172
- areasList: [],
9173
- allAssets: [],
9174
- plantAssetId,
8980
+ initialState: UTLSettingsReducer.getInitialState(),
8981
+ reducers: UTLSettingsReducer.caseReducers,
8982
+ });
8983
+ const { data: rows, isLoading, isError, error: e, isSuccess, refetch, } = searchSettings();
8984
+ useEffect(() => {
8985
+ if (isSuccess) {
8986
+ const settings = rows;
8987
+ const settingsTrimmed = settings.map((setting) => (Object.assign(Object.assign({}, setting), { SettingName: setting.SettingName.trim() })));
8988
+ actions.initSettings(settingsTrimmed);
8989
+ }
8990
+ }, [isSuccess]);
8991
+ useEffect(() => {
8992
+ if (e && isError) {
8993
+ console.error(e.message);
8994
+ }
8995
+ }, [e, isError]);
8996
+ useMesfRealtime({
8997
+ onReceiveMessage: (author, message) => {
8998
+ if (message === "UTL.GetSettings") {
8999
+ refetch();
9000
+ }
9175
9001
  },
9176
- reducers: AssetReducer.caseReducers,
9177
9002
  });
9178
- return (React__default.createElement(AssetContext.Provider, { value: { state, actions } }, children));
9003
+ return (React__default.createElement(UTLSettingsContext.Provider, { value: { state, actions, isLoading } }, children));
9179
9004
  };
9180
9005
 
9181
- const LogbookSettingsInitialState = {
9182
- entry: {
9183
- withAssetFilter: undefined,
9184
- filterAssets: undefined,
9185
- canEditAsset: false,
9186
- allowAttachments: false,
9187
- canEditShift: false,
9188
- showShiftCrew: false,
9189
- exportToExcel: false,
9190
- shiftsRange: 7,
9191
- presetAssetId: undefined,
9192
- },
9193
- report: {
9194
- withAssetFilter: undefined,
9195
- filterAssets: undefined,
9196
- showAttachments: false,
9197
- showAsset: false,
9198
- showShiftCrew: false,
9199
- exportToExcel: false,
9200
- },
9201
- section: {
9202
- schema: undefined,
9203
- withAssetFilter: undefined,
9204
- filterAssets: undefined,
9205
- canEditAsset: false,
9206
- allowAttachments: false,
9207
- showShiftCrew: false,
9208
- exportToExcel: false,
9209
- topSectionsCount: 5,
9210
- },
9006
+ const getShiftParameters = (assetId, signal) => __awaiter(void 0, void 0, void 0, function* () {
9007
+ const apiService = new MESApiService();
9008
+ const parameters = [{ name: "AssetId", value: assetId }];
9009
+ const resp = yield apiService.callV2("[MES].[GetShiftParameters]", parameters, signal);
9010
+ if (resp.ok) {
9011
+ return get(resp, "data.tables[0].rows", []);
9012
+ }
9013
+ else {
9014
+ throw new Error(resp.message || "Error fetching shifts");
9015
+ }
9016
+ });
9017
+ 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) {
9018
+ const apiService = new MESApiService();
9019
+ const parameters = [
9020
+ { name: "AssetId", value: assetId },
9021
+ { name: "PatternStart", value: PatternStart },
9022
+ { name: "ShiftCodes", value: ShiftCodes },
9023
+ { name: "Crews", value: Crews },
9024
+ { name: "CrewRotation", value: CrewRotation },
9025
+ { name: "Comments", value: Comments },
9026
+ { name: "IsUpdate", value: isUpdate },
9027
+ ];
9028
+ const resp = yield apiService.callV2("[MES].[UpsertShiftParameters]", parameters);
9029
+ if (!resp.ok) {
9030
+ throw new Error(resp.message || "Error when upsert shift");
9031
+ }
9032
+ });
9033
+ const deleteShiftParameters = (assetId, PatternStart) => __awaiter(void 0, void 0, void 0, function* () {
9034
+ const apiService = new MESApiService();
9035
+ const parameters = [];
9036
+ parameters.push({ name: "AssetId", value: assetId });
9037
+ parameters.push({ name: "PatternStart", value: PatternStart });
9038
+ const resp = yield apiService.callV2("[MES].[DeleteShiftParameters]", parameters);
9039
+ if (!resp.ok) {
9040
+ throw new Error(resp.message || "Error when delete shift");
9041
+ }
9042
+ });
9043
+
9044
+ const INITIAL_VALUES = {
9045
+ PatternStart: new Date(),
9046
+ ShiftCodes: "",
9047
+ Crews: "",
9048
+ User: "",
9049
+ PatternDays: 5,
9050
+ CrewRotation: "",
9051
+ Comments: "",
9052
+ CanEdit: false,
9053
+ ShiftsPerDay: 1,
9054
+ NumberOfCrews: 1,
9055
+ };
9056
+
9057
+ const CreateShift = ({ shiftSelected, show, onHide, suffixTitle, assetId, assetName, }) => {
9058
+ var _a, _b;
9059
+ const theme = useTheme();
9060
+ const [open, setOpen] = useState(false);
9061
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
9062
+ const [error, setError] = useState("");
9063
+ const { control, handleSubmit, reset, watch, setValue, formState: { errors }, } = useForm({
9064
+ defaultValues: shiftSelected ? shiftSelected : INITIAL_VALUES,
9065
+ });
9066
+ // Progress bar
9067
+ const calculatePercentage = () => ((crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) / maxCrewRotationLength) * 100;
9068
+ const createShift = useMutation({
9069
+ mutationFn: (data) => upsertShiftParameters(data, assetId),
9070
+ onSuccess: () => {
9071
+ setOpen(true);
9072
+ onHide(true);
9073
+ },
9074
+ onError: (error) => {
9075
+ setError(error.message);
9076
+ },
9077
+ onSettled: () => {
9078
+ setIsSubmitLoading(false);
9079
+ },
9080
+ });
9081
+ const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
9082
+ setIsSubmitLoading(true);
9083
+ yield createShift.mutate(data);
9084
+ });
9085
+ const handleClose = (event, reason) => {
9086
+ if (reason === "clickaway") {
9087
+ return;
9088
+ }
9089
+ setOpen(false);
9090
+ };
9091
+ // const patternStart = watch('PatternStart');
9092
+ const shiftsPerDay = watch("ShiftsPerDay");
9093
+ const shiftCodes = watch("ShiftCodes");
9094
+ const numberOfCrews = watch("NumberOfCrews");
9095
+ const crewsCodes = watch("Crews");
9096
+ const rotationPattern = watch("PatternDays");
9097
+ const crewRotation = watch("CrewRotation");
9098
+ const comments = watch("Comments");
9099
+ const maxCrewRotationLength = shiftsPerDay * rotationPattern;
9100
+ useEffect(() => {
9101
+ if (show) {
9102
+ reset();
9103
+ setValue("PatternStart", new Date());
9104
+ }
9105
+ }, [show]);
9106
+ return (React.createElement(React.Fragment, null,
9107
+ show && (React.createElement(HelmetDexteel, { title: `New Shift/Crew${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
9108
+ React.createElement(MesfModal, { title: "NEW SHIFT/CREW", open: show, handleClose: () => onHide(false), id: "create-shift-modal", maxWidth: "md" },
9109
+ React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
9110
+ React.createElement(MesfModal.Content, null,
9111
+ React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
9112
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9113
+ React.createElement(TextField, { label: "Asset", value: assetName, disabled: true, fullWidth: true, variant: "outlined", margin: "dense" })),
9114
+ React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
9115
+ React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9116
+ React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
9117
+ minWidth: "100%",
9118
+ borderTopLeftRadius: 3,
9119
+ borderTopRightRadius: 3,
9120
+ }, label: "Start", value: value ? moment$g(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
9121
+ textField: {
9122
+ fullWidth: true,
9123
+ variant: "standard",
9124
+ },
9125
+ } })),
9126
+ React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9127
+ React.createElement(DatePicker$1, { label: "Time", value: value ? moment$g(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
9128
+ textField: {
9129
+ fullWidth: true,
9130
+ variant: "standard",
9131
+ },
9132
+ } })))) }),
9133
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9134
+ React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
9135
+ min: 1,
9136
+ }, 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 &&
9137
+ parseInt(evt.target.value) <= 10 &&
9138
+ onChange(evt) })) }),
9139
+ ((_a = errors.ShiftsPerDay) === null || _a === void 0 ? void 0 : _a.type) === "min" && (React.createElement(ErrorLabel, { text: "Shift per day is required" }))),
9140
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9141
+ React.createElement(Controller, { name: "ShiftCodes", control: control, rules: {
9142
+ validate: (value) => value.length == shiftsPerDay,
9143
+ }, 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) => {
9144
+ // TODO: aquí podriamos hacer que no pueda haber dos valores iguales, para prevenir errores. Ej. dos DNN
9145
+ if (evt.target.value.length <= shiftsPerDay)
9146
+ onChange(evt.target.value.toString().toUpperCase());
9147
+ } })) }),
9148
+ !!errors.ShiftCodes && (React.createElement("span", { style: {
9149
+ fontSize: 12,
9150
+ } },
9151
+ "Please put ",
9152
+ shiftsPerDay,
9153
+ " shifts")),
9154
+ shiftCodes.length < shiftsPerDay &&
9155
+ !!errors.ShiftCodes === false && (React.createElement("span", { style: {
9156
+ fontSize: 12,
9157
+ color: theme.palette.info.main,
9158
+ } }, `Insert: ${shiftsPerDay} ${shiftsPerDay == 1 ? "Id" : "Ids"}. ${shiftsPerDay > 1 ? "The Ids must be differents" : ""}`))),
9159
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9160
+ React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
9161
+ min: 1,
9162
+ max: 9,
9163
+ }, 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) => {
9164
+ // max. crew 15
9165
+ if (parseInt(evt.target.value) >= 1 &&
9166
+ parseInt(evt.target.value) <= 15)
9167
+ onChange(evt);
9168
+ }, value: value })) }),
9169
+ ((_b = errors.NumberOfCrews) === null || _b === void 0 ? void 0 : _b.type) === "min" && (React.createElement(ErrorLabel, { text: "# Crews days is required" }))),
9170
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9171
+ React.createElement(Controller, { name: "Crews", control: control, rules: {
9172
+ validate: (value) => value.length == numberOfCrews,
9173
+ }, 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) => {
9174
+ if (evt.target.value.length <= numberOfCrews)
9175
+ onChange(evt.target.value.toString().toUpperCase());
9176
+ } })) }),
9177
+ !!errors.Crews && (React.createElement("span", { style: {
9178
+ fontSize: 12,
9179
+ } },
9180
+ "Please put ",
9181
+ numberOfCrews,
9182
+ " crews")),
9183
+ crewsCodes.length < numberOfCrews &&
9184
+ !!errors.Crews === false && (React.createElement("span", { style: {
9185
+ fontSize: 12,
9186
+ color: theme.palette.info.main,
9187
+ } }, `Insert: ${numberOfCrews} ${numberOfCrews == 1 ? "Crew" : "Crews"}. ${numberOfCrews > 1 ? "The Crews must be differents" : ""}`))),
9188
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9189
+ 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) => {
9190
+ if (parseInt(evt.target.value) >= 5 &&
9191
+ parseInt(evt.target.value) <= 60)
9192
+ onChange(evt);
9193
+ } })) })),
9194
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9195
+ React.createElement(Controller, { name: "CrewRotation", control: control, rules: {
9196
+ validate: (value) => value.length == maxCrewRotationLength,
9197
+ }, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { value: value, onChange: (evt) => {
9198
+ if (evt.target.value.length <= maxCrewRotationLength)
9199
+ onChange(evt.target.value.toString().toUpperCase());
9200
+ }, label: "Crew rotation", variant: "outlined", fullWidth: true, error: !!errors.CrewRotation, margin: "dense", autoComplete: "off" })) }),
9201
+ React.createElement(Grid2, { container: true, height: 2 },
9202
+ React.createElement(Grid2, { style: {
9203
+ height: 2,
9204
+ width: `${calculatePercentage()}% `,
9205
+ backgroundColor: `${crewRotation.length == maxCrewRotationLength
9206
+ ? "#4CAF50"
9207
+ : "#F44336"}`,
9208
+ transition: " 0.2s ease",
9209
+ margin: "0 5px",
9210
+ } })),
9211
+ React.createElement(Grid2, { container: true, style: { margin: "4px 0 0" } },
9212
+ React.createElement(Grid2, null, (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) >= 1 &&
9213
+ (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) !==
9214
+ maxCrewRotationLength && (React.createElement("span", { style: {
9215
+ fontSize: 12,
9216
+ color: theme.palette.info.main,
9217
+ marginLeft: 5,
9218
+ } }, `${crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length}/${maxCrewRotationLength}`)))),
9219
+ !!errors.CrewRotation && (React.createElement(ErrorLabel, { text: `Please put ${maxCrewRotationLength} crews` })),
9220
+ numberOfCrews > 0 &&
9221
+ Number.isInteger(maxCrewRotationLength / numberOfCrews) ===
9222
+ false && (React.createElement(Grid2, { container: true, style: { padding: "0", marginLeft: 5 } },
9223
+ React.createElement(ErrorLabel, { text: `Rotation # not a multiple of Shifts (${maxCrewRotationLength}) / Crews (${numberOfCrews})` })))),
9224
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9225
+ 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) => {
9226
+ if (evt.target.value.length <= 200)
9227
+ onChange(evt);
9228
+ } })) }),
9229
+ React.createElement(Grid2, { container: true, style: { marginBottom: 18 } },
9230
+ React.createElement(Grid2, null,
9231
+ (comments === null || comments === void 0 ? void 0 : comments.length) >= 1 &&
9232
+ (comments === null || comments === void 0 ? void 0 : comments.length) !== 200 && (React.createElement("span", { style: {
9233
+ fontSize: 12,
9234
+ color: theme.palette.info.main,
9235
+ marginLeft: 5,
9236
+ } }, `${comments === null || comments === void 0 ? void 0 : comments.length}/200 max.`)),
9237
+ (comments === null || comments === void 0 ? void 0 : comments.length) == 200 && (React.createElement("span", { style: {
9238
+ fontSize: 12,
9239
+ color: theme.palette.info.main,
9240
+ marginLeft: 5,
9241
+ } }, "Max. 200"))))))),
9242
+ React.createElement(MesfModal.Actions, null,
9243
+ React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
9244
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
9245
+ React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
9246
+ React.createElement(Grid2, { size: { md: 3, xs: 12 } },
9247
+ React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))),
9248
+ React.createElement(ErrorModal, { error: error, onHide: () => setError(""), title: "Error Creating Shift" }),
9249
+ React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
9250
+ React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The shift was created successfully"))));
9251
+ };
9252
+
9253
+ const DeleteShift = ({ shiftSelected, show, onHide, suffixTitle, assetId, assetName, }) => {
9254
+ var _a;
9255
+ const [open, setOpen] = useState(false);
9256
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
9257
+ const [deleteAlert, setDeleteAlert] = useState(false);
9258
+ const [error, setError] = useState("");
9259
+ const { control, setValue, reset, watch, formState: { errors }, } = useForm({ defaultValues: INITIAL_VALUES });
9260
+ const deleteShift = useMutation({
9261
+ mutationFn: (patternStart) => deleteShiftParameters(assetId, patternStart),
9262
+ onSuccess: () => {
9263
+ setOpen(true);
9264
+ onHide(true);
9265
+ },
9266
+ onError: (error) => {
9267
+ setError(error.message);
9268
+ },
9269
+ onSettled: () => {
9270
+ setIsSubmitLoading(false);
9271
+ setDeleteAlert(false);
9272
+ },
9273
+ });
9274
+ const onDelete = (data) => __awaiter(void 0, void 0, void 0, function* () {
9275
+ setIsSubmitLoading(true);
9276
+ yield deleteShift.mutate(data);
9277
+ });
9278
+ const handleClose = (event, reason) => {
9279
+ if (reason === "clickaway") {
9280
+ return;
9281
+ }
9282
+ setOpen(false);
9283
+ setDeleteAlert(false);
9284
+ };
9285
+ const patternStart = watch("PatternStart");
9286
+ const shiftsPerDay = watch("ShiftsPerDay");
9287
+ const crewRotation = watch("CrewRotation");
9288
+ const numberOfCrews = watch("NumberOfCrews");
9289
+ const crewsCodes = watch("Crews");
9290
+ const rotationPattern = watch("PatternDays");
9291
+ useEffect(() => {
9292
+ var _a, _b, _c, _d, _e, _f;
9293
+ if (show) {
9294
+ reset();
9295
+ setValue("PatternStart", (_a = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) !== null && _a !== void 0 ? _a : new Date());
9296
+ setValue("ShiftCodes", (_b = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.ShiftCodes) !== null && _b !== void 0 ? _b : "");
9297
+ setValue("Crews", (_c = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Crews) !== null && _c !== void 0 ? _c : "");
9298
+ setValue("PatternDays", (_d = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternDays) !== null && _d !== void 0 ? _d : 0);
9299
+ setValue("CrewRotation", (_e = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.CrewRotation) !== null && _e !== void 0 ? _e : "");
9300
+ setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
9301
+ }
9302
+ }, [show]);
9303
+ return (React.createElement(React.Fragment, null,
9304
+ show && (React.createElement(HelmetDexteel, { title: `Delete Shift${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
9305
+ React.createElement(MesfModal, { title: "DELETE SHIFT", open: show, handleClose: () => onHide(false), id: "delete-shift-MesfModal", maxWidth: "md" },
9306
+ React.createElement("form", null,
9307
+ React.createElement(MesfModal.Content, null,
9308
+ React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
9309
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9310
+ React.createElement(TextField, { label: "Asset", value: assetName, disabled: true, fullWidth: true, variant: "outlined", margin: "dense" })),
9311
+ React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
9312
+ React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9313
+ React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
9314
+ minWidth: "100%",
9315
+ borderTopLeftRadius: 3,
9316
+ borderTopRightRadius: 3,
9317
+ }, label: "Start", value: value ? moment$g(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
9318
+ textField: {
9319
+ fullWidth: true,
9320
+ variant: "standard",
9321
+ disabled: true,
9322
+ },
9323
+ } })),
9324
+ React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9325
+ React.createElement(DatePicker$1, { label: "Time", value: value ? moment$g(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
9326
+ textField: {
9327
+ fullWidth: true,
9328
+ variant: "standard",
9329
+ disabled: true,
9330
+ },
9331
+ } })))) }),
9332
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9333
+ React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
9334
+ min: 1,
9335
+ }, 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 })) }),
9336
+ ((_a = errors.ShiftsPerDay) === null || _a === void 0 ? void 0 : _a.type) === "min" && (React.createElement(ErrorLabel, { text: "Shift per day is required" }))),
9337
+ React.createElement(Grid2, { size: { md: 6, xs: 6 }, style: { paddingBottom: "0" } },
9338
+ 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 })) })),
9339
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9340
+ React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
9341
+ min: 1,
9342
+ max: 9,
9343
+ }, 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 })) })),
9344
+ React.createElement(Grid2, { size: { md: 6, xs: 6 }, style: { paddingBottom: "0" } },
9345
+ 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 })) })),
9346
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9347
+ 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 })) })),
9348
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9349
+ 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 })) })),
9350
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9351
+ 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 })) })))),
9352
+ React.createElement(MesfModal.Actions, null,
9353
+ React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
9354
+ React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
9355
+ React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
9356
+ React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
9357
+ React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading
9358
+ ? isSubmitLoading
9359
+ : shiftSelected
9360
+ ? new Date(shiftSelected.PatternStart) < new Date() &&
9361
+ true
9362
+ : false, variant: "contained", color: "secondary", onClick: () => setDeleteAlert(true) }, "Delete"),
9363
+ shiftSelected &&
9364
+ new Date(shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) < new Date() && (React.createElement(Grid2, null,
9365
+ React.createElement(ErrorLabel, { text: "Can not delete before the current date" })))))),
9366
+ React.createElement(Dialog$1, { open: deleteAlert, onClose: () => handleClose(), "aria-labelledby": "responsive-dialog-title" },
9367
+ React.createElement(DialogTitle$1, { id: "responsive-dialog-title" }, "WARNING"),
9368
+ React.createElement(DialogContent$1, null,
9369
+ 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?")),
9370
+ React.createElement(DialogActions$1, { style: { padding: "16px 24px" } },
9371
+ React.createElement(Button, { onClick: () => setDeleteAlert(false), autoFocus: true, color: "inherit" }, "CANCEL"),
9372
+ React.createElement(Button, { startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), autoFocus: true, color: "secondary", onClick: () => onDelete(patternStart) }, "Delete"))))),
9373
+ React.createElement(ErrorModal, { error: error, onHide: () => setError("") }),
9374
+ React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
9375
+ React.createElement(Alert$1, { severity: "warning", onClose: handleClose }, "The shift was deleted successfully"))));
9211
9376
  };
9212
9377
 
9213
- const LogbookSettingsContext = createContext(LogbookSettingsInitialState);
9214
- const useLogbookSettings = () => useContext(LogbookSettingsContext);
9215
- const LogbookSettingsProvider = ({ children, logbookSettings = {}, }) => {
9216
- // Merge default settings with provided settings
9217
- const settings = useMemo(() => ({
9218
- entry: Object.assign(Object.assign({}, LogbookSettingsInitialState.entry), (logbookSettings.entry || {})),
9219
- report: Object.assign(Object.assign({}, LogbookSettingsInitialState.report), (logbookSettings.report || {})),
9220
- section: Object.assign(Object.assign({}, LogbookSettingsInitialState.section), (logbookSettings.section || {})),
9221
- }), [logbookSettings]);
9222
- return (React__default.createElement(LogbookSettingsContext.Provider, { value: settings }, children));
9378
+ const EditShift = ({ shiftSelected, show, onHide, suffixTitle, assetId, assetName, }) => {
9379
+ const theme = useTheme();
9380
+ const [open, setOpen] = useState(false);
9381
+ const [error, setError] = useState("");
9382
+ const [isSubmitLoading, setIsSubmitLoading] = useState(false);
9383
+ const [initialShiftPerDayAndCrewsNumber, setInitialShiftPerDayAndCrewsNumber,] = useState(false);
9384
+ const { control, setValue, handleSubmit, reset, watch, formState: { errors }, } = useForm({ defaultValues: INITIAL_VALUES });
9385
+ // Progress bar
9386
+ const calculatePercentage = () => ((crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) / maxCrewRotationLength) * 100;
9387
+ const createShift = useMutation({
9388
+ mutationFn: ({ shiftData, isUpdate, }) => upsertShiftParameters(shiftData, assetId, isUpdate),
9389
+ onSuccess: () => {
9390
+ setOpen(true);
9391
+ onHide(true);
9392
+ },
9393
+ onError: (error) => {
9394
+ setError(error.message);
9395
+ },
9396
+ onSettled: () => {
9397
+ setIsSubmitLoading(false);
9398
+ },
9399
+ });
9400
+ const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
9401
+ setIsSubmitLoading(true);
9402
+ yield createShift.mutate({ shiftData: data, isUpdate: true });
9403
+ });
9404
+ const handleClose = (event, reason) => {
9405
+ if (reason === "clickaway") {
9406
+ return;
9407
+ }
9408
+ setOpen(false);
9409
+ };
9410
+ // const patternStart = watch('PatternStart');
9411
+ const shiftsPerDay = watch("ShiftsPerDay");
9412
+ const shiftCodes = watch("ShiftCodes");
9413
+ const numberOfCrews = watch("NumberOfCrews");
9414
+ const crewsCodes = watch("Crews");
9415
+ const rotationPattern = watch("PatternDays");
9416
+ const comments = watch("Comments");
9417
+ const crewRotation = watch("CrewRotation");
9418
+ const maxCrewRotationLength = shiftsPerDay * rotationPattern;
9419
+ useEffect(() => {
9420
+ var _a, _b, _c, _d, _e, _f;
9421
+ if (show) {
9422
+ reset();
9423
+ setValue("PatternStart", (_a = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternStart) !== null && _a !== void 0 ? _a : new Date());
9424
+ setValue("ShiftCodes", (_b = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.ShiftCodes) !== null && _b !== void 0 ? _b : "");
9425
+ setValue("Crews", (_c = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Crews) !== null && _c !== void 0 ? _c : "");
9426
+ setValue("PatternDays", (_d = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.PatternDays) !== null && _d !== void 0 ? _d : 0);
9427
+ setValue("CrewRotation", (_e = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.CrewRotation) !== null && _e !== void 0 ? _e : "");
9428
+ setValue("Comments", (_f = shiftSelected === null || shiftSelected === void 0 ? void 0 : shiftSelected.Comments) !== null && _f !== void 0 ? _f : "");
9429
+ setInitialShiftPerDayAndCrewsNumber(!initialShiftPerDayAndCrewsNumber);
9430
+ }
9431
+ }, [show]);
9432
+ useEffect(() => {
9433
+ setValue("ShiftsPerDay", crewRotation.length / rotationPattern);
9434
+ setValue("NumberOfCrews", crewsCodes.length);
9435
+ }, [initialShiftPerDayAndCrewsNumber]);
9436
+ return (React.createElement(React.Fragment, null,
9437
+ show && (React.createElement(HelmetDexteel, { title: `Edit Shift${suffixTitle ? ` - ${suffixTitle}` : ""}` })),
9438
+ React.createElement(MesfModal, { title: "EDIT SHIFT", open: show, handleClose: () => onHide(false), id: "edit-shift-modal", maxWidth: "md" },
9439
+ React.createElement("form", { onSubmit: handleSubmit(onSubmit) },
9440
+ React.createElement(MesfModal.Content, null,
9441
+ React.createElement(Grid2, { container: true, spacing: 2, p: 1 },
9442
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9443
+ React.createElement(TextField, { label: "Asset", value: assetName, disabled: true, fullWidth: true, variant: "outlined", margin: "dense" })),
9444
+ React.createElement(Controller, { name: "PatternStart", control: control, render: ({ field: { value, onChange } }) => (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
9445
+ React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9446
+ React.createElement(DatePicker$1, { format: "MM/DD/YYYY", sx: {
9447
+ minWidth: "100%",
9448
+ borderTopLeftRadius: 3,
9449
+ borderTopRightRadius: 3,
9450
+ }, label: "Start", value: value ? moment$g(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
9451
+ textField: {
9452
+ fullWidth: true,
9453
+ variant: "standard",
9454
+ },
9455
+ } })),
9456
+ React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9457
+ React.createElement(DatePicker$1, { label: "Time", value: value ? moment$g(value) : value, onChange: (evt) => onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()), slotProps: {
9458
+ textField: {
9459
+ fullWidth: true,
9460
+ variant: "standard",
9461
+ },
9462
+ } })))) }),
9463
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9464
+ React.createElement(Controller, { name: "ShiftsPerDay", control: control, rules: {
9465
+ min: 1,
9466
+ }, 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:
9467
+ // FIXME: límite de 10?
9468
+ (evt) => parseInt(evt.target.value) >= 1 &&
9469
+ parseInt(evt.target.value) <= 10 &&
9470
+ onChange(evt) })) })),
9471
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9472
+ React.createElement(Controller, { name: "ShiftCodes", control: control, rules: {
9473
+ required: `Please put ${shiftsPerDay} shifts`,
9474
+ validate: (value) => value.length == shiftsPerDay,
9475
+ }, 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) => {
9476
+ // TODO: aquí deberíamos prevenir, que no pueda haber dos valores iguales, . Ej. dos DNN
9477
+ if (evt.target.value.length <= shiftsPerDay)
9478
+ onChange(evt.target.value.toString().toUpperCase());
9479
+ } })) }),
9480
+ shiftCodes.length < shiftsPerDay &&
9481
+ !!errors.ShiftCodes === false && (React.createElement(ErrorLabel, { text: `Insert: ${shiftsPerDay} ${shiftsPerDay == 1 ? "Id" : "Ids"}. ${shiftsPerDay > 1 ? "The Ids must be differents" : ""}` }))),
9482
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9483
+ React.createElement(Controller, { name: "NumberOfCrews", control: control, rules: {
9484
+ required: "# Crews day is required",
9485
+ min: 1,
9486
+ max: 9,
9487
+ }, 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) => {
9488
+ if (parseInt(evt.target.value) >= 1 &&
9489
+ parseInt(evt.target.value) <= 9)
9490
+ onChange(evt);
9491
+ } })) })),
9492
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9493
+ React.createElement(Controller, { name: "Crews", control: control, rules: {
9494
+ required: `Please put ${numberOfCrews} crews`,
9495
+ validate: (value) => value.length == numberOfCrews,
9496
+ }, 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) => {
9497
+ if (evt.target.value.length <= numberOfCrews)
9498
+ onChange(evt.target.value.toString().toUpperCase());
9499
+ } })) }),
9500
+ crewsCodes.length < numberOfCrews &&
9501
+ !!errors.Crews === false && (React.createElement(ErrorLabel, { text: `Insert: ${numberOfCrews} ${numberOfCrews == 1 ? "Crew" : "Crews"}. ${numberOfCrews > 1 ? "The Crews must be differents" : ""}` }))),
9502
+ React.createElement(Grid2, { size: { md: 6, xs: 6 } },
9503
+ React.createElement(Controller, { name: "PatternDays", control: control,
9504
+ // rules={{
9505
+ // required: true
9506
+ // }}
9507
+ 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) => {
9508
+ // FIXME: consultar si estos valores están bien, son los limites del sP
9509
+ if (parseInt(evt.target.value) >= 5 &&
9510
+ parseInt(evt.target.value) <= 60)
9511
+ onChange(evt);
9512
+ } })) })),
9513
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9514
+ React.createElement(Controller, { name: "CrewRotation", control: control, rules: {
9515
+ validate: (value) => value.length == maxCrewRotationLength,
9516
+ }, render: ({ field: { value, onChange } }) => (React.createElement(TextField, { value: value, onChange: (evt) => {
9517
+ if (evt.target.value.length <= maxCrewRotationLength)
9518
+ onChange(evt.target.value.toString().toUpperCase());
9519
+ }, error: !!errors.CrewRotation, label: "Crew rotation", variant: "outlined", fullWidth: true, margin: "dense", autoComplete: "off" })) }),
9520
+ React.createElement(Grid2, { container: true, height: 2 },
9521
+ React.createElement(Grid2, { style: {
9522
+ height: 2,
9523
+ width: `${calculatePercentage()}% `,
9524
+ backgroundColor: `${crewRotation.length == maxCrewRotationLength
9525
+ ? "#4CAF50"
9526
+ : "#F44336"}`,
9527
+ transition: " 0.2s ease",
9528
+ margin: "0 5px",
9529
+ } })),
9530
+ React.createElement(Grid2, { container: true },
9531
+ React.createElement(Grid2, null, (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) >= 1 &&
9532
+ (crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length) !==
9533
+ maxCrewRotationLength && (React.createElement("span", { style: {
9534
+ fontSize: 12,
9535
+ color: theme.palette.info.main,
9536
+ marginLeft: 5,
9537
+ } }, `${crewRotation === null || crewRotation === void 0 ? void 0 : crewRotation.length}/${maxCrewRotationLength}`)))),
9538
+ !!errors.CrewRotation && (React.createElement(ErrorLabel, { text: `Please put ${maxCrewRotationLength} crews` })),
9539
+ numberOfCrews > 0 &&
9540
+ Number.isInteger(maxCrewRotationLength / numberOfCrews) ===
9541
+ false && (React.createElement(Grid2, { container: true, style: { padding: "0", marginLeft: 5 } },
9542
+ React.createElement(ErrorLabel, { text: `Rotation # not a multiple of Shifts (${maxCrewRotationLength}) / Crews (${numberOfCrews})` })))),
9543
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9544
+ 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) => {
9545
+ if (evt.target.value.length <= 200)
9546
+ onChange(evt);
9547
+ } })) }),
9548
+ React.createElement(Grid2, { container: true, style: { marginBottom: 18 } },
9549
+ React.createElement(Grid2, null,
9550
+ (comments === null || comments === void 0 ? void 0 : comments.length) >= 1 &&
9551
+ (comments === null || comments === void 0 ? void 0 : comments.length) !== 200 && (React.createElement("span", { style: {
9552
+ fontSize: 12,
9553
+ color: theme.palette.info.main,
9554
+ marginLeft: 5,
9555
+ } }, `${comments === null || comments === void 0 ? void 0 : comments.length}/200`)),
9556
+ (comments === null || comments === void 0 ? void 0 : comments.length) == 200 && (React.createElement("span", { style: {
9557
+ fontSize: 12,
9558
+ color: theme.palette.info.main,
9559
+ marginLeft: 5,
9560
+ } }, "Max. 200"))))))),
9561
+ React.createElement(MesfModal.Actions, null,
9562
+ React.createElement(Grid2, { container: true, spacing: 2, justifyContent: "flex-end" },
9563
+ React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
9564
+ React.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: () => onHide(false) }, "Cancel")),
9565
+ React.createElement(Grid2, { size: { md: 3, xs: 12 }, style: { margin: 0 } },
9566
+ React.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading, variant: "contained", color: "primary", type: "submit" }, "Save")))))),
9567
+ React.createElement(ErrorModal, { error: error, onHide: () => setError("") }),
9568
+ React.createElement(Snackbar, { open: open, autoHideDuration: 2500, onClose: handleClose, anchorOrigin: { vertical: "bottom", horizontal: "center" } },
9569
+ React.createElement(Alert$1, { severity: "success", onClose: handleClose }, "The shift was created successfully"))));
9223
9570
  };
9224
9571
 
9225
- const useSettingsOptionsFunctions = ({ setSettingId, setShowDeleteModal, setShowCreateModal, setShowEditModal, }) => {
9572
+ const useShiftsOptionsFunctions = ({ setShiftId, setShowDeleteModal, setShowCreateModal, setShowEditModal, }) => {
9226
9573
  const getMenuOptions = (data) => {
9227
9574
  let options = [];
9228
9575
  if (!data) {
9229
9576
  options = options.concat([
9230
9577
  {
9231
- name: "New Setting",
9232
- key: "new_setting",
9578
+ name: "New Shift",
9579
+ key: "new_shift",
9233
9580
  onClick: () => {
9234
9581
  setShowCreateModal(true);
9235
9582
  },
@@ -9240,27 +9587,27 @@ const useSettingsOptionsFunctions = ({ setSettingId, setShowDeleteModal, setShow
9240
9587
  else {
9241
9588
  options = options.concat([
9242
9589
  {
9243
- name: "New Setting",
9244
- key: "new_setting",
9590
+ name: "New Shift",
9591
+ key: "new_shift",
9245
9592
  onClick: () => {
9246
9593
  setShowCreateModal(true);
9247
9594
  },
9248
9595
  icon: React__default.createElement(PlaylistAddIcon, null),
9249
9596
  },
9250
9597
  {
9251
- name: "Edit Setting",
9252
- key: "edit_setting",
9598
+ name: "Edit Shift",
9599
+ key: "edit_shift",
9253
9600
  onClick: () => {
9254
- setSettingId(data);
9601
+ setShiftId(data);
9255
9602
  setShowEditModal(true);
9256
9603
  },
9257
9604
  icon: React__default.createElement(EditIcon, null),
9258
9605
  },
9259
9606
  {
9260
- name: "Delete Setting",
9261
- key: "delete_setting",
9607
+ name: "Delete Shift",
9608
+ key: "delete_shift",
9262
9609
  onClick: () => {
9263
- setSettingId(data);
9610
+ setShiftId(data);
9264
9611
  setShowDeleteModal(true);
9265
9612
  },
9266
9613
  icon: React__default.createElement(DeleteIcon, null),
@@ -9274,33 +9621,62 @@ const useSettingsOptionsFunctions = ({ setSettingId, setShowDeleteModal, setShow
9274
9621
  };
9275
9622
  };
9276
9623
 
9277
- const useTableData$4 = ({ setOpenModalEditSetting, setOpenModalDeleteSetting, showContextMenu, setSettingSelected, }) => {
9624
+ const useTableData$4 = ({ setShiftSelected, setOpenModalEditShift, setOpenModalDeleteShift, showContextMenu, }) => {
9278
9625
  const columnDefs = [
9279
9626
  {
9280
- field: "SettingName",
9281
- headerName: "Name",
9627
+ field: "PatternStart",
9628
+ headerName: "Pattern Start",
9629
+ valueFormatter: ({ value }) => `${moment$g(value).format("L")}, ${moment$g(value).format("LTS")}`,
9282
9630
  minWidth: 180,
9283
9631
  flex: 4,
9632
+ cellStyle: {
9633
+ display: "flex",
9634
+ alignItems: "center",
9635
+ justifyContent: "center",
9636
+ },
9637
+ },
9638
+ {
9639
+ field: "ShiftCodes",
9640
+ headerName: "Shift Codes",
9641
+ minWidth: 150,
9642
+ flex: 2,
9643
+ cellStyle: {
9644
+ display: "flex",
9645
+ alignItems: "center",
9646
+ justifyContent: "center",
9647
+ },
9284
9648
  },
9285
9649
  {
9286
- field: "Value",
9287
- headerName: "Value",
9288
- minWidth: 180,
9650
+ field: "Crews",
9651
+ headerName: "Crews",
9652
+ minWidth: 150,
9289
9653
  flex: 2,
9654
+ cellStyle: {
9655
+ display: "flex",
9656
+ alignItems: "center",
9657
+ justifyContent: "center",
9658
+ },
9290
9659
  },
9291
9660
  {
9292
- field: "Description",
9293
- headerName: "Description",
9294
- minWidth: 150,
9295
- flex: 4,
9661
+ sortable: false,
9662
+ field: "PatternDays",
9663
+ headerName: "Shifts",
9664
+ minWidth: 130,
9665
+ flex: 1,
9666
+ cellStyle: {
9667
+ display: "flex",
9668
+ alignItems: "center",
9669
+ justifyContent: "center",
9670
+ },
9296
9671
  },
9297
9672
  {
9298
9673
  cellRenderer: (params) => {
9299
- return (React__default.createElement(Grid2, { container: true, sx: {
9674
+ return (React__default.createElement(Grid2, { container: true, style: {
9300
9675
  height: "100%",
9301
9676
  display: "flex",
9302
9677
  justifyContent: "center",
9303
9678
  alignItems: "center",
9679
+ }, sx: {
9304
9680
  opacity: 0,
9305
9681
  transition: "opacity 0.1s ease-in-out",
9306
9682
  ".ag-row-hover &": {
@@ -9315,329 +9691,101 @@ const useTableData$4 = ({ setOpenModalEditSetting, setOpenModalDeleteSetting, sh
9315
9691
  } },
9316
9692
  React__default.createElement(Grid2, { size: { xs: 12, md: 12 }, style: {
9317
9693
  display: "flex",
9318
- justifyContent: "space-evenly",
9694
+ justifyContent: "center",
9319
9695
  alignItems: "center",
9320
9696
  } },
9321
- React__default.createElement(IconButton$1, { size: "small", onClick: () => {
9322
- setSettingSelected(params === null || params === void 0 ? void 0 : params.data);
9323
- setOpenModalEditSetting(true);
9697
+ React__default.createElement(Button, { style: {}, onClick: () => {
9698
+ setShiftSelected(params === null || params === void 0 ? void 0 : params.data);
9699
+ setOpenModalEditShift(true);
9324
9700
  } },
9325
9701
  React__default.createElement(EditIcon, { color: "primary" })),
9326
- React__default.createElement(IconButton$1, { size: "small", onClick: () => {
9327
- setSettingSelected(params === null || params === void 0 ? void 0 : params.data);
9328
- setOpenModalDeleteSetting(true);
9329
- } },
9330
- React__default.createElement(DeleteIcon, { color: "secondary" })),
9331
- React__default.createElement(IconButton$1, { size: "small", onClick: (e) => showContextMenu(e, params.data, "TableSettings") },
9332
- React__default.createElement(FormatListBulletedSharpIcon, { color: "action" })))));
9333
- },
9334
- field: "",
9335
- flex: 1,
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);
9702
+ React__default.createElement(Button, { style: {}, onClick: () => {
9703
+ setShiftSelected(params === null || params === void 0 ? void 0 : params.data);
9704
+ setOpenModalDeleteShift(true);
9705
+ } },
9706
+ React__default.createElement(DeleteIcon, { color: "secondary" })),
9707
+ React__default.createElement(Button, { style: {}, onClick: (e) => showContextMenu(e, params.data, "TableShifts") },
9708
+ React__default.createElement(FormatListBulletedSharpIcon, { color: "action" })))));
9709
+ },
9710
+ field: "",
9711
+ flex: 3,
9712
+ minWidth: 240,
9713
+ editable: false,
9714
+ autoHeight: false,
9715
+ suppressNavigable: true,
9545
9716
  },
9546
- });
9547
- const onSubmit = (data) => __awaiter(void 0, void 0, void 0, function* () {
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"))));
9717
+ ];
9718
+ return { columnDefs };
9599
9719
  };
9600
9720
 
9601
- const useSearchSettings = () => {
9721
+ const useSearchShifts = (assetId) => {
9602
9722
  return useQuery({
9603
- queryKey: ["settings"],
9604
- queryFn: ({ signal }) => getUTLSettings(signal),
9723
+ queryKey: ["shifts", assetId],
9724
+ queryFn: ({ signal }) => getShiftParameters(assetId, signal),
9605
9725
  });
9606
9726
  };
9607
- const TableSettings = () => {
9608
- const queryClient = useQueryClient();
9609
- const { showContextMenu, registerConfig } = useContextMenuMESF();
9727
+ const TableShiftsCrews = () => {
9728
+ const gridRef = useRef(null);
9610
9729
  const [error, setError] = useState("");
9611
- const [gridApi, setGridApi] = useState(null);
9612
- const [filterValue, setFilterValue] = useState("");
9613
- const [settingSelected, setSettingSelected] = useState(null);
9614
9730
  const [openModalNew, setOpenModalNew] = useState(false);
9615
- const [openModalEditSetting, setOpenModalEditSetting] = useState(false);
9616
- const [openModalDeleteSetting, setOpenModalDeleteSetting] = useState(false);
9617
- const { data: rows, isLoading, isError, error: e } = useSearchSettings();
9618
- const { getMenuOptions } = useSettingsOptionsFunctions({
9619
- setSettingId: setSettingSelected,
9620
- setShowDeleteModal: setOpenModalDeleteSetting,
9731
+ const [openModalEditShift, setOpenModalEditShift] = useState(false);
9732
+ const [openModalDeleteShift, setOpenModalDeleteShift] = useState(false);
9733
+ const [shiftSelected, setShiftSelected] = useState(null);
9734
+ const { state: { settings }, } = useUTLSettingsContext();
9735
+ const defaultAssetId = Number(get(settings, "DefaultAssetId", null));
9736
+ const [selectedAssetId, setSelectedAssetId] = useState(defaultAssetId || null);
9737
+ const { data: assets } = useSearchAssets();
9738
+ 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]);
9739
+ 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]);
9740
+ const { data: rows, isLoading, isError, error: e, refetch, } = useSearchShifts(selectedAssetId);
9741
+ const formattedRows = rows === null || rows === void 0 ? void 0 : rows.map(({ PatternStart, ShiftCodes, Crews, PatternDays, CrewRotation, Comments, CanEdit, }) => ({
9742
+ id: ShiftCodes,
9743
+ PatternStart,
9744
+ ShiftCodes,
9745
+ Crews,
9746
+ PatternDays,
9747
+ CrewRotation,
9748
+ Comments,
9749
+ CanEdit,
9750
+ }));
9751
+ const defaultColDef = useMemo(() => {
9752
+ return {
9753
+ sortable: true,
9754
+ wrapText: true,
9755
+ autoHeight: true,
9756
+ wrapHeaderText: true,
9757
+ suppressHeaderMenuButton: true,
9758
+ cellStyle: {
9759
+ display: "flex",
9760
+ alignItems: "center",
9761
+ justifyContent: "center",
9762
+ },
9763
+ };
9764
+ }, []);
9765
+ const { getMenuOptions } = useShiftsOptionsFunctions({
9766
+ setShiftId: setShiftSelected,
9621
9767
  setShowCreateModal: setOpenModalNew,
9622
- setShowEditModal: setOpenModalEditSetting,
9768
+ setShowDeleteModal: setOpenModalDeleteShift,
9769
+ setShowEditModal: setOpenModalEditShift,
9623
9770
  });
9624
- const { columnDefs, defaultColDef } = useTableData$4({
9625
- setOpenModalEditSetting,
9626
- setOpenModalDeleteSetting,
9771
+ const { showContextMenu, registerConfig } = useContextMenuMESF();
9772
+ const { columnDefs } = useTableData$4({
9773
+ setShiftSelected,
9774
+ setOpenModalEditShift,
9775
+ setOpenModalDeleteShift,
9627
9776
  showContextMenu,
9628
- setSettingSelected,
9629
9777
  });
9630
9778
  const getContextMenuItems = (params) => {
9631
9779
  var _a, _b;
9632
9780
  const data = (_a = params.node) === null || _a === void 0 ? void 0 : _a.data;
9633
9781
  params.api.deselectAll();
9634
9782
  (_b = params.node) === null || _b === void 0 ? void 0 : _b.setSelected(true);
9635
- showContextMenu(event, data, "TableSettings");
9783
+ showContextMenu(event, data, "TableShifts");
9636
9784
  return [];
9637
9785
  };
9638
9786
  useEffect(() => {
9639
9787
  registerConfig({
9640
- id: "TableSettings",
9788
+ id: "TableShifts",
9641
9789
  getOptions: getMenuOptions,
9642
9790
  });
9643
9791
  }, []);
@@ -9646,124 +9794,219 @@ const TableSettings = () => {
9646
9794
  setError(e.message);
9647
9795
  }
9648
9796
  }, [e, isError]);
9649
- return (React__default.createElement(React__default.Fragment, null,
9650
- React__default.createElement(Grid2, { container: true, justifyContent: "center", p: 1, spacing: 1 },
9651
- React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
9652
- React__default.createElement(Typography$1, { variant: "h5", fontWeight: 600 }, "Settings")),
9653
- React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
9654
- React__default.createElement(TextField, { fullWidth: true, label: "Search", variant: "outlined", size: "small", margin: "dense", value: filterValue, onChange: (event) => {
9655
- setFilterValue(event.target.value);
9656
- gridApi === null || gridApi === void 0 ? void 0 : gridApi.setGridOption("quickFilterText", event.target.value);
9657
- }, slotProps: {
9658
- input: {
9659
- startAdornment: (React__default.createElement(InputAdornment, { position: "start" },
9660
- React__default.createElement(IconButton$1, { edge: "start", type: "submit" },
9661
- React__default.createElement(SearchIcon, null)))),
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: {
9797
+ return (React.createElement(React.Fragment, null,
9798
+ React.createElement(Grid2, { container: true, justifyContent: "flex-start", p: 1, spacing: 1 },
9799
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9800
+ React.createElement(Typography$1, { variant: "h5", fontWeight: 600 }, "Shifts / Crew")),
9801
+ React.createElement(Grid2, { size: { md: 12, xs: 12 } },
9802
+ React.createElement(FormControl, { size: "small", sx: { minWidth: 200 } },
9803
+ React.createElement(InputLabel, null, "Asset"),
9804
+ 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)))))),
9805
+ React.createElement(Grid2, { container: true, justifyContent: "center", alignItems: "center" },
9806
+ React.createElement(Grid2, { container: true, size: { md: 12, xs: 12 } },
9807
+ React.createElement(Grid2, { component: Paper, size: { md: 12, xs: 12 }, style: {
9808
+ height: "70vh",
9809
+ } },
9810
+ React.createElement(AgGridReact, { loading: isLoading, gridOptions: {
9670
9811
  theme: themeDXT,
9671
- }, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 34, headerHeight: 34, animateRows: true, loadingOverlayComponent: CenteredLazyLoading, getContextMenuItems: (e) => getContextMenuItems(e), rowSelection: "single", onRowDoubleClicked: (event) => {
9672
- setSettingSelected(event.data);
9673
- setOpenModalEditSetting(true);
9674
- }, onGridReady: (params) => setGridApi(params.api) }))),
9675
- React__default.createElement(Grid2, { container: true, justifyContent: "flex-end" },
9676
- React__default.createElement(Grid2, { size: { md: 2, xs: 12 } },
9677
- React__default.createElement(Button, { variant: "contained", color: "primary", onClick: () => setOpenModalNew(!openModalNew), fullWidth: true }, "NEW SETTING"))))),
9678
- React__default.createElement(CreateSetting, { settingSelected: settingSelected, show: openModalNew, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
9812
+ }, ref: gridRef, rowData: formattedRows || [], columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 34, headerHeight: 34, animateRows: true, loadingOverlayComponent: CenteredLazyLoading, getContextMenuItems: (e) => getContextMenuItems(e), rowSelection: "single", onRowDoubleClicked: (event) => {
9813
+ setShiftSelected(event.data);
9814
+ setOpenModalEditShift(true);
9815
+ } })),
9816
+ React.createElement(Grid2, { container: true, justifyContent: "flex-end" },
9817
+ React.createElement(Grid2, { size: { md: 2, xs: 12 } },
9818
+ React.createElement(Button, { variant: "contained", color: "primary", onClick: () => setOpenModalNew(!openModalNew), fullWidth: true }, "NEW SHIFT")))))),
9819
+ React.createElement(CreateShift, { shiftSelected: shiftSelected, show: openModalNew, onHide: (shouldUpdate) => {
9679
9820
  setOpenModalNew(false);
9680
9821
  if (shouldUpdate)
9681
- yield queryClient.invalidateQueries({ queryKey: ["settings"] });
9682
- }), suffixTitle: "Settings" }),
9683
- React__default.createElement(EditSetting, { settingSelected: settingSelected, show: openModalEditSetting, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
9684
- setOpenModalEditSetting(false);
9822
+ refetch();
9823
+ }, suffixTitle: "Shifts / Crew", assetId: selectedAssetId, assetName: selectedAssetName }),
9824
+ React.createElement(EditShift, { shiftSelected: shiftSelected, show: openModalEditShift, onHide: (shouldUpdate) => {
9825
+ setOpenModalEditShift(false);
9685
9826
  if (shouldUpdate)
9686
- yield queryClient.invalidateQueries({ queryKey: ["settings"] });
9687
- }), suffixTitle: "Settings" }),
9688
- React__default.createElement(DeleteSetting, { settingSelected: settingSelected, show: openModalDeleteSetting, onHide: (shouldUpdate) => __awaiter(void 0, void 0, void 0, function* () {
9689
- setOpenModalDeleteSetting(false);
9827
+ refetch();
9828
+ }, suffixTitle: "Shifts / Crew", assetId: selectedAssetId, assetName: selectedAssetName }),
9829
+ React.createElement(DeleteShift, { shiftSelected: shiftSelected, show: openModalDeleteShift, onHide: (shouldUpdate) => {
9830
+ setOpenModalDeleteShift(false);
9690
9831
  if (shouldUpdate)
9691
- yield queryClient.invalidateQueries({ queryKey: ["settings"] });
9692
- }), suffixTitle: "Settings" }),
9693
- React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
9832
+ refetch();
9833
+ }, suffixTitle: "Shifts / Crew", assetId: selectedAssetId, assetName: selectedAssetName })));
9834
+ };
9835
+
9836
+ const ShiftsCrews = () => {
9837
+ return (React.createElement(React.Fragment, null,
9838
+ React.createElement(HelmetDexteel, { title: "Shifts and Crews" }),
9839
+ React.createElement(TableShiftsCrews, null)));
9840
+ };
9841
+
9842
+ const ShiftsCrewsPage = (props) => {
9843
+ return React.createElement(ShiftsCrews, null);
9844
+ };
9845
+
9846
+ const AssetPage = () => {
9847
+ return (React__default.createElement(React__default.Fragment, null,
9848
+ React__default.createElement(DndProvider, { backend: HTML5Backend },
9849
+ React__default.createElement(TreeAsset, null))));
9850
+ };
9851
+
9852
+ const Asset = (props) => {
9853
+ return React.createElement(AssetPage, null);
9854
+ };
9855
+
9856
+ const UsersPage = (props) => {
9857
+ return React.createElement(Users, null);
9858
+ };
9859
+
9860
+ const CurrencyFormatter = new Intl.NumberFormat("en-US", {
9861
+ style: "currency",
9862
+ currency: "USD",
9863
+ });
9864
+ const NumberFormatter = new Intl.NumberFormat("en-US", {
9865
+ style: "currency",
9866
+ currency: "USD",
9867
+ });
9868
+ const IntegerFormatter = new Intl.NumberFormat("en-US", {});
9869
+ const DateTimeFormatter = new Intl.DateTimeFormat("en-US-u-hc-h23", {
9870
+ year: "numeric",
9871
+ month: "2-digit",
9872
+ day: "2-digit",
9873
+ hour: "numeric",
9874
+ minute: "numeric",
9875
+ second: "numeric",
9876
+ hour12: false,
9877
+ // timeZone: 'America/Los_Angeles'
9878
+ });
9879
+ const DateFormatter = new Intl.DateTimeFormat("en-US", {
9880
+ year: "numeric",
9881
+ month: "2-digit",
9882
+ day: "2-digit",
9883
+ // timeZone: 'America/Los_Angeles'
9884
+ });
9885
+ const TimeFormatter = new Intl.DateTimeFormat("en-US-u-hc-h23", {
9886
+ hour: "2-digit",
9887
+ minute: "numeric",
9888
+ second: "numeric",
9889
+ hour12: false,
9890
+ // timeZone: 'America/Los_Angeles'
9891
+ });
9892
+
9893
+ const getShiftStyle = (shift) => {
9894
+ if (shift === "D") {
9895
+ return { color: "#52a8b7" };
9896
+ }
9897
+ else if (shift === "N") {
9898
+ return { color: "#A5A5A5" };
9899
+ }
9900
+ else {
9901
+ return {};
9902
+ }
9694
9903
  };
9695
-
9696
- const searchSettings = () => {
9697
- return useQuery({
9698
- queryKey: ["settings"],
9699
- queryFn: ({ signal }) => getUTLSettings(signal),
9700
- });
9904
+ const getCrewStyle = (crew) => {
9905
+ if (crew === "A") {
9906
+ return { color: "#0070C0" };
9907
+ }
9908
+ else if (crew === "B") {
9909
+ return { color: "#FFD24A" };
9910
+ }
9911
+ else if (crew === "C") {
9912
+ return { color: "#FD8359" };
9913
+ }
9914
+ else if (crew === "D") {
9915
+ return { color: "#00B050" };
9916
+ }
9917
+ else {
9918
+ return {};
9919
+ }
9701
9920
  };
9702
- const SettingsPage = () => {
9921
+ const GetShiftColor = (props) => {
9703
9922
  return (React__default.createElement(React__default.Fragment, null,
9704
- React__default.createElement(HelmetDexteel, { title: "Settings" }),
9705
- React__default.createElement(TableSettings, null)));
9923
+ React__default.createElement(Square$1, { sx: Object.assign({ mr: 1 }, getShiftStyle(props.value)), fontSize: "small" })));
9924
+ };
9925
+ const GetCrewColor = (props) => {
9926
+ return (React__default.createElement(React__default.Fragment, null,
9927
+ React__default.createElement(Square$1, { sx: Object.assign({ mr: 1 }, getCrewStyle(props.value)), fontSize: "small" })));
9706
9928
  };
9707
9929
 
9708
- const UTLSettingsInitialState = {
9709
- serverTimeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
9710
- settings: {},
9930
+ const AssetInitialState = {
9931
+ areasList: [],
9932
+ allAssets: [],
9933
+ plantAssetId: 1,
9711
9934
  };
9712
- const UTLSettingsReducer = createSlice({
9935
+ const AssetReducer = createSlice({
9713
9936
  name: "__",
9714
- initialState: UTLSettingsInitialState,
9937
+ initialState: AssetInitialState,
9715
9938
  reducers: {
9716
- setServerTimeZone(state, { payload }) {
9717
- state.serverTimeZone = payload;
9939
+ setAreasList(state, { payload }) {
9940
+ state.areasList = payload;
9718
9941
  },
9719
- setSetting(state, { payload }) {
9720
- state.settings[payload.key] = payload.value;
9942
+ setAllAssets(state, { payload }) {
9943
+ state.allAssets = payload;
9721
9944
  },
9722
- initSettings(state, { payload }) {
9723
- state.settings = payload.reduce((acc, cur) => {
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
- }, {});
9945
+ setPlantAssetId(state, { payload }) {
9946
+ state.plantAssetId = payload;
9731
9947
  },
9732
9948
  },
9733
9949
  });
9734
9950
 
9735
- const UTLSettingsContext = createContext({
9736
- state: UTLSettingsReducer.getInitialState(),
9737
- actions: UTLSettingsReducer.actions,
9738
- isLoading: true,
9951
+ const AssetContext = createContext({
9952
+ state: AssetReducer.getInitialState(),
9953
+ actions: AssetReducer.actions,
9739
9954
  });
9740
- const useUTLSettingsContext = () => useContext(UTLSettingsContext);
9741
- const UTLSettingsProvider = ({ children }) => {
9955
+ const useAssetContext = () => useContext(AssetContext);
9956
+ const AssetProvider = ({ children, plantAssetId = 1, }) => {
9742
9957
  const [state, actions] = useComplexState({
9743
- initialState: UTLSettingsReducer.getInitialState(),
9744
- reducers: UTLSettingsReducer.caseReducers,
9745
- });
9746
- const { data: rows, isLoading, isError, error: e, isSuccess, refetch, } = searchSettings();
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
- }
9958
+ initialState: {
9959
+ areasList: [],
9960
+ allAssets: [],
9961
+ plantAssetId,
9764
9962
  },
9963
+ reducers: AssetReducer.caseReducers,
9765
9964
  });
9766
- return (React__default.createElement(UTLSettingsContext.Provider, { value: { state, actions, isLoading } }, children));
9965
+ return (React__default.createElement(AssetContext.Provider, { value: { state, actions } }, children));
9966
+ };
9967
+
9968
+ const LogbookSettingsInitialState = {
9969
+ entry: {
9970
+ withAssetFilter: undefined,
9971
+ filterAssets: undefined,
9972
+ canEditAsset: false,
9973
+ allowAttachments: false,
9974
+ canEditShift: false,
9975
+ showShiftCrew: false,
9976
+ exportToExcel: false,
9977
+ shiftsRange: 7,
9978
+ presetAssetId: undefined,
9979
+ },
9980
+ report: {
9981
+ withAssetFilter: undefined,
9982
+ filterAssets: undefined,
9983
+ showAttachments: false,
9984
+ showAsset: false,
9985
+ showShiftCrew: false,
9986
+ exportToExcel: false,
9987
+ },
9988
+ section: {
9989
+ schema: undefined,
9990
+ withAssetFilter: undefined,
9991
+ filterAssets: undefined,
9992
+ canEditAsset: false,
9993
+ allowAttachments: false,
9994
+ showShiftCrew: false,
9995
+ exportToExcel: false,
9996
+ topSectionsCount: 5,
9997
+ },
9998
+ };
9999
+
10000
+ const LogbookSettingsContext = createContext(LogbookSettingsInitialState);
10001
+ const useLogbookSettings = () => useContext(LogbookSettingsContext);
10002
+ const LogbookSettingsProvider = ({ children, logbookSettings = {}, }) => {
10003
+ // Merge default settings with provided settings
10004
+ const settings = useMemo(() => ({
10005
+ entry: Object.assign(Object.assign({}, LogbookSettingsInitialState.entry), (logbookSettings.entry || {})),
10006
+ report: Object.assign(Object.assign({}, LogbookSettingsInitialState.report), (logbookSettings.report || {})),
10007
+ section: Object.assign(Object.assign({}, LogbookSettingsInitialState.section), (logbookSettings.section || {})),
10008
+ }), [logbookSettings]);
10009
+ return (React__default.createElement(LogbookSettingsContext.Provider, { value: settings }, children));
9767
10010
  };
9768
10011
 
9769
10012
  const useFrontendVersionCheck = ({ endpoint = "/frontend/version", intervalMs = 60000, enabled = true, onUpdate, } = {}) => {
@@ -10264,9 +10507,9 @@ const QueryCacheInvalidations = () => {
10264
10507
  React__default.createElement(MesfModal.Content, { dividers: true },
10265
10508
  React__default.createElement(Grid2, { container: true, spacing: 3 },
10266
10509
  React__default.createElement(Grid2, { size: { xs: 12 } },
10267
- React__default.createElement(Controller, { control: control, name: "source", render: (params) => (React__default.createElement(Autocomplete$1, { 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" })) })),
10510
+ 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
10511
  React__default.createElement(Grid2, { size: { xs: 12 } },
10269
- React__default.createElement(Controller, { control: control, name: "targets", render: (params) => (React__default.createElement(Autocomplete$1, { 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) => {
10512
+ 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
10513
  if (typeof option === "string") {
10271
10514
  return option;
10272
10515
  }
@@ -10318,7 +10561,7 @@ const renderInput = (param, onChange, disabled) => {
10318
10561
  return (React__default.createElement(TextField, { type: "number", label: param.parameterName, value: param.value, onChange: (e) => onChange(e.target.value === "" ? "" : Number(e.target.value)), disabled: disabled, fullWidth: true, size: "small", inputProps: { step: "any" } }));
10319
10562
  }
10320
10563
  if (["datetime", "datetime2", "date", "smalldatetime"].includes(type)) {
10321
- return (React__default.createElement(DateTimePicker$1, { label: param.parameterName, value: param.value ? moment$f(param.value) : null, onChange: (newValue) => onChange((newValue === null || newValue === void 0 ? void 0 : newValue.toDate()) || null), disabled: disabled, slotProps: {
10564
+ return (React__default.createElement(DateTimePicker$1, { label: param.parameterName, value: param.value ? moment$g(param.value) : null, onChange: (newValue) => onChange((newValue === null || newValue === void 0 ? void 0 : newValue.toDate()) || null), disabled: disabled, slotProps: {
10322
10565
  textField: {
10323
10566
  fullWidth: true,
10324
10567
  size: "small",
@@ -10565,7 +10808,7 @@ const ResultsList = ({ results, onDeleteResult, onClearAll }) => {
10565
10808
  };
10566
10809
 
10567
10810
  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: {
10811
+ 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
10812
  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
10813
  } }))), renderOption: (props, option) => (React__default.createElement("li", Object.assign({}, props, { key: option.FullName }),
10571
10814
  option.SchemaName,
@@ -10784,7 +11027,7 @@ const Configuration = () => {
10784
11027
  } }, "Security") },
10785
11028
  React__default.createElement(ListItemButton, { selected: option === "users", component: Link, to: "/configuration/users" },
10786
11029
  React__default.createElement(ListItemIcon, null,
10787
- React__default.createElement(Group, null)),
11030
+ React__default.createElement(Group$1, null)),
10788
11031
  React__default.createElement(ListItemText, { primary: "Users" })),
10789
11032
  React__default.createElement(ListItemButton, { selected: option === "profiles", component: Link, to: "/configuration/profiles" },
10790
11033
  React__default.createElement(ListItemIcon, null,
@@ -11454,7 +11697,7 @@ const SaveUpdateDeleteViewModalV2 = ({ open, mode, handleClose, view, }) => {
11454
11697
  React__default.createElement("form", { onSubmit: handleSubmit(onSubmit) },
11455
11698
  React__default.createElement(MesfModal.Content, { dividers: true, style: { padding: "15px 30px" } },
11456
11699
  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) => {
11700
+ 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
11701
  if (typeof option === "string") {
11459
11702
  return option;
11460
11703
  }
@@ -11585,21 +11828,21 @@ const dateNavigator = (startDate, endDate, scope, operator, current = false) =>
11585
11828
  }
11586
11829
  else {
11587
11830
  const [quantity, duration] = scope.split(" ");
11588
- newStartDate = moment$f(newEndDate)
11831
+ newStartDate = moment$g(newEndDate)
11589
11832
  .subtract(quantity, duration[0])
11590
11833
  .toDate();
11591
11834
  }
11592
11835
  }
11593
11836
  else {
11594
11837
  if (scope === "custom") {
11595
- const durationInMs = moment$f(endDate).diff(moment$f(startDate));
11596
- newStartDate = moment$f(startDate)[operator](durationInMs).toDate();
11838
+ const durationInMs = moment$g(endDate).diff(moment$g(startDate));
11839
+ newStartDate = moment$g(startDate)[operator](durationInMs).toDate();
11597
11840
  }
11598
11841
  else {
11599
11842
  const [quantity, duration] = scope.split(" ");
11600
- newStartDate = moment$f(startDate)[operator](quantity, duration[0])
11843
+ newStartDate = moment$g(startDate)[operator](quantity, duration[0])
11601
11844
  .toDate();
11602
- newEndDate = moment$f(endDate)[operator](quantity, duration[0])
11845
+ newEndDate = moment$g(endDate)[operator](quantity, duration[0])
11603
11846
  .toDate();
11604
11847
  }
11605
11848
  }
@@ -11635,11 +11878,11 @@ const HeaderSectionV2 = React__default.memo(({ autoRefresh, setAutoRefresh, setC
11635
11878
  };
11636
11879
  const handlePartialDateNavigator = (operator) => {
11637
11880
  // Calculate 20% of the current period
11638
- const durationInMs = moment$f(timeScopeEnd).diff(moment$f(timeScopeStart));
11881
+ const durationInMs = moment$g(timeScopeEnd).diff(moment$g(timeScopeStart));
11639
11882
  const partialDuration = Math.round(durationInMs * 0.2);
11640
- const newStartDate = moment$f(timeScopeStart)[operator](partialDuration, "milliseconds")
11883
+ const newStartDate = moment$g(timeScopeStart)[operator](partialDuration, "milliseconds")
11641
11884
  .toDate();
11642
- const newEndDate = moment$f(timeScopeEnd)[operator](partialDuration, "milliseconds")
11885
+ const newEndDate = moment$g(timeScopeEnd)[operator](partialDuration, "milliseconds")
11643
11886
  .toDate();
11644
11887
  setTotalScope({
11645
11888
  start: newStartDate,
@@ -11648,7 +11891,7 @@ const HeaderSectionV2 = React__default.memo(({ autoRefresh, setAutoRefresh, setC
11648
11891
  });
11649
11892
  };
11650
11893
  const handleDateChange = (newValue, key) => {
11651
- const newDate = moment$f(newValue).toDate();
11894
+ const newDate = moment$g(newValue).toDate();
11652
11895
  // If scope is "custom", just update the changed date
11653
11896
  if (scope === "custom") {
11654
11897
  setTotalScope({ [key]: newDate });
@@ -11755,7 +11998,7 @@ const HeaderSectionV2 = React__default.memo(({ autoRefresh, setAutoRefresh, setC
11755
11998
  React__default.createElement(FastRewind, { fontSize: "medium", sx: { color: "black" } })))),
11756
11999
  React__default.createElement(Grid2, { size: { md: 3.5 } },
11757
12000
  React__default.createElement(LocalizationProvider$1, { dateAdapter: AdapterMoment },
11758
- React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$f(timeScopeStart), onChange: (newValue) => {
12001
+ React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$g(timeScopeStart), onChange: (newValue) => {
11759
12002
  if (newValue) {
11760
12003
  handleDateChange(newValue.toDate(), "start");
11761
12004
  }
@@ -11778,7 +12021,7 @@ const HeaderSectionV2 = React__default.memo(({ autoRefresh, setAutoRefresh, setC
11778
12021
  React__default.createElement(MenuItem, { value: "custom" }, "Custom")))),
11779
12022
  React__default.createElement(Grid2, { size: { md: 3.5 } },
11780
12023
  React__default.createElement(LocalizationProvider$1, { dateAdapter: AdapterMoment },
11781
- React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$f(timeScopeEnd), onChange: (newValue) => {
12024
+ React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$g(timeScopeEnd), onChange: (newValue) => {
11782
12025
  if (newValue) {
11783
12026
  handleDateChange(newValue.toDate(), "end");
11784
12027
  }
@@ -11884,7 +12127,7 @@ const HeaderSectionV2 = React__default.memo(({ autoRefresh, setAutoRefresh, setC
11884
12127
  backgroundColor: "white",
11885
12128
  width: "100%",
11886
12129
  } },
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: {
12130
+ 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
12131
  display: "flex",
11889
12132
  justifyContent: "space-between",
11890
12133
  width: "100%",
@@ -12806,7 +13049,7 @@ const BitSelectorModal = ({ open, handleClose, viewTags, onAddBits, existingBitT
12806
13049
  React__default.createElement(Grid2, { container: true, spacing: 2 },
12807
13050
  React__default.createElement(Grid2, { size: 12 },
12808
13051
  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" }),
13052
+ 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
13053
  React__default.createElement(Box, { sx: {
12811
13054
  display: "flex",
12812
13055
  justifyContent: "space-between",
@@ -12916,7 +13159,7 @@ const LoadViewModalV2 = ({ open, handleClose }) => {
12916
13159
  React__default.createElement("input", { type: "checkbox", checked: allViewsChecked, onChange: handleAllViewsCheckbox }),
12917
13160
  React__default.createElement(Typography$1, null, "All Views")))),
12918
13161
  React__default.createElement(Grid2, { size: 12 },
12919
- React__default.createElement(Autocomplete, { size: "small", id: "list-of-views", noOptionsText: allViewsChecked
13162
+ React__default.createElement(Autocomplete$1, { size: "small", id: "list-of-views", noOptionsText: allViewsChecked
12920
13163
  ? "No views detected, please create a new view"
12921
13164
  : "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
13165
  React__default.createElement(Box, { sx: {
@@ -15569,7 +15812,7 @@ const TrendingsPageV2 = () => {
15569
15812
  display: "flex",
15570
15813
  width: "100%",
15571
15814
  } },
15572
- React__default.createElement(Group$1, { orientation: "vertical", style: { width: "100%", height: "100%" } },
15815
+ React__default.createElement(Group, { orientation: "vertical", style: { width: "100%", height: "100%" } },
15573
15816
  React__default.createElement(Panel, { defaultSize: 80, minSize: 20 },
15574
15817
  React__default.createElement("div", { style: { height: "100%", width: "100%" } },
15575
15818
  React__default.createElement(TrendingChartV2, { customOptions: chartOptions, series: filteredSeries, isLoading: seriesLoading && seriesFetching, onChartReady: setChartInstance, dataLoadedTrigger: dataLoadedTrigger }))),
@@ -15667,7 +15910,7 @@ const ProvidersLoader = ({ children, }) => {
15667
15910
  };
15668
15911
 
15669
15912
  const timezone = TimeService.getInstance().getServerTimeZone();
15670
- moment$g.tz.setDefault(timezone);
15913
+ moment$h.tz.setDefault(timezone);
15671
15914
  const base = document.getElementsByTagName("base")[0].getAttribute("href") || "/";
15672
15915
  const queryClient = new QueryClient({
15673
15916
  defaultOptions: {
@@ -15693,7 +15936,7 @@ function MESFMain({ authentication, routes, navbar, navbarTitle = "MESF", config
15693
15936
  React__default.createElement(HelmetDexteelProvider, { navbarTitle: navbarTitle },
15694
15937
  React__default.createElement(QueryClientProvider, { client: queryClient },
15695
15938
  React__default.createElement(AuthProvider, { authConfig: authentication },
15696
- React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment, dateLibInstance: moment$g },
15939
+ React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment, dateLibInstance: moment$h },
15697
15940
  React__default.createElement(UserProvider, null,
15698
15941
  React__default.createElement(UTLSettingsProvider, null,
15699
15942
  React__default.createElement(ProvidersLoader, null,
@@ -15747,7 +15990,7 @@ const useGridDefinitions$1 = ({ OnEdit, OnSend }) => {
15747
15990
  };
15748
15991
  };
15749
15992
 
15750
- const moment$e = getMomentTz();
15993
+ const moment$c = getMomentTz();
15751
15994
  const getEntries$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ shiftId, assetId, signal, }) {
15752
15995
  const apiService = new MESApiService();
15753
15996
  const parameters = [
@@ -15760,9 +16003,9 @@ const getEntries$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ shiftI
15760
16003
  if (resp.ok) {
15761
16004
  let rows = get(resp, "data.tables[0].rows", []);
15762
16005
  rows = rows.map((entry) => (Object.assign(Object.assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
15763
- ? moment$e.utc(entry["CreateTimestamp"]).toDate()
16006
+ ? moment$c.utc(entry["CreateTimestamp"]).toDate()
15764
16007
  : null, UpdateTimestamp: entry.UpdateTimestamp
15765
- ? moment$e.utc(entry["UpdateTimestamp"]).toDate()
16008
+ ? moment$c.utc(entry["UpdateTimestamp"]).toDate()
15766
16009
  : null })));
15767
16010
  return rows;
15768
16011
  }
@@ -15856,7 +16099,7 @@ const getEntryAttachments$1 = (params, signal) => __awaiter(void 0, void 0, void
15856
16099
  if (resp.ok) {
15857
16100
  let rows = get(resp, "data.tables[0].rows", []);
15858
16101
  rows = rows.map((attachment) => (Object.assign(Object.assign({}, attachment), { CreationTime: attachment.CreationTime
15859
- ? moment$e.utc(attachment.CreationTime).toDate()
16102
+ ? moment$c.utc(attachment.CreationTime).toDate()
15860
16103
  : new Date() })));
15861
16104
  return rows;
15862
16105
  }
@@ -15877,7 +16120,7 @@ const upsertEntryAttachment$1 = (_a) => __awaiter(void 0, [_a], void 0, function
15877
16120
  const attachment = get(resp, "data.tables[0].rows[0]", null);
15878
16121
  if (attachment) {
15879
16122
  return Object.assign(Object.assign({}, attachment), { CreationTime: attachment.CreationTime
15880
- ? moment$e.utc(attachment.CreationTime).toDate()
16123
+ ? moment$c.utc(attachment.CreationTime).toDate()
15881
16124
  : new Date() });
15882
16125
  }
15883
16126
  return null;
@@ -16173,7 +16416,7 @@ const AssetsFilter = ({ label = "Asset", value, onChange, filterAreaAssets = fal
16173
16416
  ];
16174
16417
  const selectedOption = options.find((option) => option.value === (value || null)) || options[0];
16175
16418
  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) => {
16419
+ React__default.createElement(Autocomplete$1, { size: "small", options: filterAreaAssets ? options.filter((o) => o.isAreaAsset) : options, value: selectedOption, onChange: (event, newValue) => {
16177
16420
  var _a;
16178
16421
  if (newValue) {
16179
16422
  onChange((_a = newValue.value) !== null && _a !== void 0 ? _a : null);
@@ -16182,124 +16425,6 @@ const AssetsFilter = ({ label = "Asset", value, onChange, filterAreaAssets = fal
16182
16425
  React__default.createElement(ErrorModal, { error: error, onHide: () => setError("") })));
16183
16426
  };
16184
16427
 
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
16428
  const useEntrySubmission$1 = ({ onSuccess, onError, isNewEntry = false, onHide = () => { }, } = {}) => {
16304
16429
  const [isSubmitLoading, setIsSubmitLoading] = useState(false);
16305
16430
  const [showConfirmationDialog, setShowConfirmationDialog] = useState(false);
@@ -17300,7 +17425,7 @@ const Logbook$3 = () => {
17300
17425
  fontWeight: 600,
17301
17426
  userSelect: "none",
17302
17427
  } }, "LOGBOOK")),
17303
- React__default.createElement(Group$1, { id: "logbook-entry-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
17428
+ React__default.createElement(Group, { id: "logbook-entry-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
17304
17429
  React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
17305
17430
  React__default.createElement(Box, { sx: {
17306
17431
  display: "flex",
@@ -17911,7 +18036,7 @@ const Logbook$2 = () => {
17911
18036
  fontWeight: 600,
17912
18037
  userSelect: "none",
17913
18038
  } }, "LOGBOOK REPORT")),
17914
- React__default.createElement(Group$1, { id: "logbook-report-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
18039
+ React__default.createElement(Group, { id: "logbook-report-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
17915
18040
  React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
17916
18041
  React__default.createElement(Box, { sx: {
17917
18042
  display: "flex",
@@ -18533,7 +18658,7 @@ const SectionSelector = ({ value, onChange, topSectionsCount = 5, disabled = fal
18533
18658
  gap: 1,
18534
18659
  flexWrap: "wrap",
18535
18660
  } },
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" } }),
18661
+ 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
18662
  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
18663
  input: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
18539
18664
  loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
@@ -18579,7 +18704,7 @@ const SectionMultiSelect = ({ value, onChange, topSectionsCount = 5, disabled =
18579
18704
  gap: 1,
18580
18705
  flexWrap: "wrap",
18581
18706
  } },
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" } }),
18707
+ 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
18708
  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
18709
  input: Object.assign(Object.assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
18585
18710
  loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
@@ -19643,7 +19768,7 @@ const Logbook$1 = () => {
19643
19768
  fontWeight: 600,
19644
19769
  userSelect: "none",
19645
19770
  } }, "LOGBOOK")),
19646
- React__default.createElement(Group$1, { id: "section-logbook-entry-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
19771
+ React__default.createElement(Group, { id: "section-logbook-entry-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
19647
19772
  React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
19648
19773
  React__default.createElement(Box, { sx: {
19649
19774
  display: "flex",
@@ -20222,7 +20347,7 @@ const Logbook = () => {
20222
20347
  fontWeight: 600,
20223
20348
  userSelect: "none",
20224
20349
  } }, "LOGBOOK REPORT")),
20225
- React__default.createElement(Group$1, { id: "section-logbook-report-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
20350
+ React__default.createElement(Group, { id: "section-logbook-report-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
20226
20351
  React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
20227
20352
  React__default.createElement(Box, { sx: {
20228
20353
  display: "flex",
@@ -20461,7 +20586,16 @@ const AreaSelector = () => {
20461
20586
  borderRadius: "2px",
20462
20587
  overflowY: "auto",
20463
20588
  } },
20464
- React__default.createElement(List, { dense: true, style: { padding: 0 } }, areasList === null || areasList === void 0 ? void 0 : areasList.map((area) => (React__default.createElement(ListItemButton, { key: `Area-${area === null || area === void 0 ? void 0 : area.AssetId}`, onClick: () => handleChangeAreaId(area === null || area === void 0 ? void 0 : area.AssetId, area === null || area === void 0 ? void 0 : area.AssetName), style: { cursor: "pointer", width: "100%" } },
20589
+ React__default.createElement(List, { dense: true, style: { padding: 0 } }, areasList === null || areasList === void 0 ? void 0 : areasList.map((area) => (React__default.createElement(ListItemButton, { key: `Area-${area === null || area === void 0 ? void 0 : area.AssetId}`, onClick: () => handleChangeAreaId(area === null || area === void 0 ? void 0 : area.AssetId, area === null || area === void 0 ? void 0 : area.AssetName), selected: (area === null || area === void 0 ? void 0 : area.AssetId) === defaultAreaIdToChange, sx: {
20590
+ "&.Mui-selected": {
20591
+ backgroundColor: (theme) => alpha(theme.palette.info.main, 0.2),
20592
+ "&:hover": {
20593
+ backgroundColor: (theme) => alpha(theme.palette.info.main, 0.4),
20594
+ },
20595
+ },
20596
+ cursor: "pointer",
20597
+ width: "100%",
20598
+ } },
20465
20599
  React__default.createElement(ListItemText, { primary: area === null || area === void 0 ? void 0 : area.AssetName })))))))))),
20466
20600
  React__default.createElement(DialogActions$1, null,
20467
20601
  React__default.createElement(Button, { autoFocus: true, onClick: handleCancel, color: "primary" }, "Cancel"),
@@ -20474,5 +20608,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
20474
20608
  AreaSelector: AreaSelector
20475
20609
  });
20476
20610
 
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 };
20611
+ 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
20612
  //# sourceMappingURL=index.esm.js.map