@dexteel/mesf-core 7.8.1 → 7.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/dist/controls/section-selector/SectionMultiSelect.d.ts +11 -0
  4. package/dist/controls/section-selector/SectionSelector.d.ts +11 -0
  5. package/dist/controls/section-selector/hooks/index.d.ts +2 -0
  6. package/dist/controls/section-selector/hooks/useSections.d.ts +7 -0
  7. package/dist/controls/section-selector/hooks/useTopSections.d.ts +6 -0
  8. package/dist/controls/section-selector/index.d.ts +5 -0
  9. package/dist/controls/section-selector/models/Section.d.ts +22 -0
  10. package/dist/controls/section-selector/repositories/SectionRepository.d.ts +16 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.esm.js +3129 -347
  13. package/dist/index.esm.js.map +1 -1
  14. package/dist/pages/section-logbook/entry/LogbookPage.d.ts +3 -0
  15. package/dist/pages/section-logbook/entry/components/Logbook.d.ts +2 -0
  16. package/dist/pages/section-logbook/entry/components/attachments/AttachmentModal.d.ts +12 -0
  17. package/dist/pages/section-logbook/entry/components/attachments/AttachmentPlugin.d.ts +15 -0
  18. package/dist/pages/section-logbook/entry/components/attachments/DeleteAttachmentConfirmationDialog.d.ts +9 -0
  19. package/dist/pages/section-logbook/entry/components/dialog/DeleteEntryDialog.d.ts +9 -0
  20. package/dist/pages/section-logbook/entry/components/entry-viewer/ContentInput.d.ts +16 -0
  21. package/dist/pages/section-logbook/entry/components/entry-viewer/EntryViewer.d.ts +17 -0
  22. package/dist/pages/section-logbook/entry/components/filters/filters.d.ts +10 -0
  23. package/dist/pages/section-logbook/entry/hooks/useEntries.d.ts +8 -0
  24. package/dist/pages/section-logbook/entry/hooks/useEntrySubmission.d.ts +34 -0
  25. package/dist/pages/section-logbook/entry/hooks/useLogbookEntryOptionsFunctions.d.ts +12 -0
  26. package/dist/pages/section-logbook/entry/hooks/useTableData.d.ts +10 -0
  27. package/dist/pages/section-logbook/entry/index.d.ts +2 -0
  28. package/dist/pages/section-logbook/entry/models/Entry.d.ts +22 -0
  29. package/dist/pages/section-logbook/entry/models/EntryAttachment.d.ts +20 -0
  30. package/dist/pages/section-logbook/entry/repository/LogbookRepository.d.ts +34 -0
  31. package/dist/pages/section-logbook/index.d.ts +22 -0
  32. package/dist/pages/section-logbook/report/LogbookPage.d.ts +3 -0
  33. package/dist/pages/section-logbook/report/components/Logbook.d.ts +2 -0
  34. package/dist/pages/section-logbook/report/components/entry-viewer/EntryViewer.d.ts +13 -0
  35. package/dist/pages/section-logbook/report/components/filters/filters.d.ts +14 -0
  36. package/dist/pages/section-logbook/report/hooks/useEntriesReport.d.ts +10 -0
  37. package/dist/pages/section-logbook/report/hooks/useTableData.d.ts +8 -0
  38. package/dist/pages/section-logbook/report/index.d.ts +2 -0
  39. package/dist/pages/section-logbook/report/repository/LogbookRepository.d.ts +8 -0
  40. package/dist/pages/section-logbook/shared/LogbookSectionPage.d.ts +2 -0
  41. package/dist/pages/section-logbook/shared/components/LogbookSection.d.ts +2 -0
  42. package/dist/pages/section-logbook/shared/components/entry-viewer/SectionEntryViewer.d.ts +14 -0
  43. package/dist/pages/section-logbook/shared/components/entry-viewer/index.d.ts +1 -0
  44. package/dist/pages/section-logbook/shared/components/filters/SectionFilters.d.ts +15 -0
  45. package/dist/pages/section-logbook/shared/components/filters/index.d.ts +1 -0
  46. package/dist/pages/section-logbook/shared/hooks/index.d.ts +2 -0
  47. package/dist/pages/section-logbook/shared/hooks/useSectionEntries.d.ts +7 -0
  48. package/dist/pages/section-logbook/shared/hooks/useTableData.d.ts +11 -0
  49. package/dist/pages/section-logbook/shared/index.d.ts +6 -0
  50. package/dist/pages/section-logbook/shared/models/SectionEntry.d.ts +16 -0
  51. package/dist/pages/section-logbook/shared/repository/SectionRepository.d.ts +25 -0
  52. package/dist/pages/section-logbook/useGridDefinitions.d.ts +9 -0
  53. package/dist/reducers/LogbookSettingsReducer.d.ts +11 -0
  54. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -34,9 +34,9 @@ import { DataGrid, GridOverlay } from '@mui/x-data-grid';
34
34
  import PropTypes from 'prop-types';
35
35
  import GetAppIcon from '@mui/icons-material/GetApp';
36
36
  import { DatePicker } from '@mui/x-date-pickers/DatePicker';
37
- import moment$9 from 'moment-timezone';
37
+ import moment$g from 'moment-timezone';
38
38
  import { useParams, useNavigate, useSearchParams, Link, Navigate, Routes, Route, useLocation, BrowserRouter } from 'react-router-dom';
39
- import moment$8 from 'moment';
39
+ import moment$f from 'moment';
40
40
  import SkipNextIcon from '@mui/icons-material/SkipNext';
41
41
  import PersonOutlineIcon from '@mui/icons-material/PersonOutline';
42
42
  import LockIcon from '@mui/icons-material/Lock';
@@ -59,7 +59,7 @@ import { DateTimePicker as DateTimePicker$1 } from '@mui/x-date-pickers/DateTime
59
59
  import ClearAllIcon from '@mui/icons-material/ClearAll';
60
60
  import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
61
61
  import axios from 'axios';
62
- import { Group as Group$1, Panel, Separator } from 'react-resizable-panels';
62
+ import { Group as Group$1, Panel, Separator, useDefaultLayout } from 'react-resizable-panels';
63
63
  import { LocalizationProvider as LocalizationProvider$1 } from '@mui/x-date-pickers/LocalizationProvider';
64
64
  import InsertChartIcon from '@mui/icons-material/InsertChart';
65
65
  import ReactECharts from 'echarts-for-react';
@@ -903,7 +903,7 @@ var MESApiService = /** @class */ (function () {
903
903
  data.dataBaseName = database;
904
904
  data.parameters = formattedParameters;
905
905
  Date.prototype.toJSON = function () {
906
- return moment$8(this).format("YYYY-MM-DDTHH:mm:ss");
906
+ return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
907
907
  }; // eslint-disable-line
908
908
  isError = { ok: true };
909
909
  return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/Execute", {
@@ -962,7 +962,7 @@ var MESApiService = /** @class */ (function () {
962
962
  data.method = procedure;
963
963
  data.parameters = formattedParameters;
964
964
  Date.prototype.toJSON = function () {
965
- return moment$8(this).format("YYYY-MM-DDTHH:mm:ss");
965
+ return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
966
966
  }; // eslint-disable-line
967
967
  curatedMethod = procedure.replace(/[\[\]]/g, "");
968
968
  _a.label = 1;
@@ -1017,7 +1017,7 @@ var MESApiService = /** @class */ (function () {
1017
1017
  data.dataBaseName = database;
1018
1018
  data.parameters = formattedParameters;
1019
1019
  Date.prototype.toJSON = function () {
1020
- return moment$8(this).format("YYYY-MM-DDTHH:mm:ss");
1020
+ return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
1021
1021
  }; // eslint-disable-line
1022
1022
  isError = { ok: true };
1023
1023
  return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/ExecuteJSON", {
@@ -1074,7 +1074,7 @@ var MESApiService = /** @class */ (function () {
1074
1074
  formattedParameters.push(formattedParameter);
1075
1075
  });
1076
1076
  Date.prototype.toJSON = function () {
1077
- return moment$8(this).format("YYYY-MM-DDTHH:mm:ss");
1077
+ return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
1078
1078
  }; // eslint-disable-line
1079
1079
  isError = { ok: true };
1080
1080
  files.forEach(function (element) {
@@ -1141,7 +1141,7 @@ var MESApiService = /** @class */ (function () {
1141
1141
  data.parameters = formattedParameters;
1142
1142
  data.fileName = fileName || "Default.xlsx";
1143
1143
  Date.prototype.toJSON = function () {
1144
- return moment$8(this).format("YYYY-MM-DDTHH:mm:ss");
1144
+ return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
1145
1145
  }; // eslint-disable-line
1146
1146
  isError = { ok: true };
1147
1147
  return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/Export", {
@@ -1219,7 +1219,7 @@ var MESApiService = /** @class */ (function () {
1219
1219
  data.parameters = formattedParameters;
1220
1220
  data.fileName = fileName || "Default.xlsx";
1221
1221
  Date.prototype.toJSON = function () {
1222
- return moment$8(this).format("YYYY-MM-DDTHH:mm:ss");
1222
+ return moment$f(this).format("YYYY-MM-DDTHH:mm:ss");
1223
1223
  }; // eslint-disable-line
1224
1224
  isError = { ok: true };
1225
1225
  return [2 /*return*/, fetch(this.config.API_PROCEDURE_URL + "/ExportExcel", {
@@ -1771,7 +1771,7 @@ var TimeService = /** @class */ (function () {
1771
1771
  else {
1772
1772
  this.timeZone = timeZone;
1773
1773
  }
1774
- moment$9.tz.setDefault(this.timeZone);
1774
+ moment$g.tz.setDefault(this.timeZone);
1775
1775
  };
1776
1776
  TimeService.prototype.toUTC = function (datetime, format$1) {
1777
1777
  try {
@@ -1810,7 +1810,7 @@ var TimeService = /** @class */ (function () {
1810
1810
  };
1811
1811
  return TimeService;
1812
1812
  }());
1813
- var getMomentTz = function () { return moment$9; };
1813
+ var getMomentTz = function () { return moment$g; };
1814
1814
  var dxtServerTimeZone = function () {
1815
1815
  return TimeService.getInstance().getServerTimeZone;
1816
1816
  };
@@ -4322,7 +4322,7 @@ var useProfilesOptionsFunctions = function (_a) {
4322
4322
  };
4323
4323
  };
4324
4324
 
4325
- var useTableData$5 = function (_a) {
4325
+ var useTableData$7 = function (_a) {
4326
4326
  var setProfileId = _a.setProfileId, setModalProceduresProfile = _a.setModalProceduresProfile, setModalDeleteProfile = _a.setModalDeleteProfile, showContextMenu = _a.showContextMenu;
4327
4327
  var columnDefs = [
4328
4328
  {
@@ -4441,7 +4441,7 @@ var TableProfiles = function () {
4441
4441
  setModalProceduresProfile: setModalProceduresProfile,
4442
4442
  }).getMenuOptions;
4443
4443
  var _h = useContextMenuMESF(), showContextMenu = _h.showContextMenu, registerConfig = _h.registerConfig;
4444
- var columnDefs = useTableData$5({
4444
+ var columnDefs = useTableData$7({
4445
4445
  setModalDeleteProfile: setModalDeleteProfile,
4446
4446
  setModalProceduresProfile: setModalProceduresProfile,
4447
4447
  setProfileId: setProfile,
@@ -5272,7 +5272,7 @@ var buttonsCellRenderer = function (params) {
5272
5272
  React__default.createElement(FormatListBulletedSharpIcon, { style: { height: "auto" }, color: "action" })))));
5273
5273
  };
5274
5274
 
5275
- var useTableData$4 = function (_a) {
5275
+ var useTableData$6 = function (_a) {
5276
5276
  var setUserId = _a.setUserId, setOpenModalEditDataUser = _a.setOpenModalEditDataUser, setOpenModalDeleteUser = _a.setOpenModalDeleteUser, setOpenModalChangePasswordd = _a.setOpenModalChangePasswordd, showContextMenu = _a.showContextMenu;
5277
5277
  var columnDefs = [
5278
5278
  {
@@ -5442,7 +5442,7 @@ var TableUsers = function () {
5442
5442
  setShowChangePasswordModal: setOpenModalChangePasswordd,
5443
5443
  }).getMenuOptions;
5444
5444
  var _k = useContextMenuMESF(), showContextMenu = _k.showContextMenu, registerConfig = _k.registerConfig;
5445
- var columnDefs = useTableData$4({
5445
+ var columnDefs = useTableData$6({
5446
5446
  setUserId: setUserId,
5447
5447
  setOpenModalEditDataUser: setOpenModalEditDataUser,
5448
5448
  setOpenModalDeleteUser: setOpenModalDeleteUser,
@@ -6223,11 +6223,11 @@ var useShiftNavigatorManager = function () {
6223
6223
  case 1:
6224
6224
  resp = _a.sent();
6225
6225
  if (resp.ok) {
6226
- shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$8
6226
+ shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$f
6227
6227
  .utc(resp.data.CurrentProductionDate)
6228
- .toDate(), CurrentStart: moment$8.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$8.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$8
6228
+ .toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
6229
6229
  .utc(resp.data.PreviousProductionDate)
6230
- .toDate(), PreviousStart: moment$8.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$8.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$8.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$8.utc(resp.data.LastStart).toDate(), LastEnd: moment$8.utc(resp.data.LastEnd).toDate() });
6230
+ .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() });
6231
6231
  setShiftInfo(shift);
6232
6232
  return [2 /*return*/, shift];
6233
6233
  }
@@ -6252,11 +6252,11 @@ var useShiftNavigatorManager = function () {
6252
6252
  case 2:
6253
6253
  resp = _a.sent();
6254
6254
  if (resp.ok) {
6255
- shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$8
6255
+ shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$f
6256
6256
  .utc(resp.data.CurrentProductionDate)
6257
- .toDate(), CurrentStart: moment$8.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$8.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$8
6257
+ .toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
6258
6258
  .utc(resp.data.PreviousProductionDate)
6259
- .toDate(), PreviousStart: moment$8.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$8.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$8.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$8.utc(resp.data.LastStart).toDate(), LastEnd: moment$8.utc(resp.data.LastEnd).toDate() });
6259
+ .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() });
6260
6260
  setShiftInfo(shift);
6261
6261
  return [2 /*return*/, shift];
6262
6262
  }
@@ -6282,11 +6282,11 @@ var useShiftNavigatorManager = function () {
6282
6282
  case 1:
6283
6283
  resp = _a.sent();
6284
6284
  if (resp.ok) {
6285
- shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$8
6285
+ shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$f
6286
6286
  .utc(resp.data.CurrentProductionDate)
6287
- .toDate(), CurrentStart: moment$8.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$8.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$8
6287
+ .toDate(), CurrentStart: moment$f.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$f.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$f
6288
6288
  .utc(resp.data.PreviousProductionDate)
6289
- .toDate(), PreviousStart: moment$8.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$8.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$8.utc(resp.data.LastProductionDate).toDate(), LastStart: moment$8.utc(resp.data.LastStart).toDate(), LastEnd: moment$8.utc(resp.data.LastEnd).toDate() });
6289
+ .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() });
6290
6290
  setShiftInfo(shift);
6291
6291
  return [2 /*return*/, shift];
6292
6292
  }
@@ -6384,13 +6384,13 @@ var ShiftDayNavigatorControl = function (_a) {
6384
6384
  case 2:
6385
6385
  resp = _a.sent();
6386
6386
  if (resp.ok) {
6387
- shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$9
6387
+ shift = __assign(__assign({}, resp.data), { CurrentProductionDate: moment$g
6388
6388
  .utc(resp.data.CurrentProductionDate)
6389
- .toDate(), CurrentStart: moment$9.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$9.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$9
6389
+ .toDate(), CurrentStart: moment$g.utc(resp.data.CurrentStart).toDate(), CurrentEnd: moment$g.utc(resp.data.CurrentEnd).toDate(), PreviousProductionDate: moment$g
6390
6390
  .utc(resp.data.PreviousProductionDate)
6391
- .toDate(), PreviousStart: moment$9.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$9.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$9
6391
+ .toDate(), PreviousStart: moment$g.utc(resp.data.PreviousStart).toDate(), PreviousEnd: moment$g.utc(resp.data.PreviousEnd).toDate(), LastProductionDate: moment$g
6392
6392
  .utc(resp.data.LastProductionDate)
6393
- .toDate(), LastStart: moment$9.utc(resp.data.LastStart).toDate(), LastEnd: moment$9.utc(resp.data.LastEnd).toDate() });
6393
+ .toDate(), LastStart: moment$g.utc(resp.data.LastStart).toDate(), LastEnd: moment$g.utc(resp.data.LastEnd).toDate() });
6394
6394
  setShiftInfoCopy(shift);
6395
6395
  }
6396
6396
  return [3 /*break*/, 4];
@@ -6434,7 +6434,7 @@ var ShiftDayNavigatorControl = function (_a) {
6434
6434
  }, size: "small" },
6435
6435
  React__default.createElement(ArrowBackRounded, null)))),
6436
6436
  React__default.createElement(Grid2, { size: "auto" },
6437
- React__default.createElement(DatePicker, { label: "Current Date", timezone: "UTC", format: "MM/DD/YYYY", maxDate: moment$9(), closeOnSelect: true, formatDensity: "dense", value: moment$9(shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentProductionDate), onChange: function (date) {
6437
+ 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: function (date) {
6438
6438
  if (date) {
6439
6439
  getShiftDataFromAPI(date.toDate(), 0).then(function () { });
6440
6440
  }
@@ -6516,8 +6516,8 @@ var getShiftsRangeByParameters = function (period_1) {
6516
6516
  if (resp.ok) {
6517
6517
  data = resp.data;
6518
6518
  data.tables[0].rows.map(function (shift) {
6519
- shift.Start = moment$9.utc(shift["Start"]).toDate();
6520
- shift.End = moment$9.utc(shift["End"]).toDate();
6519
+ shift.Start = moment$g.utc(shift["Start"]).toDate();
6520
+ shift.End = moment$g.utc(shift["End"]).toDate();
6521
6521
  });
6522
6522
  return [2 /*return*/, {
6523
6523
  ok: true,
@@ -6567,13 +6567,13 @@ var ShiftPeriodNavigatorControl = function (_a) {
6567
6567
  case 1:
6568
6568
  _a.trys.push([1, 6, , 7]);
6569
6569
  if (!(direction === "prev" && (startShift === null || startShift === void 0 ? void 0 : startShift.Start))) return [3 /*break*/, 3];
6570
- return [4 /*yield*/, searchShiftsRangeByParameters(period, moment$9(startShift.Start).toDate(), null, false, "prev")];
6570
+ return [4 /*yield*/, searchShiftsRangeByParameters(period, moment$g(startShift.Start).toDate(), null, false, "prev")];
6571
6571
  case 2:
6572
6572
  _a.sent();
6573
6573
  return [3 /*break*/, 5];
6574
6574
  case 3:
6575
6575
  if (!(direction === "next" && (endShift === null || endShift === void 0 ? void 0 : endShift.End))) return [3 /*break*/, 5];
6576
- return [4 /*yield*/, searchShiftsRangeByParameters(period, null, moment$9(endShift.End).toDate(), false, "next")];
6576
+ return [4 /*yield*/, searchShiftsRangeByParameters(period, null, moment$g(endShift.End).toDate(), false, "next")];
6577
6577
  case 4:
6578
6578
  _a.sent();
6579
6579
  _a.label = 5;
@@ -6729,8 +6729,8 @@ var ShiftPeriodNavigatorControl = function (_a) {
6729
6729
  newPeriod = event.target.value;
6730
6730
  setPeriod(newPeriod);
6731
6731
  if (!(newPeriod === "Custom")) return [3 /*break*/, 2];
6732
- today = moment$9();
6733
- yesterday = moment$9().subtract(1, "day");
6732
+ today = moment$g();
6733
+ yesterday = moment$g().subtract(1, "day");
6734
6734
  setCustomStartDate(yesterday);
6735
6735
  setCustomEndDate(today);
6736
6736
  return [4 /*yield*/, searchShiftsRangeByParameters("Custom", yesterday.toDate(), today.toDate(), false)];
@@ -6740,7 +6740,7 @@ var ShiftPeriodNavigatorControl = function (_a) {
6740
6740
  case 2:
6741
6741
  setCustomStartDate(null);
6742
6742
  setCustomEndDate(null);
6743
- return [4 /*yield*/, searchShiftsRangeByParameters(newPeriod, null, (endShift === null || endShift === void 0 ? void 0 : endShift.Start) ? moment$9(endShift.Start).toDate() : null, false)];
6743
+ return [4 /*yield*/, searchShiftsRangeByParameters(newPeriod, null, (endShift === null || endShift === void 0 ? void 0 : endShift.Start) ? moment$g(endShift.Start).toDate() : null, false)];
6744
6744
  case 3:
6745
6745
  _a.sent();
6746
6746
  _a.label = 4;
@@ -6804,10 +6804,10 @@ var ShiftPeriodNavigatorControl = function (_a) {
6804
6804
  },
6805
6805
  } },
6806
6806
  React__default.createElement(DatePicker$1, { label: "Start", format: dateFormat, value: isCustomMode
6807
- ? customStartDate || moment$9().subtract(1, "day")
6808
- : moment$9((startShift === null || startShift === void 0 ? void 0 : startShift.Start) || moment$9().subtract(1, "day")), onChange: function (value) {
6809
- return handleDateChange(value ? moment$9(value) : null, "start");
6810
- }, disabled: loadingShiftPeriodList, maxDate: isCustomMode ? moment$9() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6807
+ ? customStartDate || moment$g().subtract(1, "day")
6808
+ : moment$g((startShift === null || startShift === void 0 ? void 0 : startShift.Start) || moment$g().subtract(1, "day")), onChange: function (value) {
6809
+ return handleDateChange(value ? moment$g(value) : null, "start");
6810
+ }, disabled: loadingShiftPeriodList, maxDate: isCustomMode ? moment$g() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6811
6811
  textField: function (props) { return (React__default.createElement(TextField, __assign({}, props, { size: "small", variant: "outlined", fullWidth: true, style: { width: "100%" }, InputProps: __assign(__assign({}, props.InputProps), { style: { paddingTop: "2px" } }) }))); },
6812
6812
  openPickerIcon: function () { return (React__default.createElement("div", { style: {
6813
6813
  display: "flex",
@@ -6849,10 +6849,10 @@ var ShiftPeriodNavigatorControl = function (_a) {
6849
6849
  },
6850
6850
  } },
6851
6851
  React__default.createElement(DatePicker$1, { label: "End", format: dateFormat, value: isCustomMode
6852
- ? customEndDate || moment$9()
6853
- : moment$9((endShift === null || endShift === void 0 ? void 0 : endShift.End) || (endShift === null || endShift === void 0 ? void 0 : endShift.Start) || moment$9()), onChange: function (value) {
6854
- return handleDateChange(value ? moment$9(value) : null, "end");
6855
- }, disabled: loadingShiftPeriodList, minDate: isCustomMode && customStartDate ? customStartDate : undefined, maxDate: isCustomMode ? moment$9() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6852
+ ? customEndDate || moment$g()
6853
+ : moment$g((endShift === null || endShift === void 0 ? void 0 : endShift.End) || (endShift === null || endShift === void 0 ? void 0 : endShift.Start) || moment$g()), onChange: function (value) {
6854
+ return handleDateChange(value ? moment$g(value) : null, "end");
6855
+ }, disabled: loadingShiftPeriodList, minDate: isCustomMode && customStartDate ? customStartDate : undefined, maxDate: isCustomMode ? moment$g() : undefined, enableAccessibleFieldDOMStructure: false, slots: {
6856
6856
  textField: function (props) { return (React__default.createElement(TextField, __assign({}, props, { size: "small", variant: "outlined", fullWidth: true, style: { width: "100%" }, InputProps: __assign(__assign({}, props.InputProps), { style: { paddingTop: "2px" } }) }))); },
6857
6857
  openPickerIcon: function () { return (React__default.createElement("div", { style: {
6858
6858
  display: "flex",
@@ -7532,15 +7532,15 @@ var getJobs = function () { return __awaiter(void 0, void 0, void 0, function ()
7532
7532
  if (resp.ok) {
7533
7533
  rows = get(resp, "data.tables[0].rows", []);
7534
7534
  rows = rows.map(function (job) { return (__assign(__assign({}, job), { LastStarted: job.LastStarted
7535
- ? moment$8.utc(job["LastStarted"]).toDate()
7535
+ ? moment$f.utc(job["LastStarted"]).toDate()
7536
7536
  : null, LastContact: job.LastContact
7537
- ? moment$8.utc(job["LastContact"]).toDate()
7537
+ ? moment$f.utc(job["LastContact"]).toDate()
7538
7538
  : null, LastCounter: job.LastCounter
7539
- ? moment$8.utc(job["LastCounter"]).toDate()
7540
- : null, StartTime: job.StartTime ? moment$8.utc(job["StartTime"]).toDate() : null, NextExecutionTime: job.NextExecutionTime
7541
- ? moment$8.utc(job["NextExecutionTime"]).toDate()
7539
+ ? moment$f.utc(job["LastCounter"]).toDate()
7540
+ : null, StartTime: job.StartTime ? moment$f.utc(job["StartTime"]).toDate() : null, NextExecutionTime: job.NextExecutionTime
7541
+ ? moment$f.utc(job["NextExecutionTime"]).toDate()
7542
7542
  : null, LastExecutionTime: job.LastExecutionTime
7543
- ? moment$8.utc(job["LastExecutionTime"]).toDate()
7543
+ ? moment$f.utc(job["LastExecutionTime"]).toDate()
7544
7544
  : null })); });
7545
7545
  return [2 /*return*/, rows];
7546
7546
  }
@@ -7800,7 +7800,7 @@ var JobDetails = function (_a) {
7800
7800
  React__default.createElement(Controller, { name: "StartTime", control: control, render: function (_a) {
7801
7801
  var field = _a.field, error = _a.fieldState.error;
7802
7802
  return (React__default.createElement(React__default.Fragment, null,
7803
- React__default.createElement(DateTimePicker, { label: "Start Time", value: field.value ? moment$9(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: {
7803
+ 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: {
7804
7804
  textField: {
7805
7805
  size: "small",
7806
7806
  margin: "none",
@@ -7818,7 +7818,7 @@ var JobDetails = function (_a) {
7818
7818
  React__default.createElement(Grid2, { size: { xs: 12, md: 6 } },
7819
7819
  React__default.createElement(Controller, { name: "LastExecutionTime", control: control, render: function (_a) {
7820
7820
  var field = _a.field;
7821
- return (React__default.createElement(DateTimePicker, { label: "Last Execution Time", value: field.value ? moment$9(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: {
7821
+ return (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: {
7822
7822
  textField: {
7823
7823
  size: "small",
7824
7824
  margin: "none",
@@ -7829,7 +7829,7 @@ var JobDetails = function (_a) {
7829
7829
  React__default.createElement(Grid2, { size: { xs: 12, md: 6 } },
7830
7830
  React__default.createElement(Controller, { name: "NextExecutionTime", control: control, render: function (_a) {
7831
7831
  var field = _a.field;
7832
- return (React__default.createElement(DateTimePicker, { label: "Next Execution Time", value: field.value ? moment$9(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: {
7832
+ return (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: {
7833
7833
  textField: {
7834
7834
  size: "small",
7835
7835
  margin: "none",
@@ -7953,7 +7953,7 @@ var useJobsTableData = function (_a) {
7953
7953
  headerName: "Next Execution",
7954
7954
  valueFormatter: function (_a) {
7955
7955
  var value = _a.value;
7956
- return value === null ? "" : moment$8(value).format("DD/MM/YY HH:mm");
7956
+ return value === null ? "" : moment$f(value).format("DD/MM/YY HH:mm");
7957
7957
  },
7958
7958
  flex: 2,
7959
7959
  },
@@ -8281,7 +8281,7 @@ var CodeFilter = function (_a) {
8281
8281
  var DateFilter = function (_a) {
8282
8282
  var date = _a.date, setDate = _a.setDate, _b = _a.label, label = _b === void 0 ? "Date" : _b, minDate = _a.minDate, maxDate = _a.maxDate;
8283
8283
  return (React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
8284
- React__default.createElement(DatePicker$1, { format: "MM/DD/YYYY", minDate: minDate ? moment$8(minDate) : undefined, maxDate: maxDate ? moment$8(maxDate) : undefined, sx: {
8284
+ React__default.createElement(DatePicker$1, { format: "MM/DD/YYYY", minDate: minDate ? moment$f(minDate) : undefined, maxDate: maxDate ? moment$f(maxDate) : undefined, sx: {
8285
8285
  minWidth: "100%",
8286
8286
  borderTopLeftRadius: 3,
8287
8287
  borderTopRightRadius: 3,
@@ -8291,7 +8291,7 @@ var DateFilter = function (_a) {
8291
8291
  size: "small",
8292
8292
  fullWidth: true,
8293
8293
  },
8294
- }, label: label, value: date ? moment$8(date) : null, onChange: function (newDate) { return setDate(newDate ? newDate.toDate() : null); } })));
8294
+ }, label: label, value: date ? moment$f(date) : null, onChange: function (newDate) { return setDate(newDate ? newDate.toDate() : null); } })));
8295
8295
  };
8296
8296
 
8297
8297
  var SearchFilter = function (_a) {
@@ -8403,7 +8403,7 @@ var getLogs = function (_a) { return __awaiter(void 0, [_a], void 0, function (_
8403
8403
  resp = _c.sent();
8404
8404
  if (resp.ok) {
8405
8405
  rows = get(resp, "data.tables[0].rows", []);
8406
- rows = rows.map(function (log) { return (__assign(__assign({}, log), { Timestamp: log.Timestamp ? moment$8.utc(log["Timestamp"]).toDate() : null })); });
8406
+ rows = rows.map(function (log) { return (__assign(__assign({}, log), { Timestamp: log.Timestamp ? moment$f.utc(log["Timestamp"]).toDate() : null })); });
8407
8407
  return [2 /*return*/, rows];
8408
8408
  }
8409
8409
  else {
@@ -8532,8 +8532,8 @@ var getLogTypeByCodeId = function (logTypeCodeId) {
8532
8532
  return get(LOG_TYPE_CODES, "".concat(logTypeCodeId, ".description"), " -");
8533
8533
  };
8534
8534
  var TableLogs = function () {
8535
- var _a = useState(moment$8().add(-5, "days").hour(0).minute(0).second(0).toDate()), startDate = _a[0], setStartDate = _a[1];
8536
- var _b = useState(moment$8().hour(23).minute(59).second(59).toDate()), endDate = _b[0], setEndDate = _b[1];
8535
+ var _a = useState(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate()), startDate = _a[0], setStartDate = _a[1];
8536
+ var _b = useState(moment$f().hour(23).minute(59).second(59).toDate()), endDate = _b[0], setEndDate = _b[1];
8537
8537
  var _c = useState("UTC"), timezone = _c[0], setTimezone = _c[1];
8538
8538
  var _d = useState(""), search = _d[0], setSearch = _d[1];
8539
8539
  var _e = useState(["I", "W", "E"]), logTypeCode = _e[0], setLogTypeCode = _e[1];
@@ -8556,7 +8556,7 @@ var TableLogs = function () {
8556
8556
  return ({
8557
8557
  id: LogId,
8558
8558
  Timestamp: timezone === "UTC"
8559
- ? moment$8(Timestamp).utc().format("YYYY-MM-DD HH:mm:ss z")
8559
+ ? moment$f(Timestamp).utc().format("YYYY-MM-DD HH:mm:ss z")
8560
8560
  : dxtToLocalServerTime(Timestamp, "yyyy-MM-dd HH:mm:ss z"),
8561
8561
  Source: Source,
8562
8562
  Message: isNil(Message) ? "" : Message.replaceAll("Added", " Added"),
@@ -8582,8 +8582,8 @@ var TableLogs = function () {
8582
8582
  var _m = useContextMenuMESF(), showContextMenu = _m.showContextMenu, registerConfig = _m.registerConfig;
8583
8583
  var handleResetButtonClick = function () {
8584
8584
  resetFilter();
8585
- setStartDate(moment$8().add(-5, "days").hour(0).minute(0).second(0).toDate());
8586
- setEndDate(moment$8().hour(23).minute(59).second(59).toDate());
8585
+ setStartDate(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate());
8586
+ setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
8587
8587
  setSearch("");
8588
8588
  gridAPI === null || gridAPI === void 0 ? void 0 : gridAPI.setGridOption("quickFilterText", "");
8589
8589
  setLogTypeCode(["I", "W", "E"]);
@@ -8592,8 +8592,8 @@ var TableLogs = function () {
8592
8592
  };
8593
8593
  // Btn reset data
8594
8594
  var resetFilter = function () {
8595
- setStartDate(moment$8().add(-5, "days").hour(0).minute(0).second(0).toDate());
8596
- setEndDate(moment$8().hour(23).minute(59).second(59).toDate());
8595
+ setStartDate(moment$f().add(-5, "days").hour(0).minute(0).second(0).toDate());
8596
+ setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
8597
8597
  setSearch("");
8598
8598
  gridAPI === null || gridAPI === void 0 ? void 0 : gridAPI.setGridOption("quickFilterText", "");
8599
8599
  setLogTypeCode(["I", "W", "E"]);
@@ -8678,7 +8678,7 @@ var TableLogs = function () {
8678
8678
  setEndDate(null);
8679
8679
  }
8680
8680
  else {
8681
- setEndDate(moment$8().hour(23).minute(59).second(59).toDate());
8681
+ setEndDate(moment$f().hour(23).minute(59).second(59).toDate());
8682
8682
  }
8683
8683
  setAutoRefresh(checked);
8684
8684
  } })),
@@ -8874,14 +8874,14 @@ var CreateShift = function (_a) {
8874
8874
  minWidth: "100%",
8875
8875
  borderTopLeftRadius: 3,
8876
8876
  borderTopRightRadius: 3,
8877
- }, label: "Start", value: value ? moment$8(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
8877
+ }, label: "Start", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
8878
8878
  textField: {
8879
8879
  fullWidth: true,
8880
8880
  variant: "standard",
8881
8881
  },
8882
8882
  } })),
8883
8883
  React.createElement(Grid2, { size: { md: 6, xs: 12 } },
8884
- React.createElement(DatePicker$1, { label: "Time", value: value ? moment$8(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
8884
+ React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
8885
8885
  textField: {
8886
8886
  fullWidth: true,
8887
8887
  variant: "standard",
@@ -9104,7 +9104,7 @@ var DeleteShift = function (_a) {
9104
9104
  minWidth: "100%",
9105
9105
  borderTopLeftRadius: 3,
9106
9106
  borderTopRightRadius: 3,
9107
- }, label: "Start", value: value ? moment$8(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9107
+ }, label: "Start", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9108
9108
  textField: {
9109
9109
  fullWidth: true,
9110
9110
  variant: "standard",
@@ -9112,7 +9112,7 @@ var DeleteShift = function (_a) {
9112
9112
  },
9113
9113
  } })),
9114
9114
  React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9115
- React.createElement(DatePicker$1, { label: "Time", value: value ? moment$8(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9115
+ React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9116
9116
  textField: {
9117
9117
  fullWidth: true,
9118
9118
  variant: "standard",
@@ -9273,14 +9273,14 @@ var EditShift = function (_a) {
9273
9273
  minWidth: "100%",
9274
9274
  borderTopLeftRadius: 3,
9275
9275
  borderTopRightRadius: 3,
9276
- }, label: "Start", value: value ? moment$8(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9276
+ }, label: "Start", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9277
9277
  textField: {
9278
9278
  fullWidth: true,
9279
9279
  variant: "standard",
9280
9280
  },
9281
9281
  } })),
9282
9282
  React.createElement(Grid2, { size: { md: 6, xs: 12 } },
9283
- React.createElement(DatePicker$1, { label: "Time", value: value ? moment$8(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9283
+ React.createElement(DatePicker$1, { label: "Time", value: value ? moment$f(value) : value, onChange: function (evt) { return onChange(evt === null || evt === void 0 ? void 0 : evt.toDate()); }, slotProps: {
9284
9284
  textField: {
9285
9285
  fullWidth: true,
9286
9286
  variant: "standard",
@@ -9472,7 +9472,7 @@ var useShiftsOptionsFunctions = function (_a) {
9472
9472
  };
9473
9473
  };
9474
9474
 
9475
- var useTableData$3 = function (_a) {
9475
+ var useTableData$5 = function (_a) {
9476
9476
  var setShiftSelected = _a.setShiftSelected, setOpenModalEditShift = _a.setOpenModalEditShift, setOpenModalDeleteShift = _a.setOpenModalDeleteShift, showContextMenu = _a.showContextMenu;
9477
9477
  var columnDefs = [
9478
9478
  {
@@ -9480,7 +9480,7 @@ var useTableData$3 = function (_a) {
9480
9480
  headerName: "Pattern Start",
9481
9481
  valueFormatter: function (_a) {
9482
9482
  var value = _a.value;
9483
- return "".concat(moment$8(value).format("L"), ", ").concat(moment$8(value).format("LTS"));
9483
+ return "".concat(moment$f(value).format("L"), ", ").concat(moment$f(value).format("LTS"));
9484
9484
  },
9485
9485
  minWidth: 180,
9486
9486
  flex: 4,
@@ -9621,7 +9621,7 @@ var TableShiftsCrews = function () {
9621
9621
  setShowEditModal: setOpenModalEditShift,
9622
9622
  }).getMenuOptions;
9623
9623
  var _g = useContextMenuMESF(), showContextMenu = _g.showContextMenu, registerConfig = _g.registerConfig;
9624
- var columnDefs = useTableData$3({
9624
+ var columnDefs = useTableData$5({
9625
9625
  setShiftSelected: setShiftSelected,
9626
9626
  setOpenModalEditShift: setOpenModalEditShift,
9627
9627
  setOpenModalDeleteShift: setOpenModalDeleteShift,
@@ -9837,6 +9837,16 @@ var LogbookSettingsInitialState = {
9837
9837
  showShiftCrew: false,
9838
9838
  exportToExcel: false,
9839
9839
  },
9840
+ section: {
9841
+ schema: undefined,
9842
+ withAssetFilter: undefined,
9843
+ filterAssets: undefined,
9844
+ canEditAsset: false,
9845
+ allowAttachments: false,
9846
+ showShiftCrew: false,
9847
+ exportToExcel: false,
9848
+ topSectionsCount: 5,
9849
+ },
9840
9850
  };
9841
9851
 
9842
9852
  var LogbookSettingsContext = createContext(LogbookSettingsInitialState);
@@ -9847,6 +9857,7 @@ var LogbookSettingsProvider = function (_a) {
9847
9857
  var settings = useMemo(function () { return ({
9848
9858
  entry: __assign(__assign({}, LogbookSettingsInitialState.entry), (logbookSettings.entry || {})),
9849
9859
  report: __assign(__assign({}, LogbookSettingsInitialState.report), (logbookSettings.report || {})),
9860
+ section: __assign(__assign({}, LogbookSettingsInitialState.section), (logbookSettings.section || {})),
9850
9861
  }); }, [logbookSettings]);
9851
9862
  return (React__default.createElement(LogbookSettingsContext.Provider, { value: settings }, children));
9852
9863
  };
@@ -9904,7 +9915,7 @@ var useSettingsOptionsFunctions = function (_a) {
9904
9915
  };
9905
9916
  };
9906
9917
 
9907
- var useTableData$2 = function (_a) {
9918
+ var useTableData$4 = function (_a) {
9908
9919
  var setOpenModalEditSetting = _a.setOpenModalEditSetting, setOpenModalDeleteSetting = _a.setOpenModalDeleteSetting, showContextMenu = _a.showContextMenu, setSettingSelected = _a.setSettingSelected;
9909
9920
  var columnDefs = [
9910
9921
  {
@@ -10327,7 +10338,7 @@ var TableSettings = function () {
10327
10338
  setShowCreateModal: setOpenModalNew,
10328
10339
  setShowEditModal: setOpenModalEditSetting,
10329
10340
  }).getMenuOptions;
10330
- var _k = useTableData$2({
10341
+ var _k = useTableData$4({
10331
10342
  setOpenModalEditSetting: setOpenModalEditSetting,
10332
10343
  setOpenModalDeleteSetting: setOpenModalDeleteSetting,
10333
10344
  showContextMenu: showContextMenu,
@@ -11019,7 +11030,7 @@ var renderInput = function (param, onChange, disabled) {
11019
11030
  }, disabled: disabled, fullWidth: true, size: "small", inputProps: { step: "any" } }));
11020
11031
  }
11021
11032
  if (["datetime", "datetime2", "date", "smalldatetime"].includes(type)) {
11022
- return (React__default.createElement(DateTimePicker$1, { label: param.parameterName, value: param.value ? moment$8(param.value) : null, onChange: function (newValue) { return onChange((newValue === null || newValue === void 0 ? void 0 : newValue.toDate()) || null); }, disabled: disabled, slotProps: {
11033
+ return (React__default.createElement(DateTimePicker$1, { label: param.parameterName, value: param.value ? moment$f(param.value) : null, onChange: function (newValue) { return onChange((newValue === null || newValue === void 0 ? void 0 : newValue.toDate()) || null); }, disabled: disabled, slotProps: {
11023
11034
  textField: {
11024
11035
  fullWidth: true,
11025
11036
  size: "small",
@@ -12124,21 +12135,21 @@ var dateNavigator = function (startDate, endDate, scope, operator, current) {
12124
12135
  }
12125
12136
  else {
12126
12137
  var _a = scope.split(" "), quantity = _a[0], duration = _a[1];
12127
- newStartDate = moment$8(newEndDate)
12138
+ newStartDate = moment$f(newEndDate)
12128
12139
  .subtract(quantity, duration[0])
12129
12140
  .toDate();
12130
12141
  }
12131
12142
  }
12132
12143
  else {
12133
12144
  if (scope === "custom") {
12134
- var durationInMs = moment$8(endDate).diff(moment$8(startDate));
12135
- newStartDate = moment$8(startDate)[operator](durationInMs).toDate();
12145
+ var durationInMs = moment$f(endDate).diff(moment$f(startDate));
12146
+ newStartDate = moment$f(startDate)[operator](durationInMs).toDate();
12136
12147
  }
12137
12148
  else {
12138
12149
  var _b = scope.split(" "), quantity = _b[0], duration = _b[1];
12139
- newStartDate = moment$8(startDate)[operator](quantity, duration[0])
12150
+ newStartDate = moment$f(startDate)[operator](quantity, duration[0])
12140
12151
  .toDate();
12141
- newEndDate = moment$8(endDate)[operator](quantity, duration[0])
12152
+ newEndDate = moment$f(endDate)[operator](quantity, duration[0])
12142
12153
  .toDate();
12143
12154
  }
12144
12155
  }
@@ -12581,11 +12592,11 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
12581
12592
  };
12582
12593
  var handlePartialDateNavigator = function (operator) {
12583
12594
  // Calculate 20% of the current period
12584
- var durationInMs = moment$8(timeScopeEnd).diff(moment$8(timeScopeStart));
12595
+ var durationInMs = moment$f(timeScopeEnd).diff(moment$f(timeScopeStart));
12585
12596
  var partialDuration = Math.round(durationInMs * 0.2);
12586
- var newStartDate = moment$8(timeScopeStart)[operator](partialDuration, "milliseconds")
12597
+ var newStartDate = moment$f(timeScopeStart)[operator](partialDuration, "milliseconds")
12587
12598
  .toDate();
12588
- var newEndDate = moment$8(timeScopeEnd)[operator](partialDuration, "milliseconds")
12599
+ var newEndDate = moment$f(timeScopeEnd)[operator](partialDuration, "milliseconds")
12589
12600
  .toDate();
12590
12601
  setTotalScope({
12591
12602
  start: newStartDate,
@@ -12595,7 +12606,7 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
12595
12606
  };
12596
12607
  var handleDateChange = function (newValue, key) {
12597
12608
  var _a, _b;
12598
- var newDate = moment$8(newValue).toDate();
12609
+ var newDate = moment$f(newValue).toDate();
12599
12610
  // If scope is "custom", just update the changed date
12600
12611
  if (scope === "custom") {
12601
12612
  setTotalScope((_a = {}, _a[key] = newDate, _a));
@@ -12711,7 +12722,7 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
12711
12722
  React__default.createElement(FastRewind, { fontSize: "medium", sx: { color: "black" } })))),
12712
12723
  React__default.createElement(Grid2, { size: { md: 3.5 } },
12713
12724
  React__default.createElement(LocalizationProvider$1, { dateAdapter: AdapterMoment },
12714
- React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$8(timeScopeStart), onChange: function (newValue) {
12725
+ React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$f(timeScopeStart), onChange: function (newValue) {
12715
12726
  if (newValue) {
12716
12727
  handleDateChange(newValue.toDate(), "start");
12717
12728
  }
@@ -12736,7 +12747,7 @@ var HeaderSectionV2 = React__default.memo(function (_a) {
12736
12747
  React__default.createElement(MenuItem, { value: "custom" }, "Custom")))),
12737
12748
  React__default.createElement(Grid2, { size: { md: 3.5 } },
12738
12749
  React__default.createElement(LocalizationProvider$1, { dateAdapter: AdapterMoment },
12739
- React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$8(timeScopeEnd), onChange: function (newValue) {
12750
+ React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$f(timeScopeEnd), onChange: function (newValue) {
12740
12751
  if (newValue) {
12741
12752
  handleDateChange(newValue.toDate(), "end");
12742
12753
  }
@@ -16642,7 +16653,7 @@ const FORMATS = {
16642
16653
  year: 'YYYY'
16643
16654
  };
16644
16655
 
16645
- _adapters._date.override(typeof moment$8 === 'function' ? {
16656
+ _adapters._date.override(typeof moment$f === 'function' ? {
16646
16657
  _id: 'moment', // DEBUG ONLY
16647
16658
 
16648
16659
  formats: function() {
@@ -16651,27 +16662,27 @@ _adapters._date.override(typeof moment$8 === 'function' ? {
16651
16662
 
16652
16663
  parse: function(value, format) {
16653
16664
  if (typeof value === 'string' && typeof format === 'string') {
16654
- value = moment$8(value, format);
16655
- } else if (!(value instanceof moment$8)) {
16656
- value = moment$8(value);
16665
+ value = moment$f(value, format);
16666
+ } else if (!(value instanceof moment$f)) {
16667
+ value = moment$f(value);
16657
16668
  }
16658
16669
  return value.isValid() ? value.valueOf() : null;
16659
16670
  },
16660
16671
 
16661
16672
  format: function(time, format) {
16662
- return moment$8(time).format(format);
16673
+ return moment$f(time).format(format);
16663
16674
  },
16664
16675
 
16665
16676
  add: function(time, amount, unit) {
16666
- return moment$8(time).add(amount, unit).valueOf();
16677
+ return moment$f(time).add(amount, unit).valueOf();
16667
16678
  },
16668
16679
 
16669
16680
  diff: function(max, min, unit) {
16670
- return moment$8(max).diff(moment$8(min), unit);
16681
+ return moment$f(max).diff(moment$f(min), unit);
16671
16682
  },
16672
16683
 
16673
16684
  startOf: function(time, unit, weekday) {
16674
- time = moment$8(time);
16685
+ time = moment$f(time);
16675
16686
  if (unit === 'isoWeek') {
16676
16687
  weekday = Math.trunc(Math.min(Math.max(0, weekday), 6));
16677
16688
  return time.isoWeekday(weekday).startOf('day').valueOf();
@@ -16680,7 +16691,7 @@ _adapters._date.override(typeof moment$8 === 'function' ? {
16680
16691
  },
16681
16692
 
16682
16693
  endOf: function(time, unit) {
16683
- return moment$8(time).endOf(unit).valueOf();
16694
+ return moment$f(time).endOf(unit).valueOf();
16684
16695
  }
16685
16696
  } : {});
16686
16697
 
@@ -16735,7 +16746,7 @@ var ColorPicker = function (_a) {
16735
16746
  };
16736
16747
 
16737
16748
  var TrendingsInitialState = {
16738
- timeScopeStart: moment$8(new Date()).subtract(1, "days").toDate(),
16749
+ timeScopeStart: moment$f(new Date()).subtract(1, "days").toDate(),
16739
16750
  timeScopeEnd: new Date(),
16740
16751
  scope: "1 day",
16741
16752
  graphPan: false,
@@ -16775,32 +16786,32 @@ var TrendingsReducer = createSlice({
16775
16786
  if (payload.scope !== "custom") {
16776
16787
  switch (payload.scope) {
16777
16788
  case "10 min":
16778
- state.timeScopeStart = moment$8(state.timeScopeEnd)
16789
+ state.timeScopeStart = moment$f(state.timeScopeEnd)
16779
16790
  .subtract(10, "minutes")
16780
16791
  .toDate();
16781
16792
  break;
16782
16793
  case "1 hour":
16783
- state.timeScopeStart = moment$8(state.timeScopeEnd)
16794
+ state.timeScopeStart = moment$f(state.timeScopeEnd)
16784
16795
  .subtract(1, "hours")
16785
16796
  .toDate();
16786
16797
  break;
16787
16798
  case "4 hours":
16788
- state.timeScopeStart = moment$8(state.timeScopeEnd)
16799
+ state.timeScopeStart = moment$f(state.timeScopeEnd)
16789
16800
  .subtract(4, "hours")
16790
16801
  .toDate();
16791
16802
  break;
16792
16803
  case "12 hours":
16793
- state.timeScopeStart = moment$8(state.timeScopeEnd)
16804
+ state.timeScopeStart = moment$f(state.timeScopeEnd)
16794
16805
  .subtract(12, "hours")
16795
16806
  .toDate();
16796
16807
  break;
16797
16808
  case "1 day":
16798
- state.timeScopeStart = moment$8(state.timeScopeEnd)
16809
+ state.timeScopeStart = moment$f(state.timeScopeEnd)
16799
16810
  .subtract(1, "days")
16800
16811
  .toDate();
16801
16812
  break;
16802
16813
  case "10 days":
16803
- state.timeScopeStart = moment$8(state.timeScopeEnd)
16814
+ state.timeScopeStart = moment$f(state.timeScopeEnd)
16804
16815
  .subtract(10, "days")
16805
16816
  .toDate();
16806
16817
  break;
@@ -16831,32 +16842,32 @@ var TrendingsReducer = createSlice({
16831
16842
  if (state.scope !== "custom") {
16832
16843
  switch (state.scope) {
16833
16844
  case "10 min":
16834
- state.timeScopeEnd = moment$8(payload.start)
16845
+ state.timeScopeEnd = moment$f(payload.start)
16835
16846
  .add(10, "minutes")
16836
16847
  .toDate();
16837
16848
  break;
16838
16849
  case "1 hour":
16839
- state.timeScopeEnd = moment$8(payload.start)
16850
+ state.timeScopeEnd = moment$f(payload.start)
16840
16851
  .add(1, "hours")
16841
16852
  .toDate();
16842
16853
  break;
16843
16854
  case "4 hours":
16844
- state.timeScopeEnd = moment$8(payload.start)
16855
+ state.timeScopeEnd = moment$f(payload.start)
16845
16856
  .add(4, "hours")
16846
16857
  .toDate();
16847
16858
  break;
16848
16859
  case "12 hours":
16849
- state.timeScopeEnd = moment$8(payload.start)
16860
+ state.timeScopeEnd = moment$f(payload.start)
16850
16861
  .add(12, "hours")
16851
16862
  .toDate();
16852
16863
  break;
16853
16864
  case "1 day":
16854
- state.timeScopeEnd = moment$8(payload.start)
16865
+ state.timeScopeEnd = moment$f(payload.start)
16855
16866
  .add(1, "days")
16856
16867
  .toDate();
16857
16868
  break;
16858
16869
  case "10 days":
16859
- state.timeScopeEnd = moment$8(payload.start)
16870
+ state.timeScopeEnd = moment$f(payload.start)
16860
16871
  .add(10, "days")
16861
16872
  .toDate();
16862
16873
  break;
@@ -16869,32 +16880,32 @@ var TrendingsReducer = createSlice({
16869
16880
  if (state.scope !== "custom") {
16870
16881
  switch (state.scope) {
16871
16882
  case "10 min":
16872
- state.timeScopeStart = moment$8(payload.end)
16883
+ state.timeScopeStart = moment$f(payload.end)
16873
16884
  .subtract(10, "minutes")
16874
16885
  .toDate();
16875
16886
  break;
16876
16887
  case "1 hour":
16877
- state.timeScopeStart = moment$8(payload.end)
16888
+ state.timeScopeStart = moment$f(payload.end)
16878
16889
  .subtract(1, "hours")
16879
16890
  .toDate();
16880
16891
  break;
16881
16892
  case "4 hours":
16882
- state.timeScopeStart = moment$8(payload.end)
16893
+ state.timeScopeStart = moment$f(payload.end)
16883
16894
  .subtract(4, "hours")
16884
16895
  .toDate();
16885
16896
  break;
16886
16897
  case "12 hours":
16887
- state.timeScopeStart = moment$8(payload.end)
16898
+ state.timeScopeStart = moment$f(payload.end)
16888
16899
  .subtract(12, "hours")
16889
16900
  .toDate();
16890
16901
  break;
16891
16902
  case "1 day":
16892
- state.timeScopeStart = moment$8(payload.end)
16903
+ state.timeScopeStart = moment$f(payload.end)
16893
16904
  .subtract(1, "days")
16894
16905
  .toDate();
16895
16906
  break;
16896
16907
  case "10 days":
16897
- state.timeScopeStart = moment$8(payload.end)
16908
+ state.timeScopeStart = moment$f(payload.end)
16898
16909
  .subtract(10, "days")
16899
16910
  .toDate();
16900
16911
  break;
@@ -18628,7 +18639,7 @@ var Header = React__default.memo(function (_a) {
18628
18639
  var handleDateChange = function (newValue, key) {
18629
18640
  var _a;
18630
18641
  //@ts-ignore
18631
- actions.setTotalScope((_a = {}, _a[key] = moment$8(newValue).toDate(), _a));
18642
+ actions.setTotalScope((_a = {}, _a[key] = moment$f(newValue).toDate(), _a));
18632
18643
  };
18633
18644
  var handleChangeScope = function (value) {
18634
18645
  actions.setTotalScope({
@@ -18667,7 +18678,7 @@ var Header = React__default.memo(function (_a) {
18667
18678
  } },
18668
18679
  React__default.createElement(ChevronLeft, { fontSize: "medium" }))),
18669
18680
  React__default.createElement(Grid2, { size: { md: 4 } },
18670
- React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$8(state.timeScopeStart), onChange: function (newValue) {
18681
+ React__default.createElement(DateTimePicker, { label: "Start", format: "MM/DD/YYYY HH:mm:ss", value: moment$f(state.timeScopeStart), onChange: function (newValue) {
18671
18682
  if (newValue) {
18672
18683
  handleDateChange(newValue.toDate(), "start");
18673
18684
  }
@@ -18691,7 +18702,7 @@ var Header = React__default.memo(function (_a) {
18691
18702
  React__default.createElement(MenuItem, { value: "10 days" }, "10 days"),
18692
18703
  React__default.createElement(MenuItem, { value: "custom" }, "Custom")))),
18693
18704
  React__default.createElement(Grid2, { size: { md: 4 } },
18694
- React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$8(state.timeScopeEnd), onChange: function (newValue) {
18705
+ React__default.createElement(DateTimePicker, { label: "End", format: "MM/DD/YYYY HH:mm:ss", value: autoRefresh ? null : moment$f(state.timeScopeEnd), onChange: function (newValue) {
18695
18706
  if (newValue) {
18696
18707
  handleDateChange(newValue.toDate(), "end");
18697
18708
  }
@@ -19376,7 +19387,7 @@ var ProvidersLoader = function (_a) {
19376
19387
  };
19377
19388
 
19378
19389
  var timezone = TimeService.getInstance().getServerTimeZone();
19379
- moment$9.tz.setDefault(timezone);
19390
+ moment$g.tz.setDefault(timezone);
19380
19391
  var base = document.getElementsByTagName("base")[0].getAttribute("href") || "/";
19381
19392
  var queryClient = new QueryClient({
19382
19393
  defaultOptions: {
@@ -19396,7 +19407,7 @@ function MESFMain(_a) {
19396
19407
  React__default.createElement(HelmetDexteelProvider, { navbarTitle: navbarTitle },
19397
19408
  React__default.createElement(QueryClientProvider, { client: queryClient },
19398
19409
  React__default.createElement(AuthProvider, { authConfig: authentication },
19399
- React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment, dateLibInstance: moment$9 },
19410
+ React__default.createElement(LocalizationProvider, { dateAdapter: AdapterMoment, dateLibInstance: moment$g },
19400
19411
  React__default.createElement(UserProvider, null,
19401
19412
  React__default.createElement(UTLSettingsProvider, null,
19402
19413
  React__default.createElement(ProvidersLoader, null,
@@ -19424,7 +19435,7 @@ var CustomStatusPanel = function (_a) {
19424
19435
  React__default.createElement(PlaylistAddIcon, { style: { width: 30, height: 30 } })));
19425
19436
  };
19426
19437
 
19427
- var useGridDefinitions = function (_a) {
19438
+ var useGridDefinitions$1 = function (_a) {
19428
19439
  _a.OnEdit; _a.OnSend;
19429
19440
  var defaultColDef = {
19430
19441
  flex: 1,
@@ -19448,8 +19459,8 @@ var useGridDefinitions = function (_a) {
19448
19459
  };
19449
19460
  };
19450
19461
 
19451
- var moment$7 = getMomentTz();
19452
- var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
19462
+ var moment$e = getMomentTz();
19463
+ var getEntries$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
19453
19464
  var apiService, parameters, resp, rows;
19454
19465
  var shiftId = _b.shiftId, assetId = _b.assetId, signal = _b.signal;
19455
19466
  return __generator(this, function (_c) {
@@ -19468,9 +19479,9 @@ var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function
19468
19479
  if (resp.ok) {
19469
19480
  rows = get(resp, "data.tables[0].rows", []);
19470
19481
  rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
19471
- ? moment$7.utc(entry["CreateTimestamp"]).toDate()
19482
+ ? moment$e.utc(entry["CreateTimestamp"]).toDate()
19472
19483
  : null, UpdateTimestamp: entry.UpdateTimestamp
19473
- ? moment$7.utc(entry["UpdateTimestamp"]).toDate()
19484
+ ? moment$e.utc(entry["UpdateTimestamp"]).toDate()
19474
19485
  : null })); });
19475
19486
  return [2 /*return*/, rows];
19476
19487
  }
@@ -19480,7 +19491,7 @@ var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function
19480
19491
  }
19481
19492
  });
19482
19493
  }); };
19483
- var upsertEntry = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
19494
+ var upsertEntry$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
19484
19495
  var apiService, parameters, resp;
19485
19496
  var assetId = _b.assetId, entryId = _b.entryId, shiftId = _b.shiftId, title = _b.title, content = _b.content, createTimestamp = _b.createTimestamp, author = _b.author;
19486
19497
  return __generator(this, function (_c) {
@@ -19517,7 +19528,7 @@ var upsertEntry = function (_a) { return __awaiter(void 0, [_a], void 0, functio
19517
19528
  }
19518
19529
  });
19519
19530
  }); };
19520
- var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0, function () {
19531
+ var deleteEntry$1 = function (EntryId) { return __awaiter(void 0, void 0, void 0, function () {
19521
19532
  var apiService, attachmentsToDelete, error_1, parameters, resp;
19522
19533
  return __generator(this, function (_a) {
19523
19534
  switch (_a.label) {
@@ -19528,7 +19539,7 @@ var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0,
19528
19539
  case 1:
19529
19540
  _a.trys.push([1, 4, , 5]);
19530
19541
  if (!EntryId) return [3 /*break*/, 3];
19531
- return [4 /*yield*/, getEntryAttachments(EntryId)];
19542
+ return [4 /*yield*/, getEntryAttachments$1(EntryId)];
19532
19543
  case 2:
19533
19544
  attachmentsToDelete = _a.sent();
19534
19545
  _a.label = 3;
@@ -19548,13 +19559,13 @@ var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0,
19548
19559
  }
19549
19560
  // Delete associated files in background (don't block the UI)
19550
19561
  if (attachmentsToDelete.length > 0) {
19551
- deleteAttachedFilesInBackground(attachmentsToDelete);
19562
+ deleteAttachedFilesInBackground$1(attachmentsToDelete);
19552
19563
  }
19553
19564
  return [2 /*return*/];
19554
19565
  }
19555
19566
  });
19556
19567
  }); };
19557
- var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(void 0, void 0, void 0, function () {
19568
+ var deleteAttachedFilesInBackground$1 = function (attachments) { return __awaiter(void 0, void 0, void 0, function () {
19558
19569
  return __generator(this, function (_a) {
19559
19570
  // Delete files in background without blocking the UI
19560
19571
  Promise.all(attachments.map(function (attachment) { return __awaiter(void 0, void 0, void 0, function () {
@@ -19563,7 +19574,7 @@ var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(
19563
19574
  switch (_a.label) {
19564
19575
  case 0:
19565
19576
  _a.trys.push([0, 2, , 3]);
19566
- return [4 /*yield*/, deleteUploadFile(attachment.UploadFileId)];
19577
+ return [4 /*yield*/, deleteUploadFile$1(attachment.UploadFileId)];
19567
19578
  case 1:
19568
19579
  _a.sent();
19569
19580
  return [3 /*break*/, 3];
@@ -19581,7 +19592,7 @@ var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(
19581
19592
  return [2 /*return*/];
19582
19593
  });
19583
19594
  }); };
19584
- var deleteUploadFile = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
19595
+ var deleteUploadFile$1 = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
19585
19596
  var apiService, parameters, resp;
19586
19597
  return __generator(this, function (_a) {
19587
19598
  switch (_a.label) {
@@ -19601,7 +19612,7 @@ var deleteUploadFile = function (uploadFileId) { return __awaiter(void 0, void 0
19601
19612
  });
19602
19613
  }); };
19603
19614
  // Attachment management functions
19604
- var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0, void 0, function () {
19615
+ var getEntryAttachments$1 = function (entryId) { return __awaiter(void 0, void 0, void 0, function () {
19605
19616
  var apiService, parameters, resp, rows;
19606
19617
  return __generator(this, function (_a) {
19607
19618
  switch (_a.label) {
@@ -19614,7 +19625,7 @@ var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0,
19614
19625
  if (resp.ok) {
19615
19626
  rows = get(resp, "data.tables[0].rows", []);
19616
19627
  rows = rows.map(function (attachment) { return (__assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
19617
- ? moment$7.utc(attachment.CreationTime).toDate()
19628
+ ? moment$e.utc(attachment.CreationTime).toDate()
19618
19629
  : new Date() })); });
19619
19630
  return [2 /*return*/, rows];
19620
19631
  }
@@ -19624,7 +19635,7 @@ var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0,
19624
19635
  }
19625
19636
  });
19626
19637
  }); };
19627
- var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
19638
+ var upsertEntryAttachment$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
19628
19639
  var apiService, parameters, resp, attachment;
19629
19640
  var entryId = _b.entryId, uploadFileId = _b.uploadFileId, attachmentName = _b.attachmentName, attachmentURL = _b.attachmentURL;
19630
19641
  return __generator(this, function (_c) {
@@ -19644,7 +19655,7 @@ var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void
19644
19655
  attachment = get(resp, "data.tables[0].rows[0]", null);
19645
19656
  if (attachment) {
19646
19657
  return [2 /*return*/, __assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
19647
- ? moment$7.utc(attachment.CreationTime).toDate()
19658
+ ? moment$e.utc(attachment.CreationTime).toDate()
19648
19659
  : new Date() })];
19649
19660
  }
19650
19661
  return [2 /*return*/, null];
@@ -19655,7 +19666,7 @@ var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void
19655
19666
  }
19656
19667
  });
19657
19668
  }); };
19658
- var deleteEntryAttachment = function (entryAttachmentId, uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
19669
+ var deleteEntryAttachment$1 = function (entryAttachmentId, uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
19659
19670
  var apiService, parameters, resp;
19660
19671
  return __generator(this, function (_a) {
19661
19672
  switch (_a.label) {
@@ -19672,19 +19683,19 @@ var deleteEntryAttachment = function (entryAttachmentId, uploadFileId) { return
19672
19683
  }
19673
19684
  // Delete the associated file in background if UploadFileId was provided
19674
19685
  if (uploadFileId) {
19675
- deleteUploadFileInBackground(uploadFileId);
19686
+ deleteUploadFileInBackground$1(uploadFileId);
19676
19687
  }
19677
19688
  return [2 /*return*/];
19678
19689
  }
19679
19690
  });
19680
19691
  }); };
19681
- var deleteUploadFileInBackground = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
19692
+ var deleteUploadFileInBackground$1 = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
19682
19693
  var error_3;
19683
19694
  return __generator(this, function (_a) {
19684
19695
  switch (_a.label) {
19685
19696
  case 0:
19686
19697
  _a.trys.push([0, 2, , 3]);
19687
- return [4 /*yield*/, deleteUploadFile(uploadFileId)];
19698
+ return [4 /*yield*/, deleteUploadFile$1(uploadFileId)];
19688
19699
  case 1:
19689
19700
  _a.sent();
19690
19701
  return [3 /*break*/, 3];
@@ -19698,19 +19709,19 @@ var deleteUploadFileInBackground = function (uploadFileId) { return __awaiter(vo
19698
19709
  });
19699
19710
  }); };
19700
19711
 
19701
- var useEntries = function (_a) {
19712
+ var useEntries$1 = function (_a) {
19702
19713
  var shiftId = _a.shiftId, assetId = _a.assetId;
19703
19714
  return useQuery({
19704
19715
  queryKey: ["entries", shiftId, assetId],
19705
19716
  queryFn: function (_a) {
19706
19717
  var signal = _a.signal;
19707
- return getEntries({ shiftId: shiftId, assetId: assetId, signal: signal });
19718
+ return getEntries$1({ shiftId: shiftId, assetId: assetId, signal: signal });
19708
19719
  },
19709
19720
  });
19710
19721
  };
19711
- var routeLogbookEntry = "/logbook/entry";
19722
+ var routeLogbookEntry$1 = "/logbook/entry";
19712
19723
 
19713
- var useLogbookEntryOptionsFunctions = function (_a) {
19724
+ var useLogbookEntryOptionsFunctions$1 = function (_a) {
19714
19725
  var setSelectedRowData = _a.setSelectedRowData, setShow = _a.setShow, setShowRemoveDialog = _a.setShowRemoveDialog, handleNewEntry = _a.handleNewEntry;
19715
19726
  var getMenuOptions = function (data) {
19716
19727
  var options = [];
@@ -19756,7 +19767,7 @@ var useLogbookEntryOptionsFunctions = function (_a) {
19756
19767
  };
19757
19768
  };
19758
19769
 
19759
- var useTableData$1 = function (_a) {
19770
+ var useTableData$3 = function (_a) {
19760
19771
  var showContextMenu = _a.showContextMenu, allowAttachments = _a.allowAttachments, withAssetFilter = _a.withAssetFilter, showShiftCrew = _a.showShiftCrew;
19761
19772
  var columnDefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
19762
19773
  {
@@ -19872,7 +19883,7 @@ var useTableData$1 = function (_a) {
19872
19883
  return { columnDefs: columnDefs };
19873
19884
  };
19874
19885
 
19875
- var ENTRY_INITIAL_VALUES = {
19886
+ var ENTRY_INITIAL_VALUES$1 = {
19876
19887
  EntryId: 0,
19877
19888
  ShiftId: 0,
19878
19889
  AssetId: null,
@@ -19888,7 +19899,7 @@ var ENTRY_INITIAL_VALUES = {
19888
19899
  AttachmentCount: 0,
19889
19900
  };
19890
19901
 
19891
- var RemoveEntryDialog = function (_a) {
19902
+ var RemoveEntryDialog$1 = function (_a) {
19892
19903
  var entry = _a.entry, show = _a.show, onHide = _a.onHide;
19893
19904
  var navigate = useNavigate();
19894
19905
  var _b = useState(false), isSubmitLoading = _b[0], setIsSubmitLoading = _b[1];
@@ -19899,14 +19910,14 @@ var RemoveEntryDialog = function (_a) {
19899
19910
  onHide(false);
19900
19911
  };
19901
19912
  var queryClient = useQueryClient();
19902
- var removeEntry = useMutation(deleteEntry, {
19913
+ var removeEntry = useMutation(deleteEntry$1, {
19903
19914
  onSuccess: function () { return __awaiter(void 0, void 0, void 0, function () {
19904
19915
  return __generator(this, function (_a) {
19905
19916
  switch (_a.label) {
19906
19917
  case 0: return [4 /*yield*/, queryClient.invalidateQueries({ queryKey: ["entries"] })];
19907
19918
  case 1:
19908
19919
  _a.sent();
19909
- navigate("".concat(routeLogbookEntry), { replace: true });
19920
+ navigate("".concat(routeLogbookEntry$1), { replace: true });
19910
19921
  setSuccessMessage("The entry was deleted succesfully");
19911
19922
  onHide(true);
19912
19923
  return [2 /*return*/];
@@ -19989,7 +20000,7 @@ var AssetsFilter = function (_a) {
19989
20000
  React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
19990
20001
  };
19991
20002
 
19992
- var moment$6 = getMomentTz();
20003
+ var moment$d = getMomentTz();
19993
20004
  var getShifts = function (shiftId) { return __awaiter(void 0, void 0, void 0, function () {
19994
20005
  var apiService, parameters, resp, rows;
19995
20006
  return __generator(this, function (_a) {
@@ -20008,26 +20019,26 @@ var getShifts = function (shiftId) { return __awaiter(void 0, void 0, void 0, fu
20008
20019
  if (resp.ok) {
20009
20020
  rows = get(resp, "data.tables[0].rows", []);
20010
20021
  rows = rows.map(function (row) {
20011
- (row.CurrentProductionDate = moment$6
20022
+ (row.CurrentProductionDate = moment$d
20012
20023
  .utc(row["CurrentProductionDate"])
20013
20024
  .toDate()),
20014
- (row.CurrentStart = moment$6.utc(row["CurrentStart"]).toDate()),
20015
- (row.CurrentEnd = moment$6.utc(row["CurrentEnd"]).toDate()),
20016
- (row.PreviousProductionDate = moment$6
20025
+ (row.CurrentStart = moment$d.utc(row["CurrentStart"]).toDate()),
20026
+ (row.CurrentEnd = moment$d.utc(row["CurrentEnd"]).toDate()),
20027
+ (row.PreviousProductionDate = moment$d
20017
20028
  .utc(row["PreviousProductionDate"])
20018
20029
  .toDate()),
20019
- (row.PreviousStart = moment$6.utc(row["PreviousStart"]).toDate()),
20020
- (row.PreviousEnd = moment$6.utc(row["PreviousEnd"]).toDate()),
20021
- (row.NextProductionDate = moment$6
20030
+ (row.PreviousStart = moment$d.utc(row["PreviousStart"]).toDate()),
20031
+ (row.PreviousEnd = moment$d.utc(row["PreviousEnd"]).toDate()),
20032
+ (row.NextProductionDate = moment$d
20022
20033
  .utc(row["NextProductionDate"])
20023
20034
  .toDate()),
20024
- (row.NextStart = moment$6.utc(row["NextStart"]).toDate()),
20025
- (row.NextEnd = moment$6.utc(row["NextEnd"]).toDate()),
20026
- (row.LastProductionDate = moment$6
20035
+ (row.NextStart = moment$d.utc(row["NextStart"]).toDate()),
20036
+ (row.NextEnd = moment$d.utc(row["NextEnd"]).toDate()),
20037
+ (row.LastProductionDate = moment$d
20027
20038
  .utc(row["LastProductionDate"])
20028
20039
  .toDate()),
20029
- (row.LastStart = moment$6.utc(row["LastStart"]).toDate()),
20030
- (row.LastEnd = moment$6.utc(row["LastEnd"]).toDate());
20040
+ (row.LastStart = moment$d.utc(row["LastStart"]).toDate()),
20041
+ (row.LastEnd = moment$d.utc(row["LastEnd"]).toDate());
20031
20042
  return row;
20032
20043
  });
20033
20044
  return [2 /*return*/, rows];
@@ -20056,7 +20067,7 @@ var getShiftsAroundCurrent = function (_a) { return __awaiter(void 0, [_a], void
20056
20067
  resp = _c.sent();
20057
20068
  if (resp.ok) {
20058
20069
  rows = get(resp, "data.tables[0].rows", []);
20059
- rows = rows.map(function (row) { return (__assign(__assign({}, row), { Start: moment$6.utc(row.Start).toDate(), End: moment$6.utc(row.End).toDate() })); });
20070
+ rows = rows.map(function (row) { return (__assign(__assign({}, row), { Start: moment$d.utc(row.Start).toDate(), End: moment$d.utc(row.End).toDate() })); });
20060
20071
  return [2 /*return*/, rows];
20061
20072
  }
20062
20073
  else {
@@ -20066,7 +20077,7 @@ var getShiftsAroundCurrent = function (_a) { return __awaiter(void 0, [_a], void
20066
20077
  });
20067
20078
  }); };
20068
20079
 
20069
- var moment$5 = getMomentTz();
20080
+ var moment$c = getMomentTz();
20070
20081
  var useShiftsAroundCurrent = function (_a) {
20071
20082
  var currentShiftId = _a.currentShiftId, shiftsRange = _a.shiftsRange;
20072
20083
  return useQuery({
@@ -20094,7 +20105,7 @@ var ShiftAutocomplete = function (_a) {
20094
20105
  React__default.createElement(Grid2, { container: true },
20095
20106
  React__default.createElement(Grid2, { size: { xs: 12 } },
20096
20107
  React__default.createElement(Autocomplete, { loading: isLoading, options: rows || [], getOptionLabel: function (option) {
20097
- return "".concat(moment$5
20108
+ return "".concat(moment$c
20098
20109
  .utc(option.ProductionDate)
20099
20110
  .format("MM/DD/YYYY"), " - ").concat(option.Shift, " - ").concat(option.Crew);
20100
20111
  }, value: selectedShift, onChange: function (event, newValue) {
@@ -20131,12 +20142,12 @@ var ShiftSelector = function (_a) {
20131
20142
  React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); }, title: "Error loading shifts" })));
20132
20143
  };
20133
20144
 
20134
- var useEntrySubmission = function (_a) {
20145
+ var useEntrySubmission$1 = function (_a) {
20135
20146
  var _b = _a === void 0 ? {} : _a, onSuccess = _b.onSuccess, onError = _b.onError, _c = _b.isNewEntry, isNewEntry = _c === void 0 ? false : _c, _d = _b.onHide, onHide = _d === void 0 ? function () { } : _d;
20136
20147
  var _e = useState(false), isSubmitLoading = _e[0], setIsSubmitLoading = _e[1];
20137
20148
  var _f = useState(false), showConfirmationDialog = _f[0], setShowConfirmationDialog = _f[1];
20138
20149
  var _g = useState(null), pendingSubmitData = _g[0], setPendingSubmitData = _g[1];
20139
- var submit = useMutation(upsertEntry, {
20150
+ var submit = useMutation(upsertEntry$1, {
20140
20151
  onSuccess: function (entry) { return __awaiter(void 0, void 0, void 0, function () {
20141
20152
  return __generator(this, function (_a) {
20142
20153
  if (entry && entry.EntryId) {
@@ -20213,7 +20224,7 @@ var useEntrySubmission = function (_a) {
20213
20224
  };
20214
20225
  };
20215
20226
 
20216
- var DeleteAttachmentConfirmationDialog = function (_a) {
20227
+ var DeleteAttachmentConfirmationDialog$1 = function (_a) {
20217
20228
  var open = _a.open, attachmentName = _a.attachmentName, onClose = _a.onClose, _b = _a.isDeleting, isDeleting = _b === void 0 ? false : _b;
20218
20229
  var _c = useState(false), isClosing = _c[0], setIsClosing = _c[1];
20219
20230
  var handleCancel = function () {
@@ -20239,7 +20250,7 @@ var DeleteAttachmentConfirmationDialog = function (_a) {
20239
20250
  React__default.createElement(Button, { onClick: handleConfirm, color: "secondary", variant: "contained", disabled: isClosing, startIcon: isDeleting && React__default.createElement(CircularProgress, { size: "1rem" }) }, "Delete"))));
20240
20251
  };
20241
20252
 
20242
- var AttachmentModal = function (_a) {
20253
+ var AttachmentModal$1 = function (_a) {
20243
20254
  var open = _a.open, onClose = _a.onClose, entryId = _a.entryId, isEditing = _a.isEditing, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted;
20244
20255
  var queryClient = useQueryClient();
20245
20256
  var api = new MESApiService();
@@ -20251,7 +20262,7 @@ var AttachmentModal = function (_a) {
20251
20262
  var _g = useState(null), attachmentToDelete = _g[0], setAttachmentToDelete = _g[1];
20252
20263
  var pendingFilesRef = useRef([]);
20253
20264
  // Entry submission hook for background saves
20254
- var _h = useEntrySubmission({
20265
+ var _h = useEntrySubmission$1({
20255
20266
  onSuccess: function (entry) {
20256
20267
  setIsSubmittingEntry(false);
20257
20268
  if (entry === null || entry === void 0 ? void 0 : entry.EntryId) {
@@ -20280,11 +20291,11 @@ var AttachmentModal = function (_a) {
20280
20291
  // Query for fetching attachments
20281
20292
  var _j = useQuery({
20282
20293
  queryKey: ["entryAttachments", currentEntryId],
20283
- queryFn: function () { return getEntryAttachments(currentEntryId); },
20294
+ queryFn: function () { return getEntryAttachments$1(currentEntryId); },
20284
20295
  enabled: !!currentEntryId && currentEntryId > 0,
20285
20296
  }), _k = _j.data, attachments = _k === void 0 ? [] : _k, isLoading = _j.isLoading, fetchError = _j.error;
20286
20297
  // Mutations
20287
- var uploadMutation = useMutation(upsertEntryAttachment, {
20298
+ var uploadMutation = useMutation(upsertEntryAttachment$1, {
20288
20299
  onSuccess: function () {
20289
20300
  queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
20290
20301
  queryClient.invalidateQueries(["entries"]);
@@ -20296,7 +20307,7 @@ var AttachmentModal = function (_a) {
20296
20307
  });
20297
20308
  var deleteMutation = useMutation(function (_a) {
20298
20309
  var entryAttachmentId = _a.entryAttachmentId, uploadFileId = _a.uploadFileId;
20299
- return deleteEntryAttachment(entryAttachmentId, uploadFileId);
20310
+ return deleteEntryAttachment$1(entryAttachmentId, uploadFileId);
20300
20311
  }, {
20301
20312
  onSuccess: function () {
20302
20313
  queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
@@ -20568,11 +20579,11 @@ var AttachmentModal = function (_a) {
20568
20579
  " file(s)...")))),
20569
20580
  React__default.createElement(DialogActions$1, null,
20570
20581
  React__default.createElement(Button, { onClick: onClose, color: "primary" }, "Close"))),
20571
- React__default.createElement(DeleteAttachmentConfirmationDialog, { open: showDeleteConfirmation, attachmentName: (attachmentToDelete === null || attachmentToDelete === void 0 ? void 0 : attachmentToDelete.name) || "", onClose: handleDeleteConfirmation, isDeleting: deleteMutation.isLoading }),
20582
+ React__default.createElement(DeleteAttachmentConfirmationDialog$1, { open: showDeleteConfirmation, attachmentName: (attachmentToDelete === null || attachmentToDelete === void 0 ? void 0 : attachmentToDelete.name) || "", onClose: handleDeleteConfirmation, isDeleting: deleteMutation.isLoading }),
20572
20583
  React__default.createElement(ErrorModal, { error: error || (fetchError === null || fetchError === void 0 ? void 0 : fetchError.message), onHide: function () { return setError(null); } })));
20573
20584
  };
20574
20585
 
20575
- var AttachmentPlugin = /** @class */ (function (_super) {
20586
+ var AttachmentPlugin$1 = /** @class */ (function (_super) {
20576
20587
  __extends(AttachmentPlugin, _super);
20577
20588
  function AttachmentPlugin() {
20578
20589
  return _super !== null && _super.apply(this, arguments) || this;
@@ -20619,7 +20630,7 @@ var AttachmentPlugin = /** @class */ (function (_super) {
20619
20630
  return AttachmentPlugin;
20620
20631
  }(PluginComponent));
20621
20632
 
20622
- var ContentInput = function (_a) {
20633
+ var ContentInput$1 = function (_a) {
20623
20634
  var value = _a.value, onChange = _a.onChange, isEditing = _a.isEditing, UpdateTimestamp = _a.UpdateTimestamp, UpdatedBy = _a.UpdatedBy, isNewEntry = _a.isNewEntry, entryId = _a.entryId, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted, _b = _a.allowAttachments, allowAttachments = _b === void 0 ? false : _b;
20624
20635
  var mdParser = new MarkdownIt();
20625
20636
  var api = new MESApiService();
@@ -20633,7 +20644,7 @@ var ContentInput = function (_a) {
20633
20644
  // Query for fetching attachment count
20634
20645
  var _f = useQuery({
20635
20646
  queryKey: ["entryAttachments", effectiveEntryId],
20636
- queryFn: function () { return getEntryAttachments(effectiveEntryId); },
20647
+ queryFn: function () { return getEntryAttachments$1(effectiveEntryId); },
20637
20648
  enabled: !!effectiveEntryId && effectiveEntryId > 0,
20638
20649
  retry: 1,
20639
20650
  onError: function (err) {
@@ -20673,7 +20684,7 @@ var ContentInput = function (_a) {
20673
20684
  }, [isEditing, attachmentCount]);
20674
20685
  // Register the attachment plugin
20675
20686
  useEffect(function () {
20676
- MdEditor.use(AttachmentPlugin, {
20687
+ MdEditor.use(AttachmentPlugin$1, {
20677
20688
  attachmentCount: attachmentCount,
20678
20689
  onAttachmentClick: function () {
20679
20690
  if (entryData.title && entryData.author) {
@@ -20791,12 +20802,12 @@ var ContentInput = function (_a) {
20791
20802
  fontSize: "0.7rem",
20792
20803
  },
20793
20804
  } })))),
20794
- React__default.createElement(AttachmentModal, { open: attachmentModalOpen, onClose: function () { return setAttachmentModalOpen(false); }, entryId: effectiveEntryId, isEditing: isEditing, entryData: entryData, onEntrySubmitted: onEntrySubmitted }),
20805
+ React__default.createElement(AttachmentModal$1, { open: attachmentModalOpen, onClose: function () { return setAttachmentModalOpen(false); }, entryId: effectiveEntryId, isEditing: isEditing, entryData: entryData, onEntrySubmitted: onEntrySubmitted }),
20795
20806
  React__default.createElement(ErrorModal, { error: error || (attachmentError === null || attachmentError === void 0 ? void 0 : attachmentError.message), onHide: function () { return setError(""); } })));
20796
20807
  };
20797
20808
 
20798
- var moment$4 = getMomentTz();
20799
- var EntryViewer$1 = function (_a) {
20809
+ var moment$b = getMomentTz();
20810
+ var EntryViewer$3 = function (_a) {
20800
20811
  var entry = _a.entry, show = _a.show, onChangeShow = _a.onChangeShow, onHide = _a.onHide, preselectedAssetId = _a.preselectedAssetId, withAssetFilter = _a.withAssetFilter, canEditAsset = _a.canEditAsset, canEditShift = _a.canEditShift, filterAssets = _a.filterAssets, allowAttachments = _a.allowAttachments, shiftsRange = _a.shiftsRange;
20801
20812
  var settings = useUTLSettingsContext().state.settings;
20802
20813
  var defaultAssetId = Number(get(settings, "DefaultAssetId", 15));
@@ -20835,7 +20846,7 @@ var EntryViewer$1 = function (_a) {
20835
20846
  }, 1000); // 1000ms delay to ensure all processing is complete
20836
20847
  };
20837
20848
  // Use the shared entry submission hook
20838
- var _g = useEntrySubmission({
20849
+ var _g = useEntrySubmission$1({
20839
20850
  onSuccess: function (entry) {
20840
20851
  setNotificationMessage(entryId === "new"
20841
20852
  ? "Entry created successfully"
@@ -20887,8 +20898,8 @@ var EntryViewer$1 = function (_a) {
20887
20898
  useEffect(function () {
20888
20899
  var _a, _b, _c;
20889
20900
  if (shiftInfo || !isNewEntry) {
20890
- var newEntry = __assign(__assign({}, ENTRY_INITIAL_VALUES), { ShiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, Shift: (_a = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShift) !== null && _a !== void 0 ? _a : "", Crew: (_b = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentCrew) !== null && _b !== void 0 ? _b : "", CreateTimestamp: new Date(), AssetId: (_c = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _c !== void 0 ? _c : null });
20891
- reset((isNewEntry ? newEntry : entry) || ENTRY_INITIAL_VALUES);
20901
+ var newEntry = __assign(__assign({}, ENTRY_INITIAL_VALUES$1), { ShiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, Shift: (_a = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShift) !== null && _a !== void 0 ? _a : "", Crew: (_b = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentCrew) !== null && _b !== void 0 ? _b : "", CreateTimestamp: new Date(), AssetId: (_c = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _c !== void 0 ? _c : null });
20902
+ reset((isNewEntry ? newEntry : entry) || ENTRY_INITIAL_VALUES$1);
20892
20903
  }
20893
20904
  }, [entry, shiftInfo, entryId, reset, defaultAssetId]);
20894
20905
  useEffect(function () {
@@ -20920,7 +20931,7 @@ var EntryViewer$1 = function (_a) {
20920
20931
  React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
20921
20932
  React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
20922
20933
  var value = _a.field.value;
20923
- return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$4(value) : null, disabled: true, slotProps: {
20934
+ return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$b(value) : null, disabled: true, slotProps: {
20924
20935
  textField: {
20925
20936
  variant: "outlined",
20926
20937
  size: "small",
@@ -20981,7 +20992,7 @@ var EntryViewer$1 = function (_a) {
20981
20992
  React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
20982
20993
  React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
20983
20994
  var _b = _a.field, value = _b.value, onChange = _b.onChange;
20984
- return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return onChange(val); }, value: value, isEditing: show === "edit", isNewEntry: isNewEntry, entryId: entryIdValue, entryData: {
20995
+ return (React__default.createElement(ContentInput$1, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return onChange(val); }, value: value, isEditing: show === "edit", isNewEntry: isNewEntry, entryId: entryIdValue, entryData: {
20985
20996
  assetId: assetId,
20986
20997
  entryId: entryIdValue,
20987
20998
  shiftId: shiftId,
@@ -21003,11 +21014,11 @@ var EntryViewer$1 = function (_a) {
21003
21014
  React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
21004
21015
  React__default.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React__default.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading || !isFormDirty, variant: "contained", color: "primary", type: "submit" }, isNewEntry ? "Create" : "Save"))))))) : null,
21005
21016
  React__default.createElement(NotificationSnackBar, { message: notificationMessage, onHide: function () { return setNotificationMessage(""); } }),
21006
- React__default.createElement(ConfirmationDialogRaw, { open: showConfirmationDialog, onClose: handleConfirmationClose, title: "Shift Submission Confirmation", message: "You are about to ".concat(isNewEntry ? "create" : "save", " an entry for ").concat(moment$4(shiftTimestamp).format("MM/DD/YYYY"), " ").concat(shift, " - ").concat(crew, ". Are you sure you want to proceed?"), suffixTitle: "Logbook Entry" }),
21017
+ React__default.createElement(ConfirmationDialogRaw, { open: showConfirmationDialog, onClose: handleConfirmationClose, title: "Shift Submission Confirmation", message: "You are about to ".concat(isNewEntry ? "create" : "save", " an entry for ").concat(moment$b(shiftTimestamp).format("MM/DD/YYYY"), " ").concat(shift, " - ").concat(crew, ". Are you sure you want to proceed?"), suffixTitle: "Logbook Entry" }),
21007
21018
  React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
21008
21019
  };
21009
21020
 
21010
- var Filters$1 = function (_a) {
21021
+ var Filters$3 = function (_a) {
21011
21022
  var withAssetFilter = _a.withAssetFilter, filterAssets = _a.filterAssets, assetId = _a.assetId, _b = _a.setAssetId, setAssetId = _b === void 0 ? function () { } : _b, quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange;
21012
21023
  useMesfRealtime({
21013
21024
  onReceiveMessage: function (author, message) {
@@ -21035,8 +21046,10 @@ var Filters$1 = function (_a) {
21035
21046
  } }))));
21036
21047
  };
21037
21048
 
21038
- var moment$3 = getMomentTz();
21039
- var Logbook$1 = function () {
21049
+ var moment$a = getMomentTz();
21050
+ // Default layout matching original Grid md:5 / md:7 ratio (41.67% / 58.33%)
21051
+ var DEFAULT_LAYOUT$3 = { left: 42, right: 58 };
21052
+ var Logbook$3 = function () {
21040
21053
  var entry = useLogbookSettings().entry;
21041
21054
  var defaultAreaId = useUserContext().state.defaultAreaId;
21042
21055
  var withAssetFilter = entry.withAssetFilter;
@@ -21065,17 +21078,24 @@ var Logbook$1 = function () {
21065
21078
  var _f = useState(null), selectedRowData = _f[0], setSelectedRowData = _f[1];
21066
21079
  var _g = useState(false), showRemoveDialog = _g[0], setShowRemoveDialog = _g[1];
21067
21080
  var _h = useContextMenuMESF(), registerConfig = _h.registerConfig, showContextMenu = _h.showContextMenu;
21068
- var _j = useEntries({
21081
+ // Resizable panels layout persistence
21082
+ var _j = useDefaultLayout({
21083
+ id: "logbook-entry-v2",
21084
+ storage: localStorage,
21085
+ }), savedLayout = _j.defaultLayout, onLayoutChange = _j.onLayoutChange;
21086
+ // Use saved layout or default to avoid flash on initial render
21087
+ var resolvedLayout = savedLayout !== null && savedLayout !== void 0 ? savedLayout : DEFAULT_LAYOUT$3;
21088
+ var _k = useEntries$1({
21069
21089
  shiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId,
21070
21090
  assetId: withAssetFilter ? assetId : undefined,
21071
- }), rows = _j.data, isLoading = _j.isLoading, e = _j.error, isError = _j.isError, refetch = _j.refetch;
21072
- var columnDefs = useTableData$1({
21091
+ }), rows = _k.data, isLoading = _k.isLoading, e = _k.error, isError = _k.isError, refetch = _k.refetch;
21092
+ var columnDefs = useTableData$3({
21073
21093
  showContextMenu: showContextMenu,
21074
21094
  allowAttachments: allowAttachments,
21075
21095
  withAssetFilter: withAssetFilter,
21076
21096
  showShiftCrew: showShiftCrew,
21077
21097
  }).columnDefs;
21078
- var defaultColDef = useGridDefinitions({}).defaultColDef;
21098
+ var defaultColDef = useGridDefinitions$1({}).defaultColDef;
21079
21099
  var onQuickFilterChange = function (text) {
21080
21100
  var _a;
21081
21101
  setQuickFilter(text);
@@ -21084,8 +21104,8 @@ var Logbook$1 = function () {
21084
21104
  var handleNewEntry = function () {
21085
21105
  var _a;
21086
21106
  (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
21087
- setSelectedRowData(__assign({}, ENTRY_INITIAL_VALUES));
21088
- navigate("".concat(routeLogbookEntry, "/").concat(shiftIdRef.current, "?action=new"), {
21107
+ setSelectedRowData(__assign({}, ENTRY_INITIAL_VALUES$1));
21108
+ navigate("".concat(routeLogbookEntry$1, "/").concat(shiftIdRef.current, "?action=new"), {
21089
21109
  replace: true,
21090
21110
  });
21091
21111
  setShow("edit");
@@ -21094,7 +21114,7 @@ var Logbook$1 = function () {
21094
21114
  var _a;
21095
21115
  var currentShiftId = shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId);
21096
21116
  setSelectedRowData(event === null || event === void 0 ? void 0 : event.data);
21097
- navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "?entryId=").concat((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.EntryId, "&action=view"));
21117
+ navigate("".concat(routeLogbookEntry$1, "/").concat(currentShiftId, "?entryId=").concat((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.EntryId, "&action=view"));
21098
21118
  setShow("view");
21099
21119
  };
21100
21120
  var onCellKeyDown = useCallback(function (event) {
@@ -21112,7 +21132,7 @@ var Logbook$1 = function () {
21112
21132
  nextNode.setSelected(true);
21113
21133
  api.ensureIndexVisible(nextRowIndex);
21114
21134
  setSelectedRowData(nextNode.data);
21115
- navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "/?entryId=").concat(nextNode.data.EntryId, "&action=view"));
21135
+ navigate("".concat(routeLogbookEntry$1, "/").concat(currentShiftId, "/?entryId=").concat(nextNode.data.EntryId, "&action=view"));
21116
21136
  }
21117
21137
  }
21118
21138
  }, [setSelectedRowData, shiftId, shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId]);
@@ -21126,7 +21146,7 @@ var Logbook$1 = function () {
21126
21146
  }
21127
21147
  return [];
21128
21148
  }, [rows]);
21129
- var getMenuOptions = useLogbookEntryOptionsFunctions({
21149
+ var getMenuOptions = useLogbookEntryOptionsFunctions$1({
21130
21150
  setSelectedRowData: setSelectedRowData,
21131
21151
  setShow: setShow,
21132
21152
  setShowRemoveDialog: setShowRemoveDialog,
@@ -21149,7 +21169,7 @@ var Logbook$1 = function () {
21149
21169
  ],
21150
21170
  processCellCallback: function (params) {
21151
21171
  if (params.column.colId === "CreateTimestamp") {
21152
- return moment$3(params.value).format("MM/DD/yy - HH:mm");
21172
+ return moment$a(params.value).format("MM/DD/yy - HH:mm");
21153
21173
  }
21154
21174
  return params.value;
21155
21175
  },
@@ -21218,10 +21238,10 @@ var Logbook$1 = function () {
21218
21238
  if (entryId &&
21219
21239
  (shiftIdRef.current == null ||
21220
21240
  shiftIdRef.current === (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId))) {
21221
- navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId, "?entryId=").concat(entryId, "&action=").concat(action));
21241
+ navigate("".concat(routeLogbookEntry$1, "/").concat(shiftInfo.CurrentShiftId, "?entryId=").concat(entryId, "&action=").concat(action));
21222
21242
  }
21223
21243
  else {
21224
- navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId));
21244
+ navigate("".concat(routeLogbookEntry$1, "/").concat(shiftInfo.CurrentShiftId));
21225
21245
  }
21226
21246
  shiftIdRef.current = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId;
21227
21247
  (function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -21265,21 +21285,29 @@ var Logbook$1 = function () {
21265
21285
  }); })();
21266
21286
  }
21267
21287
  }, []);
21268
- return (React__default.createElement(React__default.Fragment, null,
21269
- React__default.createElement(Grid2, { container: true, size: {
21270
- xs: 12,
21271
- }, spacing: 2, justifyContent: "flex-start" },
21272
- React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
21273
- React__default.createElement(Typography$1, { variant: "h5", style: {
21274
- fontWeight: 600,
21275
- userSelect: "none",
21276
- } }, "LOGBOOK")),
21277
- React__default.createElement(Grid2, { container: true, size: { xs: 12, md: 5 }, spacing: 1 },
21278
- React__default.createElement(Grid2, { size: { xs: 12 } },
21279
- React__default.createElement(Filters$1, { withAssetFilter: withAssetFilter, filterAssets: filterAssets, quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, assetId: assetId, setAssetId: setAssetId })),
21280
- React__default.createElement(Grid2, { size: { xs: 12 } },
21288
+ return (React__default.createElement(Box, { sx: {
21289
+ width: "100%",
21290
+ height: "calc(100vh - 130px)",
21291
+ display: "flex",
21292
+ flexDirection: "column",
21293
+ } },
21294
+ React__default.createElement(Box, { sx: { mb: 2 } },
21295
+ React__default.createElement(Typography$1, { variant: "h5", style: {
21296
+ fontWeight: 600,
21297
+ userSelect: "none",
21298
+ } }, "LOGBOOK")),
21299
+ React__default.createElement(Group$1, { id: "logbook-entry-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
21300
+ React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
21301
+ React__default.createElement(Box, { sx: {
21302
+ display: "flex",
21303
+ flexDirection: "column",
21304
+ gap: 1,
21305
+ height: "100%",
21306
+ pr: 1,
21307
+ } },
21308
+ React__default.createElement(Filters$3, { withAssetFilter: withAssetFilter, filterAssets: filterAssets, quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, assetId: assetId, setAssetId: setAssetId }),
21281
21309
  React__default.createElement(Paper, { elevation: 1, style: {
21282
- height: "62vh",
21310
+ flex: 1,
21283
21311
  width: "100%",
21284
21312
  } },
21285
21313
  React__default.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 38, headerHeight: 42, loadingOverlayComponent: CenteredLazyLoading, animateRows: true, getContextMenuItems: getContextMenuItems, onRowClicked: rowClicked, onCellKeyDown: onCellKeyDown, onGridReady: function (params) { return (gridApiRef.current = params.api); }, getRowId: function (params) { return "".concat(params.data.EntryId); }, gridOptions: {
@@ -21308,81 +21336,112 @@ var Logbook$1 = function () {
21308
21336
  ],
21309
21337
  },
21310
21338
  } })))),
21311
- React__default.createElement(Grid2, { size: { xs: 12, md: 7 } },
21312
- React__default.createElement(EntryViewer$1, { entry: selectedRowData, show: show, onChangeShow: function () {
21313
- var newShow = show === "view" ? "edit" : "view";
21314
- setShow(newShow);
21315
- if (entryId && entryId !== "new") {
21316
- var targetUrl = newShow === "edit"
21317
- ? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
21318
- : "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
21319
- navigate(targetUrl);
21320
- }
21321
- }, preselectedAssetId: assetId, withAssetFilter: withAssetFilter, canEditAsset: canEditAsset, canEditShift: canEditShift, filterAssets: filterAssets, allowAttachments: allowAttachments, shiftsRange: shiftsRange, onHide: function (entryId, shouldStayInEditMode) { return __awaiter(void 0, void 0, void 0, function () {
21322
- var targetUrl;
21323
- var _a;
21324
- return __generator(this, function (_b) {
21325
- switch (_b.label) {
21326
- case 0:
21327
- if (!entryId) return [3 /*break*/, 2];
21328
- // First refetch to ensure we have the latest data
21329
- return [4 /*yield*/, refetch()];
21330
- case 1:
21331
- // First refetch to ensure we have the latest data
21332
- _b.sent();
21333
- targetUrl = shouldStayInEditMode
21334
- ? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
21335
- : "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
21336
- navigate(targetUrl);
21337
- setShow(shouldStayInEditMode ? "edit" : "view");
21338
- // Additional delay to allow navigation and state updates to complete
21339
- setTimeout(function () {
21340
- var _a, _b;
21341
- var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
21342
- if (rowNode) {
21343
- (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
21344
- rowNode.setSelected(true);
21345
- setSelectedRowData(rowNode.data);
21346
- }
21347
- else {
21348
- // If still not found, try one more refetch
21349
- setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
21350
- var retryRowNode;
21351
- var _a, _b, _c;
21352
- return __generator(this, function (_d) {
21353
- switch (_d.label) {
21354
- case 0: return [4 /*yield*/, refetch()];
21355
- case 1:
21356
- _d.sent();
21357
- retryRowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
21358
- if (retryRowNode) {
21359
- (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(retryRowNode);
21360
- retryRowNode.setSelected(true);
21361
- setSelectedRowData(retryRowNode.data);
21362
- }
21363
- else {
21364
- setShow("");
21365
- setSelectedRowData(null);
21366
- (_c = gridApiRef.current) === null || _c === void 0 ? void 0 : _c.deselectAll();
21367
- }
21368
- return [2 /*return*/];
21369
- }
21370
- });
21371
- }); }, 500);
21372
- }
21373
- }, 200);
21374
- return [3 /*break*/, 3];
21375
- case 2:
21376
- setShow("");
21377
- setSelectedRowData(null);
21378
- (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
21379
- navigate("".concat(routeLogbookEntry, "/").concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId)));
21380
- _b.label = 3;
21381
- case 3: return [2 /*return*/];
21339
+ React__default.createElement(Separator, { style: {
21340
+ display: "flex",
21341
+ alignItems: "center",
21342
+ justifyContent: "center",
21343
+ cursor: "col-resize",
21344
+ } },
21345
+ React__default.createElement(Box, { sx: {
21346
+ width: 8,
21347
+ height: 48,
21348
+ borderRadius: 1,
21349
+ backgroundColor: "#e0e0e0",
21350
+ display: "flex",
21351
+ flexDirection: "column",
21352
+ alignItems: "center",
21353
+ justifyContent: "center",
21354
+ gap: "3px",
21355
+ transition: "background-color 0.2s",
21356
+ "&:hover": {
21357
+ backgroundColor: "primary.main",
21358
+ "& .grip-dot": {
21359
+ backgroundColor: "#fff",
21360
+ },
21361
+ },
21362
+ } }, __spreadArray([], Array(5), true).map(function (_, i) { return (React__default.createElement(Box, { key: i, className: "grip-dot", sx: {
21363
+ width: 4,
21364
+ height: 4,
21365
+ borderRadius: "50%",
21366
+ backgroundColor: "#9e9e9e",
21367
+ transition: "background-color 0.2s",
21368
+ } })); }))),
21369
+ React__default.createElement(Panel, { id: "right", defaultSize: 58, minSize: 30, style: { paddingBottom: 5 } },
21370
+ React__default.createElement(Box, { sx: { pl: 1, height: "100%" } },
21371
+ React__default.createElement(EntryViewer$3, { entry: selectedRowData, show: show, onChangeShow: function () {
21372
+ var newShow = show === "view" ? "edit" : "view";
21373
+ setShow(newShow);
21374
+ if (entryId && entryId !== "new") {
21375
+ var targetUrl = newShow === "edit"
21376
+ ? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
21377
+ : "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
21378
+ navigate(targetUrl);
21382
21379
  }
21383
- });
21384
- }); } }))),
21385
- React__default.createElement(RemoveEntryDialog, { entry: selectedRowData, show: showRemoveDialog, onHide: function (shouldUpdate) {
21380
+ }, preselectedAssetId: assetId, withAssetFilter: withAssetFilter, canEditAsset: canEditAsset, canEditShift: canEditShift, filterAssets: filterAssets, allowAttachments: allowAttachments, shiftsRange: shiftsRange, onHide: function (entryId, shouldStayInEditMode) { return __awaiter(void 0, void 0, void 0, function () {
21381
+ var targetUrl;
21382
+ var _a;
21383
+ return __generator(this, function (_b) {
21384
+ switch (_b.label) {
21385
+ case 0:
21386
+ if (!entryId) return [3 /*break*/, 2];
21387
+ // First refetch to ensure we have the latest data
21388
+ return [4 /*yield*/, refetch()];
21389
+ case 1:
21390
+ // First refetch to ensure we have the latest data
21391
+ _b.sent();
21392
+ targetUrl = shouldStayInEditMode
21393
+ ? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
21394
+ : "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
21395
+ navigate(targetUrl);
21396
+ setShow(shouldStayInEditMode ? "edit" : "view");
21397
+ // Additional delay to allow navigation and state updates to complete
21398
+ setTimeout(function () {
21399
+ var _a, _b;
21400
+ var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
21401
+ if (rowNode) {
21402
+ (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
21403
+ rowNode.setSelected(true);
21404
+ setSelectedRowData(rowNode.data);
21405
+ }
21406
+ else {
21407
+ // If still not found, try one more refetch
21408
+ setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
21409
+ var retryRowNode;
21410
+ var _a, _b, _c;
21411
+ return __generator(this, function (_d) {
21412
+ switch (_d.label) {
21413
+ case 0: return [4 /*yield*/, refetch()];
21414
+ case 1:
21415
+ _d.sent();
21416
+ retryRowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
21417
+ if (retryRowNode) {
21418
+ (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(retryRowNode);
21419
+ retryRowNode.setSelected(true);
21420
+ setSelectedRowData(retryRowNode.data);
21421
+ }
21422
+ else {
21423
+ setShow("");
21424
+ setSelectedRowData(null);
21425
+ (_c = gridApiRef.current) === null || _c === void 0 ? void 0 : _c.deselectAll();
21426
+ }
21427
+ return [2 /*return*/];
21428
+ }
21429
+ });
21430
+ }); }, 500);
21431
+ }
21432
+ }, 200);
21433
+ return [3 /*break*/, 3];
21434
+ case 2:
21435
+ setShow("");
21436
+ setSelectedRowData(null);
21437
+ (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
21438
+ navigate("".concat(routeLogbookEntry$1, "/").concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId)));
21439
+ _b.label = 3;
21440
+ case 3: return [2 /*return*/];
21441
+ }
21442
+ });
21443
+ }); } })))),
21444
+ React__default.createElement(RemoveEntryDialog$1, { entry: selectedRowData, show: showRemoveDialog, onHide: function (shouldUpdate) {
21386
21445
  if (shouldUpdate) {
21387
21446
  refetch();
21388
21447
  }
@@ -21393,19 +21452,19 @@ var Logbook$1 = function () {
21393
21452
  React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
21394
21453
  };
21395
21454
 
21396
- var LogbookPage$1 = function () {
21455
+ var LogbookPage$3 = function () {
21397
21456
  return (React__default.createElement(React__default.Fragment, null,
21398
21457
  React__default.createElement(HelmetDexteel, { title: "Logbook Entry" }),
21399
21458
  React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
21400
- React__default.createElement(Logbook$1, null))));
21459
+ React__default.createElement(Logbook$3, null))));
21401
21460
  };
21402
21461
 
21403
- var MESFLogbookEntry = function () {
21404
- return React__default.createElement(LogbookPage$1, null);
21462
+ var MESFLogbookEntry$1 = function () {
21463
+ return React__default.createElement(LogbookPage$3, null);
21405
21464
  };
21406
21465
 
21407
- var moment$2 = getMomentTz();
21408
- var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
21466
+ var moment$9 = getMomentTz();
21467
+ var getEntriesReport$1 = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
21409
21468
  var apiService, parameters, resp, rows;
21410
21469
  var startShiftId = _b.startShiftId, endShiftId = _b.endShiftId, assetId = _b.assetId;
21411
21470
  return __generator(this, function (_c) {
@@ -21425,9 +21484,9 @@ var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, fu
21425
21484
  if (resp.ok) {
21426
21485
  rows = get(resp, "data.tables[0].rows", []);
21427
21486
  rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
21428
- ? moment$2.utc(entry["CreateTimestamp"]).toDate()
21487
+ ? moment$9.utc(entry["CreateTimestamp"]).toDate()
21429
21488
  : null, UpdateTimestamp: entry.UpdateTimestamp
21430
- ? moment$2.utc(entry["UpdateTimestamp"]).toDate()
21489
+ ? moment$9.utc(entry["UpdateTimestamp"]).toDate()
21431
21490
  : null })); });
21432
21491
  return [2 /*return*/, rows];
21433
21492
  }
@@ -21438,16 +21497,16 @@ var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, fu
21438
21497
  });
21439
21498
  }); };
21440
21499
 
21441
- var useEntriesReport = function (_a) {
21500
+ var useEntriesReport$1 = function (_a) {
21442
21501
  var startShiftId = _a.startShiftId, endShiftId = _a.endShiftId, assetId = _a.assetId;
21443
21502
  return useQuery({
21444
21503
  queryKey: ["entriesReport", startShiftId, endShiftId, assetId],
21445
- queryFn: function () { return getEntriesReport({ startShiftId: startShiftId, endShiftId: endShiftId, assetId: assetId }); },
21504
+ queryFn: function () { return getEntriesReport$1({ startShiftId: startShiftId, endShiftId: endShiftId, assetId: assetId }); },
21446
21505
  });
21447
21506
  };
21448
21507
  var routeLogbookReport = "/logbook/report";
21449
21508
 
21450
- var useTableData = function (_a) {
21509
+ var useTableData$2 = function (_a) {
21451
21510
  var showAttachments = _a.showAttachments, showAsset = _a.showAsset, showShiftCrew = _a.showShiftCrew;
21452
21511
  var columnDefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
21453
21512
  {
@@ -21540,8 +21599,8 @@ var useTableData = function (_a) {
21540
21599
  return { columnDefs: columnDefs };
21541
21600
  };
21542
21601
 
21543
- var moment$1 = getMomentTz();
21544
- var EntryViewer = function (_a) {
21602
+ var moment$8 = getMomentTz();
21603
+ var EntryViewer$2 = function (_a) {
21545
21604
  var entry = _a.entry, show = _a.show, onHide = _a.onHide, filterAssets = _a.filterAssets, showAsset = _a.showAsset, _b = _a.showAttachments, showAttachments = _b === void 0 ? false : _b;
21546
21605
  var _c = useState(""), error = _c[0], setError = _c[1];
21547
21606
  var _d = useForm(), control = _d.control, setValue = _d.setValue, reset = _d.reset, watch = _d.watch; _d.getValues;
@@ -21555,7 +21614,7 @@ var EntryViewer = function (_a) {
21555
21614
  var assetId = watch("AssetId");
21556
21615
  var createTimestamp = watch("CreateTimestamp");
21557
21616
  useEffect(function () {
21558
- reset(entry || ENTRY_INITIAL_VALUES);
21617
+ reset(entry || ENTRY_INITIAL_VALUES$1);
21559
21618
  }, [entry, show]);
21560
21619
  return (React__default.createElement(React__default.Fragment, null,
21561
21620
  (entry === null || entry === void 0 ? void 0 : entry.EntryId) && (React__default.createElement(HelmetDexteel, { title: "'".concat(entry === null || entry === void 0 ? void 0 : entry.Title, "' by ").concat(entry.Author, " - Logbook Report") })),
@@ -21575,7 +21634,7 @@ var EntryViewer = function (_a) {
21575
21634
  React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
21576
21635
  React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
21577
21636
  var value = _a.field.value;
21578
- return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$1(value) : null, disabled: true, slotProps: {
21637
+ return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$8(value) : null, disabled: true, slotProps: {
21579
21638
  textField: {
21580
21639
  variant: "outlined",
21581
21640
  size: "small",
@@ -21606,7 +21665,7 @@ var EntryViewer = function (_a) {
21606
21665
  React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
21607
21666
  React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
21608
21667
  var _b = _a.field; _b.value; _b.onChange;
21609
- return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return setValue("Content", val); }, value: content, isEditing: false, isNewEntry: false, entryId: entryId, entryData: {
21668
+ return (React__default.createElement(ContentInput$1, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return setValue("Content", val); }, value: content, isEditing: false, isNewEntry: false, entryId: entryId, entryData: {
21610
21669
  assetId: assetId,
21611
21670
  entryId: entryId,
21612
21671
  shiftId: shiftId,
@@ -21623,7 +21682,7 @@ var EntryViewer = function (_a) {
21623
21682
  React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
21624
21683
  };
21625
21684
 
21626
- var customPeriodOptions = [
21685
+ var customPeriodOptions$1 = [
21627
21686
  { value: "Day", label: "Day" },
21628
21687
  { value: "4Days", label: "4 Days" },
21629
21688
  { value: "Week", label: "Week" },
@@ -21650,7 +21709,7 @@ var buildTreeAssets = function (nodes) {
21650
21709
  });
21651
21710
  return root;
21652
21711
  };
21653
- var Filters = function (_a) {
21712
+ var Filters$2 = function (_a) {
21654
21713
  var withAssetFilter = _a.withAssetFilter, filterAssets = _a.filterAssets, quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange, assetId = _a.assetId, setAssetId = _a.setAssetId, shiftPeriod = _a.shiftPeriod, onChangeShiftPeriod = _a.onChangeShiftPeriod, actualPeriod = _a.actualPeriod;
21655
21714
  var handleShiftPeriodChange = function (value, period) {
21656
21715
  onChangeShiftPeriod(value, period);
@@ -21676,7 +21735,7 @@ var Filters = function (_a) {
21676
21735
  return (React__default.createElement(Paper, { elevation: 1, style: { padding: 8 } },
21677
21736
  React__default.createElement(Grid2, { container: true, spacing: 1 },
21678
21737
  React__default.createElement(Grid2, { size: { xs: 12 }, alignItems: "center", justifyContent: "center" },
21679
- React__default.createElement(ShiftPeriodNavigatorControl, { onChange: handleShiftPeriodChange, value: shiftPeriod, actualPeriod: actualPeriod, showShiftAndCrews: false, dateFormat: "MM/DD/YYYY", periodOptions: customPeriodOptions })),
21738
+ React__default.createElement(ShiftPeriodNavigatorControl, { onChange: handleShiftPeriodChange, value: shiftPeriod, actualPeriod: actualPeriod, showShiftAndCrews: false, dateFormat: "MM/DD/YYYY", periodOptions: customPeriodOptions$1 })),
21680
21739
  React__default.createElement(Grid2, { size: { xs: 12, md: withAssetFilter ? 6 : 12 } },
21681
21740
  React__default.createElement(TextField, { fullWidth: true, label: "Search", variant: "outlined", size: "small", margin: "dense", value: quickFilter, onChange: function (event) {
21682
21741
  onQuickFilterChange(event === null || event === void 0 ? void 0 : event.target.value);
@@ -21700,8 +21759,10 @@ var Filters = function (_a) {
21700
21759
  }, filterAreaAssets: filterAssets === "area", isFilter: true }))))));
21701
21760
  };
21702
21761
 
21703
- var moment = getMomentTz();
21704
- var Logbook = function () {
21762
+ var moment$7 = getMomentTz();
21763
+ // Default layout matching original Grid md:5 / md:7 ratio (41.67% / 58.33%)
21764
+ var DEFAULT_LAYOUT$2 = { left: 42, right: 58 };
21765
+ var Logbook$2 = function () {
21705
21766
  var report = useLogbookSettings().report;
21706
21767
  var defaultAreaId = useUserContext().state.defaultAreaId;
21707
21768
  var withAssetFilter = report.withAssetFilter;
@@ -21756,17 +21817,24 @@ var Logbook = function () {
21756
21817
  }
21757
21818
  setSearchParams(newParams);
21758
21819
  };
21759
- var _h = useEntriesReport({
21820
+ var _h = useEntriesReport$1({
21760
21821
  startShiftId: shiftPeriod.StartShiftId,
21761
21822
  endShiftId: shiftPeriod.EndShiftId,
21762
21823
  assetId: assetId,
21763
21824
  }), rows = _h.data, isLoading = _h.isLoading, e = _h.error, isError = _h.isError, refetch = _h.refetch;
21764
- var columnDefs = useTableData({
21825
+ var columnDefs = useTableData$2({
21765
21826
  showAttachments: showAttachments,
21766
21827
  showAsset: showAsset,
21767
21828
  showShiftCrew: showShiftCrew,
21768
21829
  }).columnDefs;
21769
- var defaultColDef = useGridDefinitions({}).defaultColDef;
21830
+ var defaultColDef = useGridDefinitions$1({}).defaultColDef;
21831
+ // Resizable panels layout persistence
21832
+ var _j = useDefaultLayout({
21833
+ id: "logbook-report-v2",
21834
+ storage: localStorage,
21835
+ }), savedLayout = _j.defaultLayout, onLayoutChange = _j.onLayoutChange;
21836
+ // Use saved layout or default to avoid flash on initial render
21837
+ var resolvedLayout = savedLayout !== null && savedLayout !== void 0 ? savedLayout : DEFAULT_LAYOUT$2;
21770
21838
  var onQuickFilterChange = function (text) {
21771
21839
  var _a;
21772
21840
  setQuickFilter(text);
@@ -21814,7 +21882,7 @@ var Logbook = function () {
21814
21882
  ],
21815
21883
  processCellCallback: function (params) {
21816
21884
  if (params.column.colId === "CreateTimestamp") {
21817
- return moment(params.value).format("MM/DD/yy - HH:mm");
21885
+ return moment$7(params.value).format("MM/DD/yy - HH:mm");
21818
21886
  }
21819
21887
  return params.value;
21820
21888
  },
@@ -21887,18 +21955,27 @@ var Logbook = function () {
21887
21955
  }); })();
21888
21956
  }
21889
21957
  }, [shiftPeriod.StartShiftId, shiftPeriod.EndShiftId]);
21890
- return (React__default.createElement(React__default.Fragment, null,
21891
- React__default.createElement(Grid2, { container: true, size: {
21892
- xs: 12,
21893
- }, spacing: 2, justifyContent: "flex-start" },
21894
- React__default.createElement(Grid2, { size: { md: 12, xs: 12 } },
21895
- React__default.createElement(Typography$1, { variant: "h5", style: {
21896
- fontWeight: 600,
21897
- userSelect: "none",
21898
- } }, "LOGBOOK REPORT")),
21899
- React__default.createElement(Grid2, { container: true, size: { xs: 12, md: 5 }, spacing: 1 },
21900
- React__default.createElement(Grid2, { size: { xs: 12 } },
21901
- React__default.createElement(Filters, { withAssetFilter: withAssetFilter, filterAssets: filterAssets, quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, assetId: assetId, setAssetId: function (value) { return setAssetId(value); }, shiftPeriod: shiftPeriod, onChangeShiftPeriod: function (value, period) {
21958
+ return (React__default.createElement(Box, { sx: {
21959
+ width: "100%",
21960
+ height: "calc(100vh - 130px)",
21961
+ display: "flex",
21962
+ flexDirection: "column",
21963
+ } },
21964
+ React__default.createElement(Box, { sx: { mb: 2 } },
21965
+ React__default.createElement(Typography$1, { variant: "h5", style: {
21966
+ fontWeight: 600,
21967
+ userSelect: "none",
21968
+ } }, "LOGBOOK REPORT")),
21969
+ React__default.createElement(Group$1, { id: "logbook-report-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
21970
+ React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
21971
+ React__default.createElement(Box, { sx: {
21972
+ display: "flex",
21973
+ flexDirection: "column",
21974
+ gap: 1,
21975
+ height: "100%",
21976
+ pr: 1,
21977
+ } },
21978
+ React__default.createElement(Filters$2, { withAssetFilter: withAssetFilter, filterAssets: filterAssets, quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, assetId: assetId, setAssetId: function (value) { return setAssetId(value); }, shiftPeriod: shiftPeriod, onChangeShiftPeriod: function (value, period) {
21902
21979
  setShiftPeriod(value);
21903
21980
  updateUrl({
21904
21981
  startShiftId: value.StartShiftId,
@@ -21906,10 +21983,9 @@ var Logbook = function () {
21906
21983
  period: period,
21907
21984
  entryId: searchParams.get("entryId"),
21908
21985
  });
21909
- }, actualPeriod: searchParams.get("period") })),
21910
- React__default.createElement(Grid2, { size: { xs: 12 } },
21986
+ }, actualPeriod: searchParams.get("period") }),
21911
21987
  React__default.createElement(Paper, { elevation: 1, style: {
21912
- height: "62vh",
21988
+ flex: 1,
21913
21989
  width: "100%",
21914
21990
  } },
21915
21991
  React__default.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 38, headerHeight: 42, loadingOverlayComponent: CenteredLazyLoading, animateRows: true, onRowClicked: rowClicked, onCellKeyDown: onCellKeyDown, onGridReady: function (params) { return (gridApiRef.current = params.api); }, getRowId: function (params) { return "".concat(params.data.EntryId); }, gridOptions: {
@@ -21935,40 +22011,71 @@ var Logbook = function () {
21935
22011
  ],
21936
22012
  },
21937
22013
  } })))),
21938
- React__default.createElement(Grid2, { size: { xs: 12, md: 7 } },
21939
- React__default.createElement(EntryViewer, { entry: selectedRowData, show: show, onChangeShow: function () { return setShow(show === "view" ? "edit" : "view"); }, onHide: function () {
21940
- var _a;
21941
- setShow("");
21942
- setSelectedRowData(null);
21943
- (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
21944
- updateUrl({ entryId: null });
21945
- }, filterAssets: filterAssets, showAsset: showAsset, showAttachments: showAttachments }))),
22014
+ React__default.createElement(Separator, { style: {
22015
+ display: "flex",
22016
+ alignItems: "center",
22017
+ justifyContent: "center",
22018
+ cursor: "col-resize",
22019
+ } },
22020
+ React__default.createElement(Box, { sx: {
22021
+ width: 8,
22022
+ height: 48,
22023
+ borderRadius: 1,
22024
+ backgroundColor: "#e0e0e0",
22025
+ display: "flex",
22026
+ flexDirection: "column",
22027
+ alignItems: "center",
22028
+ justifyContent: "center",
22029
+ gap: "3px",
22030
+ transition: "background-color 0.2s",
22031
+ "&:hover": {
22032
+ backgroundColor: "primary.main",
22033
+ "& .grip-dot": {
22034
+ backgroundColor: "#fff",
22035
+ },
22036
+ },
22037
+ } }, __spreadArray([], Array(5), true).map(function (_, i) { return (React__default.createElement(Box, { key: i, className: "grip-dot", sx: {
22038
+ width: 4,
22039
+ height: 4,
22040
+ borderRadius: "50%",
22041
+ backgroundColor: "#9e9e9e",
22042
+ transition: "background-color 0.2s",
22043
+ } })); }))),
22044
+ React__default.createElement(Panel, { id: "right", defaultSize: 58, minSize: 30, style: { paddingBottom: 5 } },
22045
+ React__default.createElement(Box, { sx: { pl: 1, height: "100%" } },
22046
+ React__default.createElement(EntryViewer$2, { entry: selectedRowData, show: show, onChangeShow: function () { return setShow(show === "view" ? "edit" : "view"); }, onHide: function () {
22047
+ var _a;
22048
+ setShow("");
22049
+ setSelectedRowData(null);
22050
+ (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
22051
+ updateUrl({ entryId: null });
22052
+ }, filterAssets: filterAssets, showAsset: showAsset, showAttachments: showAttachments })))),
21946
22053
  React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
21947
22054
  };
21948
22055
 
21949
- var LogbookPage = function () {
22056
+ var LogbookPage$2 = function () {
21950
22057
  return (React__default.createElement(React__default.Fragment, null,
21951
22058
  React__default.createElement(HelmetDexteel, { title: "Logbook Report" }),
21952
22059
  React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
21953
- React__default.createElement(Logbook, null))));
22060
+ React__default.createElement(Logbook$2, null))));
21954
22061
  };
21955
22062
 
21956
- var MESFLogbookReport = function () {
21957
- return React__default.createElement(LogbookPage, null);
22063
+ var MESFLogbookReport$1 = function () {
22064
+ return React__default.createElement(LogbookPage$2, null);
21958
22065
  };
21959
22066
 
21960
22067
  var logbookRoutesMESF = [
21961
22068
  {
21962
22069
  path: "/logbook/entry",
21963
- element: React__default.createElement(MESFLogbookEntry),
22070
+ element: React__default.createElement(MESFLogbookEntry$1),
21964
22071
  },
21965
22072
  {
21966
22073
  path: "/logbook/entry/:shiftId",
21967
- element: React__default.createElement(MESFLogbookEntry),
22074
+ element: React__default.createElement(MESFLogbookEntry$1),
21968
22075
  },
21969
22076
  {
21970
22077
  path: "/logbook/report",
21971
- element: React__default.createElement(MESFLogbookReport),
22078
+ element: React__default.createElement(MESFLogbookReport$1),
21972
22079
  },
21973
22080
  ];
21974
22081
  var logbookNavbar = [
@@ -21988,6 +22095,2681 @@ var logbookNavbar = [
21988
22095
  },
21989
22096
  ];
21990
22097
 
22098
+ var useGridDefinitions = function (_a) {
22099
+ _a.OnEdit; _a.OnSend;
22100
+ var defaultColDef = {
22101
+ flex: 1,
22102
+ filter: false,
22103
+ floatingFilter: false,
22104
+ sortable: false,
22105
+ editable: false,
22106
+ resizable: false,
22107
+ wrapText: false,
22108
+ autoHeight: false,
22109
+ wrapHeaderText: true,
22110
+ suppressHeaderMenuButton: true,
22111
+ cellStyle: {
22112
+ display: "flex",
22113
+ alignItems: "center",
22114
+ justifyContent: "center",
22115
+ },
22116
+ };
22117
+ return {
22118
+ defaultColDef: defaultColDef,
22119
+ };
22120
+ };
22121
+
22122
+ var moment$6 = getMomentTz();
22123
+ var getEntries = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
22124
+ var apiService, parameters, resp, rows;
22125
+ var shiftId = _b.shiftId, sectionIds = _b.sectionIds, signal = _b.signal;
22126
+ return __generator(this, function (_c) {
22127
+ switch (_c.label) {
22128
+ case 0:
22129
+ apiService = new MESApiService();
22130
+ parameters = [
22131
+ { name: "ShiftId", value: shiftId },
22132
+ ];
22133
+ // Pass comma-separated sectionIds for multi-select filter
22134
+ if (sectionIds && sectionIds.length > 0) {
22135
+ parameters.push({ name: "SectionIds", value: sectionIds.join(",") });
22136
+ }
22137
+ return [4 /*yield*/, apiService.callV2("[SWV].[GetSectionLogbookEntries]", parameters, signal)];
22138
+ case 1:
22139
+ resp = _c.sent();
22140
+ if (resp.ok) {
22141
+ rows = get(resp, "data.tables[0].rows", []);
22142
+ rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
22143
+ ? moment$6.utc(entry["CreateTimestamp"]).toDate()
22144
+ : null, UpdateTimestamp: entry.UpdateTimestamp
22145
+ ? moment$6.utc(entry["UpdateTimestamp"]).toDate()
22146
+ : null })); });
22147
+ return [2 /*return*/, rows];
22148
+ }
22149
+ else {
22150
+ throw new Error(resp.message || "Error fetching entries");
22151
+ }
22152
+ }
22153
+ });
22154
+ }); };
22155
+ var upsertEntry = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
22156
+ var apiService, parameters, resp;
22157
+ var assetId = _b.assetId, entryId = _b.entryId, shiftId = _b.shiftId, title = _b.title, content = _b.content, createTimestamp = _b.createTimestamp, author = _b.author;
22158
+ return __generator(this, function (_c) {
22159
+ switch (_c.label) {
22160
+ case 0:
22161
+ apiService = new MESApiService();
22162
+ parameters = [
22163
+ { name: "EntryId", value: entryId },
22164
+ { name: "ShiftId", value: shiftId },
22165
+ { name: "Title", value: title },
22166
+ { name: "Content", value: content },
22167
+ {
22168
+ name: "CreateTimestamp",
22169
+ value: createTimestamp.toISOString(),
22170
+ },
22171
+ {
22172
+ name: "UpdateTimestamp",
22173
+ value: new Date().toISOString(),
22174
+ },
22175
+ { name: "Author", value: author },
22176
+ ];
22177
+ if (assetId || assetId === 0) {
22178
+ parameters.push({ name: "AssetId", value: assetId });
22179
+ }
22180
+ return [4 /*yield*/, apiService.callV2("[LB].[UpsertEntry]", parameters)];
22181
+ case 1:
22182
+ resp = _c.sent();
22183
+ if (resp.ok) {
22184
+ return [2 /*return*/, get(resp, "data.tables[0].rows[0]", null)];
22185
+ }
22186
+ {
22187
+ throw new Error(resp.message || "Error upserting entry");
22188
+ }
22189
+ }
22190
+ });
22191
+ }); };
22192
+ var deleteEntry = function (EntryId) { return __awaiter(void 0, void 0, void 0, function () {
22193
+ var apiService, attachmentsToDelete, error_1, parameters, resp;
22194
+ return __generator(this, function (_a) {
22195
+ switch (_a.label) {
22196
+ case 0:
22197
+ apiService = new MESApiService();
22198
+ attachmentsToDelete = [];
22199
+ _a.label = 1;
22200
+ case 1:
22201
+ _a.trys.push([1, 4, , 5]);
22202
+ if (!EntryId) return [3 /*break*/, 3];
22203
+ return [4 /*yield*/, getEntryAttachments(EntryId)];
22204
+ case 2:
22205
+ attachmentsToDelete = _a.sent();
22206
+ _a.label = 3;
22207
+ case 3: return [3 /*break*/, 5];
22208
+ case 4:
22209
+ error_1 = _a.sent();
22210
+ // If we can't get attachments, log but continue with entry deletion
22211
+ console.warn("Failed to get attachments for entry deletion:", error_1);
22212
+ return [3 /*break*/, 5];
22213
+ case 5:
22214
+ parameters = [{ name: "EntryId", value: EntryId }];
22215
+ return [4 /*yield*/, apiService.callV2("[LB].[DeleteEntry]", parameters)];
22216
+ case 6:
22217
+ resp = _a.sent();
22218
+ if (!resp.ok) {
22219
+ throw new Error(resp.message || "Error deleting entry");
22220
+ }
22221
+ // Delete associated files in background (don't block the UI)
22222
+ if (attachmentsToDelete.length > 0) {
22223
+ deleteAttachedFilesInBackground(attachmentsToDelete);
22224
+ }
22225
+ return [2 /*return*/];
22226
+ }
22227
+ });
22228
+ }); };
22229
+ var deleteAttachedFilesInBackground = function (attachments) { return __awaiter(void 0, void 0, void 0, function () {
22230
+ return __generator(this, function (_a) {
22231
+ // Delete files in background without blocking the UI
22232
+ Promise.all(attachments.map(function (attachment) { return __awaiter(void 0, void 0, void 0, function () {
22233
+ var error_2;
22234
+ return __generator(this, function (_a) {
22235
+ switch (_a.label) {
22236
+ case 0:
22237
+ _a.trys.push([0, 2, , 3]);
22238
+ return [4 /*yield*/, deleteUploadFile(attachment.UploadFileId)];
22239
+ case 1:
22240
+ _a.sent();
22241
+ return [3 /*break*/, 3];
22242
+ case 2:
22243
+ error_2 = _a.sent();
22244
+ // Log errors but don't fail the entire operation
22245
+ console.error("Failed to delete file ".concat(attachment.UploadFileId, ":"), error_2);
22246
+ return [3 /*break*/, 3];
22247
+ case 3: return [2 /*return*/];
22248
+ }
22249
+ });
22250
+ }); })).catch(function (error) {
22251
+ console.error("Background file deletion failed:", error);
22252
+ });
22253
+ return [2 /*return*/];
22254
+ });
22255
+ }); };
22256
+ var deleteUploadFile = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
22257
+ var apiService, parameters, resp;
22258
+ return __generator(this, function (_a) {
22259
+ switch (_a.label) {
22260
+ case 0:
22261
+ apiService = new MESApiService();
22262
+ parameters = [
22263
+ { name: "UploadFileId", value: uploadFileId },
22264
+ ];
22265
+ return [4 /*yield*/, apiService.callV2("[SYSTEM].[DeleteUploadFile]", parameters)];
22266
+ case 1:
22267
+ resp = _a.sent();
22268
+ if (!resp.ok) {
22269
+ throw new Error(resp.message || "Error deleting upload file");
22270
+ }
22271
+ return [2 /*return*/];
22272
+ }
22273
+ });
22274
+ }); };
22275
+ // Attachment management functions
22276
+ var getEntryAttachments = function (entryId) { return __awaiter(void 0, void 0, void 0, function () {
22277
+ var apiService, parameters, resp, rows;
22278
+ return __generator(this, function (_a) {
22279
+ switch (_a.label) {
22280
+ case 0:
22281
+ apiService = new MESApiService();
22282
+ parameters = [{ name: "EntryId", value: entryId }];
22283
+ return [4 /*yield*/, apiService.callV2("[LB].[GetEntryAttachments]", parameters)];
22284
+ case 1:
22285
+ resp = _a.sent();
22286
+ if (resp.ok) {
22287
+ rows = get(resp, "data.tables[0].rows", []);
22288
+ rows = rows.map(function (attachment) { return (__assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
22289
+ ? moment$6.utc(attachment.CreationTime).toDate()
22290
+ : new Date() })); });
22291
+ return [2 /*return*/, rows];
22292
+ }
22293
+ else {
22294
+ throw new Error(resp.message || "Error fetching entry attachments");
22295
+ }
22296
+ }
22297
+ });
22298
+ }); };
22299
+ var upsertEntryAttachment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
22300
+ var apiService, parameters, resp, attachment;
22301
+ var entryId = _b.entryId, uploadFileId = _b.uploadFileId, attachmentName = _b.attachmentName, attachmentURL = _b.attachmentURL;
22302
+ return __generator(this, function (_c) {
22303
+ switch (_c.label) {
22304
+ case 0:
22305
+ apiService = new MESApiService();
22306
+ parameters = [
22307
+ { name: "EntryId", value: entryId },
22308
+ { name: "UploadFileId", value: uploadFileId },
22309
+ { name: "AttachmentName", value: attachmentName },
22310
+ { name: "AttachmentURL", value: attachmentURL },
22311
+ ];
22312
+ return [4 /*yield*/, apiService.callV2("[LB].[UpsertEntryAttachment]", parameters)];
22313
+ case 1:
22314
+ resp = _c.sent();
22315
+ if (resp.ok) {
22316
+ attachment = get(resp, "data.tables[0].rows[0]", null);
22317
+ if (attachment) {
22318
+ return [2 /*return*/, __assign(__assign({}, attachment), { CreationTime: attachment.CreationTime
22319
+ ? moment$6.utc(attachment.CreationTime).toDate()
22320
+ : new Date() })];
22321
+ }
22322
+ return [2 /*return*/, null];
22323
+ }
22324
+ else {
22325
+ throw new Error(resp.message || "Error creating entry attachment");
22326
+ }
22327
+ }
22328
+ });
22329
+ }); };
22330
+ var deleteEntryAttachment = function (entryAttachmentId, uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
22331
+ var apiService, parameters, resp;
22332
+ return __generator(this, function (_a) {
22333
+ switch (_a.label) {
22334
+ case 0:
22335
+ apiService = new MESApiService();
22336
+ parameters = [
22337
+ { name: "EntryAttachmentId", value: entryAttachmentId },
22338
+ ];
22339
+ return [4 /*yield*/, apiService.callV2("[LB].[DeleteEntryAttachment]", parameters)];
22340
+ case 1:
22341
+ resp = _a.sent();
22342
+ if (!resp.ok) {
22343
+ throw new Error(resp.message || "Error deleting entry attachment");
22344
+ }
22345
+ // Delete the associated file in background if UploadFileId was provided
22346
+ if (uploadFileId) {
22347
+ deleteUploadFileInBackground(uploadFileId);
22348
+ }
22349
+ return [2 /*return*/];
22350
+ }
22351
+ });
22352
+ }); };
22353
+ var deleteUploadFileInBackground = function (uploadFileId) { return __awaiter(void 0, void 0, void 0, function () {
22354
+ var error_3;
22355
+ return __generator(this, function (_a) {
22356
+ switch (_a.label) {
22357
+ case 0:
22358
+ _a.trys.push([0, 2, , 3]);
22359
+ return [4 /*yield*/, deleteUploadFile(uploadFileId)];
22360
+ case 1:
22361
+ _a.sent();
22362
+ return [3 /*break*/, 3];
22363
+ case 2:
22364
+ error_3 = _a.sent();
22365
+ // Log errors but don't fail the operation
22366
+ console.error("Failed to delete file ".concat(uploadFileId, ":"), error_3);
22367
+ return [3 /*break*/, 3];
22368
+ case 3: return [2 /*return*/];
22369
+ }
22370
+ });
22371
+ }); };
22372
+
22373
+ var useEntries = function (_a) {
22374
+ var shiftId = _a.shiftId, sectionIds = _a.sectionIds;
22375
+ return useQuery({
22376
+ queryKey: ["entries", shiftId, sectionIds],
22377
+ queryFn: function (_a) {
22378
+ var signal = _a.signal;
22379
+ return getEntries({ shiftId: shiftId, sectionIds: sectionIds, signal: signal });
22380
+ },
22381
+ });
22382
+ };
22383
+ var routeLogbookEntry = "/logbook/entry";
22384
+
22385
+ var useLogbookEntryOptionsFunctions = function (_a) {
22386
+ var setSelectedRowData = _a.setSelectedRowData, setShow = _a.setShow, setShowRemoveDialog = _a.setShowRemoveDialog, handleNewEntry = _a.handleNewEntry;
22387
+ var getMenuOptions = function (data) {
22388
+ var options = [];
22389
+ options = options.concat([
22390
+ {
22391
+ name: "New Entry",
22392
+ key: "new_logbook_entry",
22393
+ onClick: function () { return handleNewEntry(); },
22394
+ icon: React__default.createElement(PlaylistAddIcon, null),
22395
+ },
22396
+ ]);
22397
+ if (data) {
22398
+ options = options.concat([
22399
+ {
22400
+ name: "Edit Entry",
22401
+ key: "edit_logbook_entry",
22402
+ onClick: function () {
22403
+ setSelectedRowData(data);
22404
+ setShow("edit");
22405
+ },
22406
+ icon: React__default.createElement(EditIcon, null),
22407
+ },
22408
+ {
22409
+ name: "Delete Entry",
22410
+ key: "delete_logbook_entry",
22411
+ onClick: function () {
22412
+ setShowRemoveDialog(true);
22413
+ },
22414
+ icon: React__default.createElement(DeleteIcon, null),
22415
+ },
22416
+ ]);
22417
+ }
22418
+ return options;
22419
+ };
22420
+ return {
22421
+ getMenuOptions: getMenuOptions,
22422
+ };
22423
+ };
22424
+
22425
+ var useTableData$1 = function (_a) {
22426
+ var showContextMenu = _a.showContextMenu, allowAttachments = _a.allowAttachments, showShiftCrew = _a.showShiftCrew;
22427
+ var columnDefs = __spreadArray(__spreadArray(__spreadArray([
22428
+ {
22429
+ field: "CreateTimestamp",
22430
+ headerName: "Created",
22431
+ flex: 2,
22432
+ valueGetter: function (params) {
22433
+ return dxtToLocalServerTime(params.data.CreateTimestamp, "MM/dd/yy HH:mm");
22434
+ },
22435
+ },
22436
+ {
22437
+ field: "AssetName",
22438
+ headerName: "Asset",
22439
+ sortable: true,
22440
+ flex: 2,
22441
+ minWidth: 70,
22442
+ },
22443
+ {
22444
+ field: "Title",
22445
+ headerName: "Title",
22446
+ flex: 4,
22447
+ },
22448
+ {
22449
+ field: "SectionName",
22450
+ headerName: "Section",
22451
+ flex: 2,
22452
+ },
22453
+ {
22454
+ field: "Author",
22455
+ headerName: "Created By",
22456
+ flex: 2,
22457
+ }
22458
+ ], (showShiftCrew
22459
+ ? [
22460
+ {
22461
+ field: "Shift",
22462
+ headerName: "Shift",
22463
+ sortable: false,
22464
+ flex: 1,
22465
+ minWidth: 60,
22466
+ maxWidth: 60,
22467
+ },
22468
+ {
22469
+ field: "Crew",
22470
+ headerName: "Crew",
22471
+ sortable: false,
22472
+ flex: 1,
22473
+ minWidth: 60,
22474
+ maxWidth: 60,
22475
+ },
22476
+ ]
22477
+ : []), true), (allowAttachments
22478
+ ? [
22479
+ {
22480
+ field: "AttachmentCount",
22481
+ headerName: "",
22482
+ flex: 1,
22483
+ headerComponent: function () { return (React__default.createElement("div", { style: {
22484
+ display: "flex",
22485
+ alignItems: "center",
22486
+ justifyContent: "center",
22487
+ height: "100%",
22488
+ width: "100%",
22489
+ textAlign: "center",
22490
+ } },
22491
+ React__default.createElement(AttachFile, { style: { fontSize: 18, color: "#666" } }))); },
22492
+ cellRenderer: function (params) {
22493
+ var count = params.data.AttachmentCount || 0;
22494
+ if (count === 0) {
22495
+ return null;
22496
+ }
22497
+ return (React__default.createElement("div", { style: {
22498
+ display: "flex",
22499
+ alignItems: "center",
22500
+ height: "100%",
22501
+ justifyContent: "center",
22502
+ } },
22503
+ React__default.createElement(Chip, { icon: React__default.createElement(AttachFile, { style: { fontSize: 16 } }), label: count, size: "small", variant: "outlined", color: "primary" })));
22504
+ },
22505
+ },
22506
+ ]
22507
+ : []), true), [
22508
+ {
22509
+ field: "Content",
22510
+ headerName: "Content",
22511
+ hide: true,
22512
+ },
22513
+ {
22514
+ headerName: "",
22515
+ flex: 1,
22516
+ wrapText: false,
22517
+ autoHeight: false,
22518
+ cellRenderer: function (params) {
22519
+ return (React__default.createElement(Grid2, { container: true, style: {
22520
+ height: "100%",
22521
+ display: "flex",
22522
+ justifyContent: "center",
22523
+ alignItems: "center",
22524
+ } },
22525
+ React__default.createElement(Grid2, { size: { md: 12, xs: 12 }, style: {
22526
+ display: "flex",
22527
+ justifyContent: "center",
22528
+ alignItems: "center",
22529
+ } },
22530
+ React__default.createElement(Button, { fullWidth: true, onClick: function (e) {
22531
+ return showContextMenu(e, params.data, "logbookEntryContext");
22532
+ }, size: "small" },
22533
+ React__default.createElement(FormatListBulletedSharpIcon, { style: { height: "auto" }, color: "action" })))));
22534
+ },
22535
+ },
22536
+ ], false);
22537
+ return { columnDefs: columnDefs };
22538
+ };
22539
+
22540
+ var ENTRY_INITIAL_VALUES = {
22541
+ EntryId: 0,
22542
+ ShiftId: 0,
22543
+ AssetId: null,
22544
+ Title: "",
22545
+ Content: "",
22546
+ CreateTimestamp: new Date(),
22547
+ UpdateTimestamp: new Date(),
22548
+ LogEntryTypeCode: "S", // Default 'S'
22549
+ Shift: null,
22550
+ Crew: null,
22551
+ Author: null,
22552
+ UpdatedBy: null,
22553
+ AttachmentCount: 0,
22554
+ // Section defaults
22555
+ SectionId: null,
22556
+ SectionName: undefined,
22557
+ SectionFamilyName: undefined,
22558
+ WeighUp: undefined,
22559
+ BreakIn: undefined,
22560
+ SectionNotes: undefined,
22561
+ };
22562
+
22563
+ var RemoveEntryDialog = function (_a) {
22564
+ var entry = _a.entry, show = _a.show, onHide = _a.onHide;
22565
+ var navigate = useNavigate();
22566
+ var _b = useState(false), isSubmitLoading = _b[0], setIsSubmitLoading = _b[1];
22567
+ var _c = useState(""); _c[0]; var setSuccessMessage = _c[1];
22568
+ var _d = useState(""), error = _d[0], setError = _d[1];
22569
+ var handleCancel = function () {
22570
+ setIsSubmitLoading(false);
22571
+ onHide(false);
22572
+ };
22573
+ var queryClient = useQueryClient();
22574
+ var removeEntry = useMutation(deleteEntry, {
22575
+ onSuccess: function () { return __awaiter(void 0, void 0, void 0, function () {
22576
+ return __generator(this, function (_a) {
22577
+ switch (_a.label) {
22578
+ case 0: return [4 /*yield*/, queryClient.invalidateQueries({ queryKey: ["entries"] })];
22579
+ case 1:
22580
+ _a.sent();
22581
+ navigate("".concat(routeLogbookEntry), { replace: true });
22582
+ setSuccessMessage("The entry was deleted succesfully");
22583
+ onHide(true);
22584
+ return [2 /*return*/];
22585
+ }
22586
+ });
22587
+ }); },
22588
+ onError: function (error) {
22589
+ setError(error.message);
22590
+ },
22591
+ onSettled: function () { return setIsSubmitLoading(false); },
22592
+ });
22593
+ return (React__default.createElement(React__default.Fragment, null,
22594
+ React__default.createElement(Dialog$1, { fullWidth: true, maxWidth: "md", open: show, onClose: function () { return handleCancel(); }, disableEnforceFocus: true, sx: {
22595
+ "& .input-group-text": {
22596
+ display: "none",
22597
+ },
22598
+ "& .MuiDialogContent-dividers": {
22599
+ padding: 0,
22600
+ },
22601
+ } },
22602
+ React__default.createElement(DialogTitle$1, { id: "responsive-dialog-title", style: { paddingBottom: 0 } }, "WARNING"),
22603
+ React__default.createElement(DialogContent$1, null,
22604
+ React__default.createElement(DialogContentText, { style: { padding: 0, margin: 0 } },
22605
+ "Be careful, you are about to delete: ",
22606
+ React__default.createElement("b", null, entry === null || entry === void 0 ? void 0 : entry.Title),
22607
+ ". Once deleted you will not be able to recover this Entry. Are you sure you want to delete it?")),
22608
+ React__default.createElement(DialogActions$1, { style: { padding: "0 24px 16px" } },
22609
+ React__default.createElement(Button, { onClick: function () { return onHide(false); }, autoFocus: true, color: "inherit" }, "CANCEL"),
22610
+ React__default.createElement(Button, { autoFocus: true, color: "secondary", startIcon: isSubmitLoading && React__default.createElement(CircularProgress, { size: "1rem" }), onClick: function () { var _a; return removeEntry.mutate((_a = entry === null || entry === void 0 ? void 0 : entry.EntryId) !== null && _a !== void 0 ? _a : 0); } }, "Delete"))),
22611
+ React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
22612
+ };
22613
+
22614
+ var moment$5 = getMomentTz();
22615
+ var getSections = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
22616
+ var apiService, parameters, resp;
22617
+ var schema = _b.schema, sectionFamilyId = _b.sectionFamilyId, searchText = _b.searchText, signal = _b.signal;
22618
+ return __generator(this, function (_c) {
22619
+ switch (_c.label) {
22620
+ case 0:
22621
+ apiService = new MESApiService();
22622
+ parameters = [];
22623
+ if (sectionFamilyId) {
22624
+ parameters.push({ name: "SectionFamilyId", value: sectionFamilyId });
22625
+ }
22626
+ if (searchText) {
22627
+ parameters.push({ name: "SearchText", value: searchText });
22628
+ }
22629
+ return [4 /*yield*/, apiService.callV2("[".concat(schema, "].[GetSections]"), parameters, signal)];
22630
+ case 1:
22631
+ resp = _c.sent();
22632
+ if (resp.ok) {
22633
+ return [2 /*return*/, get(resp, "data.tables[0].rows", [])];
22634
+ }
22635
+ else {
22636
+ throw new Error(resp.message || "Error fetching sections");
22637
+ }
22638
+ }
22639
+ });
22640
+ }); };
22641
+ var getTopUsedSections = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
22642
+ var apiService, parameters, resp, rows;
22643
+ var schema = _b.schema, _c = _b.top, top = _c === void 0 ? 5 : _c, signal = _b.signal;
22644
+ return __generator(this, function (_d) {
22645
+ switch (_d.label) {
22646
+ case 0:
22647
+ apiService = new MESApiService();
22648
+ parameters = [{ name: "Top", value: top }];
22649
+ return [4 /*yield*/, apiService.callV2("[".concat(schema, "].[GetTopUsedSections]"), parameters, signal)];
22650
+ case 1:
22651
+ resp = _d.sent();
22652
+ if (resp.ok) {
22653
+ rows = get(resp, "data.tables[0].rows", []);
22654
+ rows = rows.map(function (section) { return (__assign(__assign({}, section), { LastUsedTimestamp: section.LastUsedTimestamp
22655
+ ? moment$5.utc(section.LastUsedTimestamp).toDate()
22656
+ : null })); });
22657
+ return [2 /*return*/, rows];
22658
+ }
22659
+ else {
22660
+ throw new Error(resp.message || "Error fetching top used sections");
22661
+ }
22662
+ }
22663
+ });
22664
+ }); };
22665
+
22666
+ var useSections = function (_a) {
22667
+ var _b = _a === void 0 ? {} : _a, _c = _b.searchText, searchText = _c === void 0 ? null : _c, _d = _b.enabled, enabled = _d === void 0 ? true : _d;
22668
+ var section = useLogbookSettings().section;
22669
+ var schema = section === null || section === void 0 ? void 0 : section.schema;
22670
+ return useQuery({
22671
+ queryKey: ["sections", schema, searchText],
22672
+ queryFn: function (_a) {
22673
+ var signal = _a.signal;
22674
+ return getSections({ schema: schema, searchText: searchText, signal: signal });
22675
+ },
22676
+ enabled: enabled,
22677
+ });
22678
+ };
22679
+
22680
+ var useTopSections = function (_a) {
22681
+ var _b = _a === void 0 ? {} : _a, _c = _b.top, top = _c === void 0 ? 5 : _c;
22682
+ var section = useLogbookSettings().section;
22683
+ var schema = section === null || section === void 0 ? void 0 : section.schema;
22684
+ return useQuery({
22685
+ queryKey: ["topSections", schema, top],
22686
+ queryFn: function (_a) {
22687
+ var signal = _a.signal;
22688
+ return getTopUsedSections({ schema: schema, top: top, signal: signal });
22689
+ },
22690
+ });
22691
+ };
22692
+
22693
+ var SectionSelector = function (_a) {
22694
+ var value = _a.value, onChange = _a.onChange, _b = _a.topSectionsCount, topSectionsCount = _b === void 0 ? 5 : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.label, label = _d === void 0 ? "Section" : _d;
22695
+ var _e = useState(false), open = _e[0], setOpen = _e[1];
22696
+ var _f = useState(""), inputValue = _f[0], setInputValue = _f[1];
22697
+ var _g = useTopSections({
22698
+ top: topSectionsCount,
22699
+ }), _h = _g.data, topSections = _h === void 0 ? [] : _h, loadingTop = _g.isLoading;
22700
+ var _j = useSections({
22701
+ searchText: inputValue || null,
22702
+ enabled: open,
22703
+ }), _k = _j.data, options = _k === void 0 ? [] : _k, loading = _j.isFetching;
22704
+ var handleChipClick = function (section) {
22705
+ if ((value === null || value === void 0 ? void 0 : value.SectionId) === section.SectionId) {
22706
+ onChange(null);
22707
+ }
22708
+ else {
22709
+ onChange(section);
22710
+ }
22711
+ };
22712
+ return (React__default.createElement(Box, { sx: {
22713
+ display: "flex",
22714
+ flexDirection: "row",
22715
+ alignItems: "center",
22716
+ gap: 1,
22717
+ flexWrap: "wrap",
22718
+ } },
22719
+ React__default.createElement(Autocomplete$1, { open: open, onOpen: function () { return setOpen(true); }, onClose: function () { return setOpen(false); }, value: value, onChange: function (_, newValue) { return onChange(newValue); }, inputValue: inputValue, onInputChange: function (_, newInputValue) { return setInputValue(newInputValue); }, options: options, loading: loading, disabled: disabled, getOptionLabel: function (option) { return option.SectionName; }, isOptionEqualToValue: function (option, value) {
22720
+ return option.SectionId === value.SectionId;
22721
+ }, sx: { minWidth: 120, maxWidth: 150 }, renderOption: function (props, option) { return (React__default.createElement(Box, __assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
22722
+ React__default.createElement(Typography$1, { fontWeight: 500 }, option.SectionName))); }, renderInput: function (params) { return (React__default.createElement(TextField, __assign({}, params, { label: label, placeholder: "####", size: "small", slotProps: {
22723
+ input: __assign(__assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
22724
+ loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
22725
+ params.InputProps.endAdornment)) }),
22726
+ } }))); } }),
22727
+ loadingTop ? (React__default.createElement(CircularProgress, { size: 14 })) : topSections.length > 0 ? (React__default.createElement(Box, { sx: {
22728
+ display: "flex",
22729
+ flexWrap: "wrap",
22730
+ gap: 0.5,
22731
+ alignItems: "center",
22732
+ } },
22733
+ React__default.createElement(Typography$1, { variant: "caption", color: "text.secondary", sx: { mr: 0.5 } }, "Top:"),
22734
+ topSections.map(function (section) { return (React__default.createElement(Chip, { key: section.SectionId, label: section.SectionName, size: "small", variant: (value === null || value === void 0 ? void 0 : value.SectionId) === section.SectionId ? "filled" : "outlined", color: (value === null || value === void 0 ? void 0 : value.SectionId) === section.SectionId ? "primary" : "default", onClick: function () { return handleChipClick(section); }, disabled: disabled, sx: {
22735
+ cursor: "pointer",
22736
+ height: 22,
22737
+ "& .MuiChip-label": { px: 1, fontSize: "0.75rem" },
22738
+ } })); }))) : null));
22739
+ };
22740
+
22741
+ var SectionMultiSelect = function (_a) {
22742
+ var value = _a.value, onChange = _a.onChange, _b = _a.topSectionsCount, topSectionsCount = _b === void 0 ? 5 : _b, _c = _a.disabled, disabled = _c === void 0 ? false : _c, _d = _a.label, label = _d === void 0 ? "Sections" : _d;
22743
+ var _e = useState(false), open = _e[0], setOpen = _e[1];
22744
+ var _f = useState(""), inputValue = _f[0], setInputValue = _f[1];
22745
+ var _g = useTopSections({
22746
+ top: topSectionsCount,
22747
+ }), _h = _g.data, topSections = _h === void 0 ? [] : _h, loadingTop = _g.isLoading;
22748
+ var _j = useSections({
22749
+ searchText: inputValue || null,
22750
+ enabled: open,
22751
+ }), _k = _j.data, options = _k === void 0 ? [] : _k, loading = _j.isFetching;
22752
+ var handleChipClick = function (section) {
22753
+ var isSelected = value.some(function (s) { return s.SectionId === section.SectionId; });
22754
+ if (isSelected) {
22755
+ onChange(value.filter(function (s) { return s.SectionId !== section.SectionId; }));
22756
+ }
22757
+ else {
22758
+ onChange(__spreadArray(__spreadArray([], value, true), [section], false));
22759
+ }
22760
+ };
22761
+ return (React__default.createElement(Box, { sx: {
22762
+ display: "flex",
22763
+ flexDirection: "row",
22764
+ alignItems: "center",
22765
+ gap: 1,
22766
+ flexWrap: "wrap",
22767
+ } },
22768
+ React__default.createElement(Autocomplete$1, { multiple: true, open: open, onOpen: function () { return setOpen(true); }, onClose: function () { return setOpen(false); }, value: value, onChange: function (_, newValue) { return onChange(newValue); }, inputValue: inputValue, onInputChange: function (_, newInputValue) { return setInputValue(newInputValue); }, options: options, loading: loading, disabled: disabled, getOptionLabel: function (option) { return option.SectionName; }, isOptionEqualToValue: function (option, val) {
22769
+ return option.SectionId === val.SectionId;
22770
+ }, limitTags: 2, size: "small", sx: { minWidth: 200, flex: 1 }, renderOption: function (props, option) { return (React__default.createElement(Box, __assign({ component: "li" }, props, { key: option.SectionId, sx: { display: "flex", justifyContent: "space-between" } }),
22771
+ React__default.createElement(Typography$1, { fontWeight: 500 }, option.SectionName))); }, renderInput: function (params) { return (React__default.createElement(TextField, __assign({}, params, { label: label, placeholder: value.length === 0 ? "All sections" : "", size: "small", slotProps: {
22772
+ input: __assign(__assign({}, params.InputProps), { endAdornment: (React__default.createElement(React__default.Fragment, null,
22773
+ loading ? (React__default.createElement(CircularProgress, { color: "inherit", size: 16 })) : null,
22774
+ params.InputProps.endAdornment)) }),
22775
+ } }))); } }),
22776
+ loadingTop ? (React__default.createElement(CircularProgress, { size: 14 })) : topSections.length > 0 ? (React__default.createElement(Box, { sx: {
22777
+ display: "flex",
22778
+ flexWrap: "wrap",
22779
+ gap: 0.5,
22780
+ alignItems: "center",
22781
+ } },
22782
+ React__default.createElement(Typography$1, { variant: "caption", color: "text.secondary", sx: { mr: 0.5 } }, "Top:"),
22783
+ topSections.map(function (section) {
22784
+ var isSelected = value.some(function (s) { return s.SectionId === section.SectionId; });
22785
+ return (React__default.createElement(Chip, { key: section.SectionId, label: section.SectionName, size: "small", variant: isSelected ? "filled" : "outlined", color: isSelected ? "primary" : "default", onClick: function () { return handleChipClick(section); }, disabled: disabled, sx: {
22786
+ cursor: "pointer",
22787
+ height: 22,
22788
+ "& .MuiChip-label": { px: 1, fontSize: "0.75rem" },
22789
+ } }));
22790
+ }))) : null));
22791
+ };
22792
+
22793
+ var upsertSectionEntry = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
22794
+ var apiService, parameters, resp;
22795
+ var entryId = _b.entryId, sectionId = _b.sectionId, weighUp = _b.weighUp, breakIn = _b.breakIn, notes = _b.notes;
22796
+ return __generator(this, function (_c) {
22797
+ switch (_c.label) {
22798
+ case 0:
22799
+ apiService = new MESApiService();
22800
+ parameters = [
22801
+ { name: "EntryId", value: entryId },
22802
+ { name: "SectionId", value: sectionId },
22803
+ ];
22804
+ if (weighUp !== undefined) {
22805
+ parameters.push({ name: "WeighUp", value: weighUp });
22806
+ }
22807
+ if (breakIn !== undefined) {
22808
+ parameters.push({ name: "BreakIn", value: breakIn });
22809
+ }
22810
+ if (notes !== undefined) {
22811
+ parameters.push({ name: "Notes", value: notes });
22812
+ }
22813
+ return [4 /*yield*/, apiService.callV2("[SWV].[UpsertLogSectionEntry]", parameters)];
22814
+ case 1:
22815
+ resp = _c.sent();
22816
+ if (resp.ok) {
22817
+ return [2 /*return*/, get(resp, "data.tables[0].rows[0]", null)];
22818
+ }
22819
+ else {
22820
+ throw new Error(resp.message || "Error upserting section entry");
22821
+ }
22822
+ }
22823
+ });
22824
+ }); };
22825
+
22826
+ var useEntrySubmission = function (_a) {
22827
+ var _b = _a === void 0 ? {} : _a, onSuccess = _b.onSuccess, onError = _b.onError, _c = _b.isNewEntry, isNewEntry = _c === void 0 ? false : _c, _d = _b.onHide, onHide = _d === void 0 ? function () { } : _d;
22828
+ var _e = useState(false), isSubmitLoading = _e[0], setIsSubmitLoading = _e[1];
22829
+ var _f = useState(false), showConfirmationDialog = _f[0], setShowConfirmationDialog = _f[1];
22830
+ var _g = useState(null), pendingSubmitData = _g[0], setPendingSubmitData = _g[1];
22831
+ var submit = useMutation(upsertEntry, {
22832
+ onSuccess: function (entry) { return __awaiter(void 0, void 0, void 0, function () {
22833
+ return __generator(this, function (_a) {
22834
+ if (entry && entry.EntryId) {
22835
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(entry);
22836
+ }
22837
+ else {
22838
+ console.error("No EntryId received from API response", entry);
22839
+ onError === null || onError === void 0 ? void 0 : onError(new Error("Failed to get entry ID from server response"));
22840
+ }
22841
+ return [2 /*return*/];
22842
+ });
22843
+ }); },
22844
+ onError: function (error) {
22845
+ onError === null || onError === void 0 ? void 0 : onError(error);
22846
+ },
22847
+ onSettled: function () { return setIsSubmitLoading(false); },
22848
+ });
22849
+ var submitEntry = function (formData) { return __awaiter(void 0, void 0, void 0, function () {
22850
+ var submissionData;
22851
+ var _a;
22852
+ return __generator(this, function (_b) {
22853
+ switch (_b.label) {
22854
+ case 0:
22855
+ setIsSubmitLoading(true);
22856
+ submissionData = __assign({}, formData);
22857
+ if (isNewEntry && !submissionData.createTimestamp) {
22858
+ submissionData.createTimestamp = new Date();
22859
+ }
22860
+ if (!(!submissionData.shiftId || submissionData.isForOtherShift)) return [3 /*break*/, 1];
22861
+ setPendingSubmitData(submissionData);
22862
+ setShowConfirmationDialog(true);
22863
+ setIsSubmitLoading(false);
22864
+ return [3 /*break*/, 3];
22865
+ case 1: return [4 /*yield*/, submit.mutate({
22866
+ assetId: submissionData.assetId,
22867
+ shiftId: submissionData.shiftId,
22868
+ entryId: submissionData.entryId,
22869
+ title: submissionData.title,
22870
+ content: submissionData.content,
22871
+ author: (_a = submissionData.author) !== null && _a !== void 0 ? _a : "",
22872
+ createTimestamp: submissionData.createTimestamp,
22873
+ })];
22874
+ case 2:
22875
+ _b.sent();
22876
+ _b.label = 3;
22877
+ case 3: return [2 /*return*/];
22878
+ }
22879
+ });
22880
+ }); };
22881
+ var handleConfirmationClose = function (value) {
22882
+ var _a;
22883
+ setShowConfirmationDialog(false);
22884
+ if (value === "OK" && pendingSubmitData) {
22885
+ onHide();
22886
+ submit.mutate({
22887
+ assetId: pendingSubmitData.assetId,
22888
+ shiftId: pendingSubmitData.shiftId,
22889
+ entryId: pendingSubmitData.entryId,
22890
+ title: pendingSubmitData.title,
22891
+ content: pendingSubmitData.content,
22892
+ author: (_a = pendingSubmitData.author) !== null && _a !== void 0 ? _a : "",
22893
+ createTimestamp: pendingSubmitData.createTimestamp,
22894
+ });
22895
+ }
22896
+ setPendingSubmitData(null);
22897
+ };
22898
+ return {
22899
+ submitEntry: submitEntry,
22900
+ isSubmitLoading: isSubmitLoading,
22901
+ showConfirmationDialog: showConfirmationDialog,
22902
+ pendingSubmitData: pendingSubmitData,
22903
+ handleConfirmationClose: handleConfirmationClose,
22904
+ mutation: submit,
22905
+ };
22906
+ };
22907
+
22908
+ var DeleteAttachmentConfirmationDialog = function (_a) {
22909
+ var open = _a.open, attachmentName = _a.attachmentName, onClose = _a.onClose, _b = _a.isDeleting, isDeleting = _b === void 0 ? false : _b;
22910
+ var _c = useState(false), isClosing = _c[0], setIsClosing = _c[1];
22911
+ var handleCancel = function () {
22912
+ if (isClosing)
22913
+ return;
22914
+ onClose(false);
22915
+ };
22916
+ var handleConfirm = function () {
22917
+ if (isClosing)
22918
+ return;
22919
+ setIsClosing(true);
22920
+ onClose(true);
22921
+ };
22922
+ return (React__default.createElement(Dialog$1, { open: open, onClose: handleCancel, "aria-labelledby": "delete-attachment-dialog-title", "aria-describedby": "delete-attachment-dialog-description" },
22923
+ React__default.createElement(DialogTitle$1, { id: "delete-attachment-dialog-title" }, "Delete Attachment"),
22924
+ React__default.createElement(DialogContent$1, null,
22925
+ React__default.createElement(DialogContentText, { id: "delete-attachment-dialog-description" },
22926
+ "Are you sure you want to delete ",
22927
+ React__default.createElement("b", null, attachmentName),
22928
+ "? This action cannot be undone.")),
22929
+ React__default.createElement(DialogActions$1, null,
22930
+ React__default.createElement(Button, { onClick: handleCancel, color: "inherit", disabled: isClosing }, "Cancel"),
22931
+ React__default.createElement(Button, { onClick: handleConfirm, color: "secondary", variant: "contained", disabled: isClosing, startIcon: isDeleting && React__default.createElement(CircularProgress, { size: "1rem" }) }, "Delete"))));
22932
+ };
22933
+
22934
+ var AttachmentModal = function (_a) {
22935
+ var open = _a.open, onClose = _a.onClose, entryId = _a.entryId, isEditing = _a.isEditing, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted;
22936
+ var queryClient = useQueryClient();
22937
+ var api = new MESApiService();
22938
+ var _b = useState(null), error = _b[0], setError = _b[1];
22939
+ var _c = useState([]), uploadingFiles = _c[0], setUploadingFiles = _c[1];
22940
+ var _d = useState(entryId), currentEntryId = _d[0], setCurrentEntryId = _d[1];
22941
+ var _e = useState(false), isSubmittingEntry = _e[0], setIsSubmittingEntry = _e[1];
22942
+ var _f = useState(false), showDeleteConfirmation = _f[0], setShowDeleteConfirmation = _f[1];
22943
+ var _g = useState(null), attachmentToDelete = _g[0], setAttachmentToDelete = _g[1];
22944
+ var pendingFilesRef = useRef([]);
22945
+ // Entry submission hook for background saves
22946
+ var _h = useEntrySubmission({
22947
+ onSuccess: function (entry) {
22948
+ setIsSubmittingEntry(false);
22949
+ if (entry === null || entry === void 0 ? void 0 : entry.EntryId) {
22950
+ setCurrentEntryId(entry.EntryId);
22951
+ onEntrySubmitted === null || onEntrySubmitted === void 0 ? void 0 : onEntrySubmitted(entry.EntryId, entry);
22952
+ // If there are pending files, upload them now with the new entry ID
22953
+ if (pendingFilesRef.current.length > 0) {
22954
+ var filesToUpload = __spreadArray([], pendingFilesRef.current, true);
22955
+ pendingFilesRef.current = [];
22956
+ // Call upload directly with the new entry ID instead of relying on state
22957
+ uploadFilesWithEntryId(filesToUpload, entry.EntryId);
22958
+ }
22959
+ }
22960
+ },
22961
+ onError: function (error) {
22962
+ setIsSubmittingEntry(false);
22963
+ setError(error.message);
22964
+ pendingFilesRef.current = []; // Clear pending files on error
22965
+ },
22966
+ isNewEntry: !entryId || entryId <= 0,
22967
+ }), submitEntry = _h.submitEntry, isSubmitLoading = _h.isSubmitLoading;
22968
+ // Sync entryId prop with currentEntryId state
22969
+ useEffect(function () {
22970
+ setCurrentEntryId(entryId);
22971
+ }, [entryId]);
22972
+ // Query for fetching attachments
22973
+ var _j = useQuery({
22974
+ queryKey: ["entryAttachments", currentEntryId],
22975
+ queryFn: function () { return getEntryAttachments(currentEntryId); },
22976
+ enabled: !!currentEntryId && currentEntryId > 0,
22977
+ }), _k = _j.data, attachments = _k === void 0 ? [] : _k, isLoading = _j.isLoading, fetchError = _j.error;
22978
+ // Mutations
22979
+ var uploadMutation = useMutation(upsertEntryAttachment, {
22980
+ onSuccess: function () {
22981
+ queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
22982
+ queryClient.invalidateQueries(["entries"]);
22983
+ queryClient.invalidateQueries(["entriesReport"]);
22984
+ },
22985
+ onError: function (error) {
22986
+ setError(error.message);
22987
+ },
22988
+ });
22989
+ var deleteMutation = useMutation(function (_a) {
22990
+ var entryAttachmentId = _a.entryAttachmentId, uploadFileId = _a.uploadFileId;
22991
+ return deleteEntryAttachment(entryAttachmentId, uploadFileId);
22992
+ }, {
22993
+ onSuccess: function () {
22994
+ queryClient.invalidateQueries(["entryAttachments", currentEntryId]);
22995
+ queryClient.invalidateQueries(["entries"]);
22996
+ queryClient.invalidateQueries(["entriesReport"]);
22997
+ },
22998
+ onError: function (error) {
22999
+ setError(error.message);
23000
+ },
23001
+ });
23002
+ // Function to upload files with a specific entry ID (used after background submission)
23003
+ var uploadFilesWithEntryId = useCallback(function (files, targetEntryId) { return __awaiter(void 0, void 0, void 0, function () {
23004
+ var _i, files_1, file, uploadResponse, uploadFileId, attachmentURL, error_1;
23005
+ var _a;
23006
+ return __generator(this, function (_b) {
23007
+ switch (_b.label) {
23008
+ case 0:
23009
+ setUploadingFiles(files);
23010
+ setError(null);
23011
+ _b.label = 1;
23012
+ case 1:
23013
+ _b.trys.push([1, 7, 8, 9]);
23014
+ _i = 0, files_1 = files;
23015
+ _b.label = 2;
23016
+ case 2:
23017
+ if (!(_i < files_1.length)) return [3 /*break*/, 6];
23018
+ file = files_1[_i];
23019
+ return [4 /*yield*/, api.uploadFiles([file], "logbook")];
23020
+ case 3:
23021
+ uploadResponse = _b.sent();
23022
+ if (!((_a = uploadResponse === null || uploadResponse === void 0 ? void 0 : uploadResponse.result) === null || _a === void 0 ? void 0 : _a[0])) return [3 /*break*/, 5];
23023
+ uploadFileId = uploadResponse.result[0].UploadFileId;
23024
+ attachmentURL = uploadResponse.result[0].URL;
23025
+ // Then create the attachment record
23026
+ return [4 /*yield*/, uploadMutation.mutateAsync({
23027
+ entryId: targetEntryId,
23028
+ uploadFileId: uploadFileId,
23029
+ attachmentName: file.name,
23030
+ attachmentURL: attachmentURL,
23031
+ })];
23032
+ case 4:
23033
+ // Then create the attachment record
23034
+ _b.sent();
23035
+ // Invalidate queries for the specific entry and the main entries lists
23036
+ queryClient.invalidateQueries(["entryAttachments", targetEntryId]);
23037
+ queryClient.invalidateQueries(["entries"]);
23038
+ queryClient.invalidateQueries(["entriesReport"]);
23039
+ _b.label = 5;
23040
+ case 5:
23041
+ _i++;
23042
+ return [3 /*break*/, 2];
23043
+ case 6: return [3 /*break*/, 9];
23044
+ case 7:
23045
+ error_1 = _b.sent();
23046
+ setError("Failed to upload files: ".concat(error_1));
23047
+ return [3 /*break*/, 9];
23048
+ case 8:
23049
+ setUploadingFiles([]);
23050
+ return [7 /*endfinally*/];
23051
+ case 9: return [2 /*return*/];
23052
+ }
23053
+ });
23054
+ }); }, [api, uploadMutation, queryClient]);
23055
+ var handleFileUpload = useCallback(function (files) { return __awaiter(void 0, void 0, void 0, function () {
23056
+ var targetEntryId, error_2, _i, files_2, file, uploadResponse, uploadFileId, attachmentURL, error_3;
23057
+ var _a;
23058
+ return __generator(this, function (_b) {
23059
+ switch (_b.label) {
23060
+ case 0:
23061
+ targetEntryId = currentEntryId;
23062
+ if (!((!targetEntryId || targetEntryId <= 0) &&
23063
+ entryData &&
23064
+ !isSubmittingEntry)) return [3 /*break*/, 4];
23065
+ _b.label = 1;
23066
+ case 1:
23067
+ _b.trys.push([1, 3, , 4]);
23068
+ setError(null);
23069
+ setIsSubmittingEntry(true);
23070
+ // Store files to upload after entry is created
23071
+ pendingFilesRef.current = files;
23072
+ return [4 /*yield*/, submitEntry(entryData)];
23073
+ case 2:
23074
+ _b.sent();
23075
+ // The files will be uploaded in the success callback
23076
+ return [2 /*return*/];
23077
+ case 3:
23078
+ error_2 = _b.sent();
23079
+ setIsSubmittingEntry(false);
23080
+ setError("Failed to save entry before uploading files: ".concat(error_2));
23081
+ pendingFilesRef.current = [];
23082
+ return [2 /*return*/];
23083
+ case 4:
23084
+ if (!targetEntryId || targetEntryId <= 0) {
23085
+ setError("Entry must be saved before adding attachments");
23086
+ return [2 /*return*/];
23087
+ }
23088
+ setUploadingFiles(files);
23089
+ setError(null);
23090
+ _b.label = 5;
23091
+ case 5:
23092
+ _b.trys.push([5, 11, 12, 13]);
23093
+ _i = 0, files_2 = files;
23094
+ _b.label = 6;
23095
+ case 6:
23096
+ if (!(_i < files_2.length)) return [3 /*break*/, 10];
23097
+ file = files_2[_i];
23098
+ return [4 /*yield*/, api.uploadFiles([file], "logbook")];
23099
+ case 7:
23100
+ uploadResponse = _b.sent();
23101
+ if (!((_a = uploadResponse === null || uploadResponse === void 0 ? void 0 : uploadResponse.result) === null || _a === void 0 ? void 0 : _a[0])) return [3 /*break*/, 9];
23102
+ uploadFileId = uploadResponse.result[0].UploadFileId;
23103
+ attachmentURL = uploadResponse.result[0].URL;
23104
+ // Then create the attachment record
23105
+ return [4 /*yield*/, uploadMutation.mutateAsync({
23106
+ entryId: targetEntryId,
23107
+ uploadFileId: uploadFileId,
23108
+ attachmentName: file.name,
23109
+ attachmentURL: attachmentURL,
23110
+ })];
23111
+ case 8:
23112
+ // Then create the attachment record
23113
+ _b.sent();
23114
+ _b.label = 9;
23115
+ case 9:
23116
+ _i++;
23117
+ return [3 /*break*/, 6];
23118
+ case 10: return [3 /*break*/, 13];
23119
+ case 11:
23120
+ error_3 = _b.sent();
23121
+ setError("Failed to upload files: ".concat(error_3));
23122
+ return [3 /*break*/, 13];
23123
+ case 12:
23124
+ setUploadingFiles([]);
23125
+ return [7 /*endfinally*/];
23126
+ case 13: return [2 /*return*/];
23127
+ }
23128
+ });
23129
+ }); }, [
23130
+ currentEntryId,
23131
+ entryData,
23132
+ api,
23133
+ uploadMutation,
23134
+ submitEntry,
23135
+ isSubmittingEntry,
23136
+ ]);
23137
+ var handleDeleteAttachment = function (attachmentId, uploadFileId, attachmentName) {
23138
+ setAttachmentToDelete({
23139
+ id: attachmentId,
23140
+ uploadFileId: uploadFileId,
23141
+ name: attachmentName,
23142
+ });
23143
+ setShowDeleteConfirmation(true);
23144
+ };
23145
+ var handleDeleteConfirmation = function (confirmed) {
23146
+ setShowDeleteConfirmation(false);
23147
+ if (confirmed && attachmentToDelete) {
23148
+ deleteMutation.mutate({
23149
+ entryAttachmentId: attachmentToDelete.id,
23150
+ uploadFileId: attachmentToDelete.uploadFileId,
23151
+ });
23152
+ }
23153
+ setAttachmentToDelete(null);
23154
+ };
23155
+ // This function is no longer needed as we're using direct anchor links
23156
+ // Keeping it as a reference in case it's needed elsewhere
23157
+ /*
23158
+ const handleDownloadAttachment = (attachment: EntryAttachment) => {
23159
+ // Use the URL property with proper encoding
23160
+ const encodedUrl = attachment.URL;
23161
+ const link = document.createElement("a");
23162
+ link.href = encodedUrl;
23163
+ link.download = attachment.AttachmentName;
23164
+ link.target = "_blank";
23165
+ document.body.appendChild(link);
23166
+ link.click();
23167
+ document.body.removeChild(link);
23168
+ };
23169
+ */
23170
+ var onDrop = useCallback(function (acceptedFiles) {
23171
+ if (isEditing) {
23172
+ handleFileUpload(acceptedFiles);
23173
+ }
23174
+ }, [handleFileUpload, isEditing]);
23175
+ var _l = useDropzone({
23176
+ onDrop: onDrop,
23177
+ disabled: !isEditing,
23178
+ multiple: true,
23179
+ }), getRootProps = _l.getRootProps, getInputProps = _l.getInputProps, isDragActive = _l.isDragActive;
23180
+ var isUploading = uploadingFiles.length > 0 ||
23181
+ uploadMutation.isLoading ||
23182
+ isSubmitLoading ||
23183
+ isSubmittingEntry;
23184
+ return (React__default.createElement(React__default.Fragment, null,
23185
+ React__default.createElement(Dialog$1, { open: open, onClose: onClose, maxWidth: "md", fullWidth: true, "aria-labelledby": "attachment-dialog-title" },
23186
+ React__default.createElement(DialogTitle$1, { id: "attachment-dialog-title" },
23187
+ "Attachments (",
23188
+ attachments.length,
23189
+ ")"),
23190
+ React__default.createElement(DialogContent$1, { dividers: true },
23191
+ isEditing ? (React__default.createElement(Box, { mb: 2 },
23192
+ React__default.createElement(Box, __assign({}, getRootProps(), { sx: {
23193
+ border: function (theme) { return "2px dashed ".concat(theme.palette.primary.main); },
23194
+ borderRadius: function (theme) { return theme.shape.borderRadius; },
23195
+ padding: function (theme) { return theme.spacing(3); },
23196
+ textAlign: "center",
23197
+ cursor: "pointer",
23198
+ marginBottom: function (theme) { return theme.spacing(2); },
23199
+ borderColor: function (theme) {
23200
+ return isDragActive
23201
+ ? theme.palette.secondary.main
23202
+ : theme.palette.primary.main;
23203
+ },
23204
+ backgroundColor: function (theme) {
23205
+ return isDragActive
23206
+ ? theme.palette.action.selected
23207
+ : theme.palette.background.default;
23208
+ },
23209
+ "&:hover": {
23210
+ backgroundColor: function (theme) { return theme.palette.action.hover; },
23211
+ },
23212
+ } }),
23213
+ React__default.createElement("input", __assign({}, getInputProps())),
23214
+ React__default.createElement(CloudUpload, { sx: {
23215
+ fontSize: 48,
23216
+ color: function (theme) { return theme.palette.primary.main; },
23217
+ marginBottom: function (theme) { return theme.spacing(1); },
23218
+ } }),
23219
+ React__default.createElement(Typography$1, { variant: "h6", gutterBottom: true }, isDragActive
23220
+ ? "Drop files here..."
23221
+ : "Drag & drop files here, or click to select"),
23222
+ React__default.createElement(Typography$1, { variant: "body2", color: "textSecondary" }, "All file types are supported")))) : null,
23223
+ !currentEntryId || currentEntryId <= 0 ? (isEditing && entryData ? (React__default.createElement(Typography$1, { variant: "body1", color: "textSecondary", align: "center" }, isSubmitLoading || isSubmittingEntry
23224
+ ? "Saving entry..."
23225
+ : "Upload files to automatically save and attach to this entry")) : (React__default.createElement(Typography$1, { variant: "body1", color: "textSecondary", align: "center" }, "Save the entry first to add attachments"))) : isLoading ? (React__default.createElement("div", { style: {
23226
+ display: "flex",
23227
+ justifyContent: "center",
23228
+ alignItems: "center",
23229
+ minHeight: 100,
23230
+ } },
23231
+ React__default.createElement(CircularProgress, null))) : attachments.length === 0 ? (React__default.createElement(Typography$1, { variant: "body1", color: "textSecondary", align: "center" }, "No attachments yet")) : (React__default.createElement(List, { sx: {
23232
+ maxHeight: 300,
23233
+ overflow: "auto",
23234
+ } }, attachments.map(function (attachment) { return (React__default.createElement(ListItem, { key: attachment.EntryAttachmentId, sx: {
23235
+ border: function (theme) { return "1px solid ".concat(theme.palette.divider); },
23236
+ borderRadius: function (theme) { return theme.shape.borderRadius; },
23237
+ marginBottom: function (theme) { return theme.spacing(1); },
23238
+ } },
23239
+ React__default.createElement(ListItemIcon, null,
23240
+ React__default.createElement(AttachFile, null)),
23241
+ React__default.createElement(ListItemText, { primary: attachment.AttachmentName, secondary: "Added by ".concat(attachment.CreatedBy, " on ").concat(attachment.CreationTime.toLocaleDateString()) }),
23242
+ React__default.createElement(ListItemSecondaryAction, null,
23243
+ React__default.createElement("a", { href: attachment.URL, target: "_blank", rel: "noopener noreferrer", title: "Download", style: {
23244
+ display: "inline-flex",
23245
+ padding: 8,
23246
+ borderRadius: "50%",
23247
+ color: "inherit",
23248
+ textDecoration: "none",
23249
+ }, className: "MuiButtonBase-root MuiIconButton-root" },
23250
+ React__default.createElement(GetApp, null)),
23251
+ isEditing && (React__default.createElement(IconButton$1, { edge: "end", onClick: function () {
23252
+ return handleDeleteAttachment(attachment.EntryAttachmentId, attachment.UploadFileId, attachment.AttachmentName);
23253
+ }, title: "Delete", disabled: deleteMutation.isLoading },
23254
+ React__default.createElement(Delete, null)))))); }))),
23255
+ isUploading && (React__default.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center", mt: 2 },
23256
+ React__default.createElement(CircularProgress, { size: 20 }),
23257
+ React__default.createElement(Typography$1, { variant: "body2", style: { marginLeft: 8 } },
23258
+ "Uploading ",
23259
+ uploadingFiles.length,
23260
+ " file(s)...")))),
23261
+ React__default.createElement(DialogActions$1, null,
23262
+ React__default.createElement(Button, { onClick: onClose, color: "primary" }, "Close"))),
23263
+ React__default.createElement(DeleteAttachmentConfirmationDialog, { open: showDeleteConfirmation, attachmentName: (attachmentToDelete === null || attachmentToDelete === void 0 ? void 0 : attachmentToDelete.name) || "", onClose: handleDeleteConfirmation, isDeleting: deleteMutation.isLoading }),
23264
+ React__default.createElement(ErrorModal, { error: error || (fetchError === null || fetchError === void 0 ? void 0 : fetchError.message), onHide: function () { return setError(null); } })));
23265
+ };
23266
+
23267
+ var AttachmentPlugin = /** @class */ (function (_super) {
23268
+ __extends(AttachmentPlugin, _super);
23269
+ function AttachmentPlugin() {
23270
+ return _super !== null && _super.apply(this, arguments) || this;
23271
+ }
23272
+ AttachmentPlugin.prototype.render = function () {
23273
+ var _a = this.props
23274
+ .config, attachmentCount = _a.attachmentCount, onAttachmentClick = _a.onAttachmentClick;
23275
+ return (React__default.createElement("span", { className: "button button-type-attachment", title: "Attachments (".concat(attachmentCount, ")"), onClick: onAttachmentClick, style: {
23276
+ display: "inline-flex",
23277
+ alignItems: "center",
23278
+ padding: "4px 8px",
23279
+ cursor: "pointer",
23280
+ borderRadius: "4px",
23281
+ backgroundColor: attachmentCount > 0 ? "#e3f2fd" : "transparent",
23282
+ border: attachmentCount > 0 ? "1px solid #2196f3" : "1px solid transparent",
23283
+ color: attachmentCount > 0 ? "#1976d2" : "#666",
23284
+ fontSize: "0.75rem",
23285
+ fontWeight: attachmentCount > 0 ? 600 : 400,
23286
+ transition: "all 0.2s ease-in-out",
23287
+ }, onMouseEnter: function (e) {
23288
+ e.currentTarget.style.backgroundColor = "#e3f2fd";
23289
+ e.currentTarget.style.borderColor = "#2196f3";
23290
+ }, onMouseLeave: function (e) {
23291
+ if (attachmentCount === 0) {
23292
+ e.currentTarget.style.backgroundColor = "transparent";
23293
+ e.currentTarget.style.borderColor = "transparent";
23294
+ }
23295
+ } },
23296
+ React__default.createElement(AttachFile, { style: {
23297
+ fontSize: 16,
23298
+ marginRight: 4,
23299
+ color: attachmentCount > 0 ? "#1976d2" : "#666",
23300
+ } }),
23301
+ "Attachments (",
23302
+ attachmentCount,
23303
+ ")"));
23304
+ };
23305
+ AttachmentPlugin.pluginName = "attachment";
23306
+ AttachmentPlugin.align = "left";
23307
+ AttachmentPlugin.defaultConfig = {
23308
+ start: 0,
23309
+ end: 0,
23310
+ };
23311
+ return AttachmentPlugin;
23312
+ }(PluginComponent));
23313
+
23314
+ var ContentInput = function (_a) {
23315
+ var value = _a.value, onChange = _a.onChange, isEditing = _a.isEditing, UpdateTimestamp = _a.UpdateTimestamp, UpdatedBy = _a.UpdatedBy, isNewEntry = _a.isNewEntry, entryId = _a.entryId, entryData = _a.entryData, onEntrySubmitted = _a.onEntrySubmitted, _b = _a.allowAttachments, allowAttachments = _b === void 0 ? false : _b;
23316
+ var mdParser = new MarkdownIt();
23317
+ var api = new MESApiService();
23318
+ var urlEntryId = useParams().entryId;
23319
+ var _c = useState(0), key = _c[0], setKey = _c[1];
23320
+ var _d = useState(null), error = _d[0], setError = _d[1];
23321
+ var _e = useState(false), attachmentModalOpen = _e[0], setAttachmentModalOpen = _e[1];
23322
+ // Use URL entryId as fallback when form entryId is not available yet
23323
+ var effectiveEntryId = entryId ||
23324
+ (urlEntryId && urlEntryId !== "new" ? parseInt(urlEntryId) : null);
23325
+ // Query for fetching attachment count
23326
+ var _f = useQuery({
23327
+ queryKey: ["entryAttachments", effectiveEntryId],
23328
+ queryFn: function () { return getEntryAttachments(effectiveEntryId); },
23329
+ enabled: !!effectiveEntryId && effectiveEntryId > 0,
23330
+ retry: 1,
23331
+ onError: function (err) {
23332
+ console.error("Failed to fetch attachments:", err);
23333
+ },
23334
+ }), _g = _f.data, attachments = _g === void 0 ? [] : _g, attachmentError = _f.error;
23335
+ var attachmentCount = attachments.length;
23336
+ var handleChange = function (_a) {
23337
+ var text = _a.text;
23338
+ onChange(text);
23339
+ };
23340
+ var onImageUpload = function (files) { return __awaiter(void 0, void 0, void 0, function () {
23341
+ var res;
23342
+ var _a;
23343
+ return __generator(this, function (_b) {
23344
+ switch (_b.label) {
23345
+ case 0:
23346
+ _b.trys.push([0, 2, , 3]);
23347
+ setError(null);
23348
+ return [4 /*yield*/, api.uploadFiles(files, "logbook")];
23349
+ case 1:
23350
+ res = _b.sent();
23351
+ if (res) {
23352
+ return [2 /*return*/, (_a = res.result[0]) === null || _a === void 0 ? void 0 : _a.URL];
23353
+ }
23354
+ return [3 /*break*/, 3];
23355
+ case 2:
23356
+ _b.sent();
23357
+ setError("Failed to upload files");
23358
+ return [2 /*return*/, ""];
23359
+ case 3: return [2 /*return*/];
23360
+ }
23361
+ });
23362
+ }); };
23363
+ useEffect(function () {
23364
+ setKey(function (prevKey) { return prevKey + 1; });
23365
+ }, [isEditing, attachmentCount]);
23366
+ // Register the attachment plugin
23367
+ useEffect(function () {
23368
+ MdEditor.use(AttachmentPlugin, {
23369
+ attachmentCount: attachmentCount,
23370
+ onAttachmentClick: function () {
23371
+ if (entryData.title && entryData.author) {
23372
+ setAttachmentModalOpen(true);
23373
+ }
23374
+ else {
23375
+ setError("Title and Author are required");
23376
+ }
23377
+ },
23378
+ });
23379
+ }, [attachmentCount, entryData.title, entryData.author]);
23380
+ return (React__default.createElement(React__default.Fragment, null,
23381
+ React__default.createElement(Box, { sx: {
23382
+ height: "100%",
23383
+ width: "100%",
23384
+ overflow: "hidden",
23385
+ display: "flex",
23386
+ flexDirection: "column",
23387
+ "& .MuiInput-underline:before": {
23388
+ borderBottom: "none",
23389
+ },
23390
+ "& .MuiInput-underline:after": {
23391
+ borderBottom: "none",
23392
+ },
23393
+ "& .MuiInput-underline:hover:not(.Mui-disabled):before": {
23394
+ borderBottom: "none",
23395
+ },
23396
+ } },
23397
+ React__default.createElement(Grid2, { sx: {
23398
+ flexGrow: 1,
23399
+ display: "flex",
23400
+ flexDirection: "column",
23401
+ overflow: "hidden",
23402
+ } },
23403
+ React__default.createElement(Box, { sx: {
23404
+ height: "100%",
23405
+ "& .rc-md-editor": {
23406
+ height: "100%",
23407
+ },
23408
+ "& .rc-md-navigation": {
23409
+ backgroundColor: function (theme) { return theme.palette.background.paper; },
23410
+ },
23411
+ "& .rc-md-editor, & .section-container": {
23412
+ height: "100%",
23413
+ },
23414
+ } },
23415
+ React__default.createElement(MdEditor, { key: key, style: { height: "100%", width: "100%" }, value: value || "", renderHTML: function (text) { return mdParser.render(text || ""); }, onChange: handleChange, view: {
23416
+ menu: allowAttachments ? true : isEditing, // Always show menu to display attachment button (if allowed)
23417
+ md: isEditing ? true : false,
23418
+ html: !isEditing,
23419
+ }, plugins: isEditing
23420
+ ? [
23421
+ "header",
23422
+ "font-bold",
23423
+ "font-italic",
23424
+ "font-underline",
23425
+ "font-strikethrough",
23426
+ "list-unordered",
23427
+ "list-ordered",
23428
+ "block-quote",
23429
+ "block-wrap",
23430
+ "block-code-inline",
23431
+ "block-code-block",
23432
+ "table",
23433
+ "image",
23434
+ "link",
23435
+ "clear",
23436
+ "logger",
23437
+ "mode-toggle",
23438
+ "full-screen",
23439
+ "tab-insert",
23440
+ allowAttachments ? "attachment" : "",
23441
+ ]
23442
+ : allowAttachments
23443
+ ? [
23444
+ "attachment", // Only show attachment button in preview mode and with attachments allowed
23445
+ ]
23446
+ : [], config: {
23447
+ attachment: allowAttachments
23448
+ ? {
23449
+ attachmentCount: attachmentCount,
23450
+ onAttachmentClick: function () {
23451
+ if (entryData.title && entryData.author) {
23452
+ setAttachmentModalOpen(true);
23453
+ }
23454
+ else {
23455
+ setError("Title and Author are required");
23456
+ }
23457
+ },
23458
+ }
23459
+ : null,
23460
+ }, autoFocus: !isNewEntry, onImageUpload: function (file) { return __awaiter(void 0, void 0, void 0, function () {
23461
+ var markdownImage;
23462
+ return __generator(this, function (_a) {
23463
+ switch (_a.label) {
23464
+ case 0: return [4 /*yield*/, onImageUpload([file])];
23465
+ case 1:
23466
+ markdownImage = _a.sent();
23467
+ return [2 /*return*/, markdownImage];
23468
+ }
23469
+ });
23470
+ }); } }))),
23471
+ (UpdatedBy === null || UpdatedBy === void 0 ? void 0 : UpdatedBy.length) > 0 && (React__default.createElement(Box, { sx: {
23472
+ backgroundColor: function (theme) { return theme.palette.background.paper; },
23473
+ borderTop: function (theme) { return "0px solid ".concat(theme.palette.divider); },
23474
+ paddingLeft: 10,
23475
+ } },
23476
+ React__default.createElement(TextField, { variant: "standard", disabled: true, value: "This entry was updated on ".concat(dxtToLocalServerTime(UpdateTimestamp, "MM/dd/yy hh:mm a"), " by ").concat(UpdatedBy), fullWidth: true, margin: "none", autoComplete: "off", InputProps: {
23477
+ style: {
23478
+ fontSize: "0.7rem",
23479
+ },
23480
+ disableUnderline: true,
23481
+ }, InputLabelProps: {
23482
+ style: {
23483
+ fontSize: "0.7rem",
23484
+ },
23485
+ } })))),
23486
+ React__default.createElement(AttachmentModal, { open: attachmentModalOpen, onClose: function () { return setAttachmentModalOpen(false); }, entryId: effectiveEntryId, isEditing: isEditing, entryData: entryData, onEntrySubmitted: onEntrySubmitted }),
23487
+ React__default.createElement(ErrorModal, { error: error || (attachmentError === null || attachmentError === void 0 ? void 0 : attachmentError.message), onHide: function () { return setError(""); } })));
23488
+ };
23489
+
23490
+ var moment$4 = getMomentTz();
23491
+ var EntryViewer$1 = function (_a) {
23492
+ var entry = _a.entry, show = _a.show, onChangeShow = _a.onChangeShow, onHide = _a.onHide, preselectedAssetId = _a.preselectedAssetId, withAssetFilter = _a.withAssetFilter, canEditAsset = _a.canEditAsset, canEditShift = _a.canEditShift, filterAssets = _a.filterAssets, allowAttachments = _a.allowAttachments, shiftsRange = _a.shiftsRange;
23493
+ var settings = useUTLSettingsContext().state.settings;
23494
+ var defaultAssetId = Number(get(settings, "DefaultAssetId", 15));
23495
+ var shiftIdParam = useParams().shiftId;
23496
+ var searchParams = useSearchParams()[0];
23497
+ var entryId = searchParams.get("entryId");
23498
+ var action = searchParams.get("action");
23499
+ var shiftInfo = useShiftNavigator().shiftInfo;
23500
+ var isNewEntry = action === "new";
23501
+ var _b = useState(""), notificationMessage = _b[0], setNotificationMessage = _b[1];
23502
+ var _c = useState(null), shiftTimestamp = _c[0], setShiftTimestamp = _c[1];
23503
+ var _d = useState(""), error = _d[0], setError = _d[1];
23504
+ // Section state
23505
+ var _e = useState(null), selectedSection = _e[0], setSelectedSection = _e[1];
23506
+ var _f = useForm(), control = _f.control, handleSubmit = _f.handleSubmit, reset = _f.reset, _g = _f.formState; _g.isValid; var dirtyFields = _g.dirtyFields, watch = _f.watch, setValue = _f.setValue;
23507
+ var isFormDirty = !(Object.keys(dirtyFields).length === 0);
23508
+ var updatedBy = watch("UpdatedBy");
23509
+ var updateTimestamp = watch("UpdateTimestamp");
23510
+ var createTimestamp = watch("CreateTimestamp");
23511
+ watch("Content");
23512
+ var entryIdValue = watch("EntryId");
23513
+ var title = watch("Title");
23514
+ var author = watch("Author");
23515
+ var shiftId = watch("ShiftId");
23516
+ var assetId = watch("AssetId");
23517
+ var shift = watch("Shift");
23518
+ var crew = watch("Crew");
23519
+ // Handler for when entry is submitted via attachment modal
23520
+ var handleEntrySubmitted = function (newEntryId, newEntryData) {
23521
+ setNotificationMessage("Entry created successfully");
23522
+ // If we have the new entry data, update the form immediately
23523
+ if (newEntryData) {
23524
+ reset(newEntryData);
23525
+ }
23526
+ // Add a setTimeout to delay navigation, giving the system time to process everything
23527
+ setTimeout(function () {
23528
+ onHide(newEntryId, true); // true = shouldStayInEditMode
23529
+ }, 1000); // 1000ms delay to ensure all processing is complete
23530
+ };
23531
+ // Use the shared entry submission hook
23532
+ var _h = useEntrySubmission({
23533
+ onSuccess: function (entry) { return __awaiter(void 0, void 0, void 0, function () {
23534
+ var err_1;
23535
+ return __generator(this, function (_a) {
23536
+ switch (_a.label) {
23537
+ case 0:
23538
+ if (!(entry && entry.EntryId)) return [3 /*break*/, 5];
23539
+ if (!selectedSection) return [3 /*break*/, 4];
23540
+ _a.label = 1;
23541
+ case 1:
23542
+ _a.trys.push([1, 3, , 4]);
23543
+ return [4 /*yield*/, upsertSectionEntry({
23544
+ entryId: entry.EntryId,
23545
+ sectionId: selectedSection.SectionId,
23546
+ })];
23547
+ case 2:
23548
+ _a.sent();
23549
+ return [3 /*break*/, 4];
23550
+ case 3:
23551
+ err_1 = _a.sent();
23552
+ console.error("Error saving section entry:", err_1);
23553
+ setError(err_1.message || "Error saving section data");
23554
+ return [2 /*return*/];
23555
+ case 4:
23556
+ setNotificationMessage(entryId === "new"
23557
+ ? "Entry created successfully"
23558
+ : "Entry updated successfully");
23559
+ // Add a setTimeout to delay navigation
23560
+ setTimeout(function () {
23561
+ onHide(entry.EntryId);
23562
+ }, 1000);
23563
+ return [3 /*break*/, 6];
23564
+ case 5:
23565
+ console.error("No EntryId received from API response", entry);
23566
+ setError("Failed to get entry ID from server response");
23567
+ _a.label = 6;
23568
+ case 6: return [2 /*return*/];
23569
+ }
23570
+ });
23571
+ }); },
23572
+ onError: function (error) {
23573
+ setError(error.message);
23574
+ },
23575
+ isNewEntry: isNewEntry,
23576
+ onHide: function () { return onHide(); },
23577
+ }), submitEntry = _h.submitEntry, isSubmitLoading = _h.isSubmitLoading, showConfirmationDialog = _h.showConfirmationDialog, handleConfirmationClose = _h.handleConfirmationClose;
23578
+ var onSubmit = function (formData) { return __awaiter(void 0, void 0, void 0, function () {
23579
+ var submissionData;
23580
+ var _a;
23581
+ return __generator(this, function (_b) {
23582
+ switch (_b.label) {
23583
+ case 0:
23584
+ setError("");
23585
+ submissionData = {
23586
+ assetId: formData.AssetId,
23587
+ entryId: formData.EntryId,
23588
+ shiftId: formData.ShiftId,
23589
+ isForOtherShift: (entry === null || entry === void 0 ? void 0 : entry.ShiftId)
23590
+ ? entry.ShiftId !== formData.ShiftId
23591
+ : (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId) !== formData.ShiftId,
23592
+ title: formData.Title,
23593
+ content: formData.Content,
23594
+ author: (_a = formData.Author) !== null && _a !== void 0 ? _a : "",
23595
+ createTimestamp: isNewEntry ? new Date() : formData.CreateTimestamp,
23596
+ };
23597
+ return [4 /*yield*/, submitEntry(submissionData)];
23598
+ case 1:
23599
+ _b.sent();
23600
+ return [2 /*return*/];
23601
+ }
23602
+ });
23603
+ }); };
23604
+ useEffect(function () {
23605
+ var _a, _b, _c;
23606
+ if (shiftInfo || !isNewEntry) {
23607
+ var newEntry = __assign(__assign({}, ENTRY_INITIAL_VALUES), { ShiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, Shift: (_a = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShift) !== null && _a !== void 0 ? _a : "", Crew: (_b = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentCrew) !== null && _b !== void 0 ? _b : "", CreateTimestamp: new Date(), AssetId: (_c = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _c !== void 0 ? _c : null });
23608
+ reset((isNewEntry ? newEntry : entry) || ENTRY_INITIAL_VALUES);
23609
+ }
23610
+ }, [entry, shiftInfo, entryId, reset, defaultAssetId]);
23611
+ useEffect(function () {
23612
+ var _a;
23613
+ if (isNewEntry) {
23614
+ setValue("AssetId", (_a = preselectedAssetId !== null && preselectedAssetId !== void 0 ? preselectedAssetId : defaultAssetId) !== null && _a !== void 0 ? _a : null);
23615
+ }
23616
+ }, [preselectedAssetId, defaultAssetId]);
23617
+ return (React__default.createElement(React__default.Fragment, null,
23618
+ isNewEntry || (entry === null || entry === void 0 ? void 0 : entry.EntryId) ? (React__default.createElement(HelmetDexteel, { title: "".concat(isNewEntry ? "New Entry" : "'".concat(entry === null || entry === void 0 ? void 0 : entry.Title, "' by ").concat(entry === null || entry === void 0 ? void 0 : entry.Author), " - Logbook Entry") })) : null,
23619
+ isNewEntry || (entry === null || entry === void 0 ? void 0 : entry.EntryId) ? (React__default.createElement(Paper, { elevation: 1, sx: {
23620
+ width: "100%",
23621
+ height: "100%",
23622
+ display: "flex",
23623
+ flexDirection: "column",
23624
+ } },
23625
+ React__default.createElement(Grid2, { container: true, spacing: 1, component: "form", onSubmit: handleSubmit(onSubmit), height: "100%", flexDirection: "column", flexWrap: "nowrap", p: 1 },
23626
+ React__default.createElement(Grid2, { size: { xs: 12 } },
23627
+ React__default.createElement(Controller, { name: "Title", control: control, rules: {
23628
+ required: "Title is required",
23629
+ validate: function (value) {
23630
+ return !!(value === null || value === void 0 ? void 0 : value.trim()) || "Title cannot be empty";
23631
+ },
23632
+ }, render: function (_a) {
23633
+ var _b = _a.field, value = _b.value, onChange = _b.onChange, error = _a.fieldState.error;
23634
+ return (React__default.createElement(TextField, { label: "Title", value: value !== null && value !== void 0 ? value : "", onChange: onChange, error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, autoFocus: isNewEntry, size: "medium" }));
23635
+ } })),
23636
+ React__default.createElement(Grid2, { container: true, size: { xs: 12 }, spacing: 2 },
23637
+ React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
23638
+ React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
23639
+ var value = _a.field.value;
23640
+ return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$4(value) : null, disabled: true, slotProps: {
23641
+ textField: {
23642
+ variant: "outlined",
23643
+ size: "small",
23644
+ fullWidth: true,
23645
+ InputLabelProps: {
23646
+ shrink: true,
23647
+ style: {
23648
+ fontSize: ".875rem",
23649
+ marginTop: -2,
23650
+ },
23651
+ },
23652
+ },
23653
+ } }));
23654
+ } })),
23655
+ canEditShift ? (React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
23656
+ React__default.createElement(Controller, { name: "ShiftId", control: control, render: function (_a) {
23657
+ var _b;
23658
+ var field = _a.field;
23659
+ return (React__default.createElement(ShiftAutocomplete, { currentShiftId: (_b = Number(shiftIdParam)) !== null && _b !== void 0 ? _b : shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId, onShiftSelected: function (selectedShift) {
23660
+ if (selectedShift) {
23661
+ setValue("Shift", selectedShift.Shift, {
23662
+ shouldDirty: true,
23663
+ });
23664
+ setValue("Crew", selectedShift.Crew, {
23665
+ shouldDirty: true,
23666
+ });
23667
+ setShiftTimestamp(new Date(selectedShift.Start));
23668
+ field.onChange(selectedShift.ShiftId);
23669
+ }
23670
+ else {
23671
+ setValue("Shift", null, { shouldDirty: true });
23672
+ setValue("Crew", null, { shouldDirty: true });
23673
+ setShiftTimestamp(null);
23674
+ field.onChange(null);
23675
+ }
23676
+ }, value: field.value, disabled: !isNewEntry && show !== "edit", shiftsRange: shiftsRange }));
23677
+ } }))) : (React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
23678
+ React__default.createElement(Controller, { name: "ShiftId", control: control, render: function (_a) {
23679
+ var field = _a.field;
23680
+ return (React__default.createElement(ShiftSelector, { onChange: field.onChange, value: field.value, disabled: true }));
23681
+ } }))),
23682
+ React__default.createElement(Grid2, { size: { xs: 12, md: canEditAsset ? 2 : 6 } },
23683
+ React__default.createElement(Controller, { name: "Author", control: control, rules: {
23684
+ required: "Author is required",
23685
+ }, render: function (_a) {
23686
+ var _b = _a.field, value = _b.value, onChange = _b.onChange, error = _a.fieldState.error;
23687
+ return (React__default.createElement(TextField, { label: "Author", variant: "outlined", value: value !== null && value !== void 0 ? value : "", onChange: onChange, fullWidth: true, error: !!error, helperText: error === null || error === void 0 ? void 0 : error.message, disabled: !isNewEntry, size: "small" }));
23688
+ } })),
23689
+ canEditAsset ? (withAssetFilter === "tree" ? (React__default.createElement(Grid2, { size: { md: 4, xs: 12 } },
23690
+ React__default.createElement(Controller, { name: "AssetId", control: control, render: function (_a) {
23691
+ var field = _a.field;
23692
+ return (React__default.createElement(AssetTreePicker, { label: "Asset", value: field.value || 0, onChange: field.onChange }));
23693
+ } }))) : withAssetFilter === "selector" ? (React__default.createElement(Grid2, { size: { md: 4, xs: 12 } },
23694
+ React__default.createElement(Controller, { name: "AssetId", control: control, render: function (_a) {
23695
+ var field = _a.field;
23696
+ return (React__default.createElement(AssetsFilter, { value: field.value, onChange: field.onChange, filterAreaAssets: filterAssets === "area" }));
23697
+ } }))) : null) : null),
23698
+ React__default.createElement(Grid2, { size: { xs: 12 } },
23699
+ React__default.createElement(SectionSelector, { value: selectedSection, onChange: function (section) {
23700
+ setSelectedSection(section);
23701
+ if (section) {
23702
+ setValue("SectionId", section.SectionId, {
23703
+ shouldDirty: true,
23704
+ });
23705
+ setValue("SectionName", section.SectionName, {
23706
+ shouldDirty: true,
23707
+ });
23708
+ }
23709
+ else {
23710
+ setValue("SectionId", null, { shouldDirty: true });
23711
+ setValue("SectionName", undefined, {
23712
+ shouldDirty: true,
23713
+ });
23714
+ }
23715
+ }, disabled: !isNewEntry && show !== "edit" })),
23716
+ React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
23717
+ React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
23718
+ var _b = _a.field, value = _b.value, onChange = _b.onChange;
23719
+ return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return onChange(val); }, value: value, isEditing: show === "edit", isNewEntry: isNewEntry, entryId: entryIdValue, entryData: {
23720
+ assetId: assetId,
23721
+ entryId: entryIdValue,
23722
+ shiftId: shiftId,
23723
+ title: title,
23724
+ content: value,
23725
+ author: author,
23726
+ createTimestamp: isNewEntry
23727
+ ? new Date()
23728
+ : createTimestamp,
23729
+ }, onEntrySubmitted: handleEntrySubmitted, allowAttachments: allowAttachments }));
23730
+ } })),
23731
+ React__default.createElement(Grid2, { container: true, size: { xs: 12 } },
23732
+ React__default.createElement(Grid2, { container: true, size: { md: 6, xs: 12 }, spacing: 1 },
23733
+ React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
23734
+ React__default.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: function () { return onHide(); } }, "Close")),
23735
+ React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
23736
+ React__default.createElement(Button, { fullWidth: true, variant: "contained", color: "primary", onClick: function () { return onChangeShow(); } }, show === "edit" ? "Preview" : "Edit"))),
23737
+ React__default.createElement(Grid2, { container: true, size: { md: 6, xs: 12 }, style: { display: "flex", justifyContent: "flex-end" } },
23738
+ React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
23739
+ React__default.createElement(Button, { fullWidth: true, startIcon: isSubmitLoading && React__default.createElement(CircularProgress, { size: "1rem" }), disabled: isSubmitLoading || !isFormDirty, variant: "contained", color: "primary", type: "submit" }, isNewEntry ? "Create" : "Save"))))))) : null,
23740
+ React__default.createElement(NotificationSnackBar, { message: notificationMessage, onHide: function () { return setNotificationMessage(""); } }),
23741
+ React__default.createElement(ConfirmationDialogRaw, { open: showConfirmationDialog, onClose: handleConfirmationClose, title: "Shift Submission Confirmation", message: "You are about to ".concat(isNewEntry ? "create" : "save", " an entry for ").concat(moment$4(shiftTimestamp).format("MM/DD/YYYY"), " ").concat(shift, " - ").concat(crew, ". Are you sure you want to proceed?"), suffixTitle: "Logbook Entry" }),
23742
+ React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
23743
+ };
23744
+
23745
+ var Filters$1 = function (_a) {
23746
+ var quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange, selectedSections = _a.selectedSections, onSectionsChange = _a.onSectionsChange;
23747
+ useMesfRealtime({
23748
+ onReceiveMessage: function (author, message) {
23749
+ if (message.replaceAll("[", "").replaceAll("]", "") == "LB.GetEntries") ;
23750
+ },
23751
+ });
23752
+ return (React__default.createElement(Grid2, { container: true, justifyContent: "center", alignItems: "center", component: Paper, size: { md: 12 }, spacing: 1, p: 1 },
23753
+ React__default.createElement(Grid2, { maxWidth: "fit-content", justifyContent: "center" },
23754
+ React__default.createElement(ShiftDayNavigatorControl, { preventInit: true, withPaper: false })),
23755
+ React__default.createElement(Grid2, { size: { md: 4.5, xs: 12 } },
23756
+ React__default.createElement(TextField, { label: "Search", value: quickFilter, onChange: function (event) {
23757
+ onQuickFilterChange(event === null || event === void 0 ? void 0 : event.target.value);
23758
+ }, size: "small", fullWidth: true, slotProps: {
23759
+ input: {
23760
+ startAdornment: (React__default.createElement(InputAdornment, { position: "start" },
23761
+ React__default.createElement(SearchIcon, { fontSize: "small", sx: { color: "action.active" } }))),
23762
+ },
23763
+ } })),
23764
+ React__default.createElement(Grid2, { size: { xs: 12 } },
23765
+ React__default.createElement(SectionMultiSelect, { value: selectedSections, onChange: onSectionsChange, label: "Sections" }))));
23766
+ };
23767
+
23768
+ var moment$3 = getMomentTz();
23769
+ // Default layout matching original Grid md:5 / md:7 ratio (41.67% / 58.33%)
23770
+ var DEFAULT_LAYOUT$1 = { left: 42, right: 58 };
23771
+ var Logbook$1 = function () {
23772
+ var entry = useLogbookSettings().entry;
23773
+ var allowAttachments = entry.allowAttachments;
23774
+ var canEditShift = entry.canEditShift;
23775
+ var showShiftCrew = entry.showShiftCrew;
23776
+ var exportToExcel = entry.exportToExcel;
23777
+ var shiftsRange = entry.shiftsRange;
23778
+ // Asset settings
23779
+ var withAssetFilter = entry.withAssetFilter;
23780
+ var canEditAsset = entry.canEditAsset;
23781
+ var filterAssets = entry.filterAssets;
23782
+ var navigate = useNavigate();
23783
+ var searchParams = useSearchParams()[0];
23784
+ var entryId = searchParams.get("entryId");
23785
+ var action = searchParams.get("action");
23786
+ var shiftId = useParams().shiftId;
23787
+ var _a = useShiftNavigator(), shiftInfo = _a.shiftInfo, getShiftDataFromAPI = _a.getShiftDataFromAPI;
23788
+ var isEditMode = action === "edit";
23789
+ var shiftIdRef = useRef(null);
23790
+ var gridApiRef = useRef(null);
23791
+ var _b = useState(""), error = _b[0], setError = _b[1];
23792
+ var _c = useState(""), show = _c[0], setShow = _c[1];
23793
+ var _d = useState(""), quickFilter = _d[0], setQuickFilter = _d[1];
23794
+ // Section filter state - multi-select
23795
+ var _e = useState([]), filterSections = _e[0], setFilterSections = _e[1];
23796
+ var _f = useState(null), selectedRowData = _f[0], setSelectedRowData = _f[1];
23797
+ var _g = useState(false), showRemoveDialog = _g[0], setShowRemoveDialog = _g[1];
23798
+ var _h = useContextMenuMESF(), registerConfig = _h.registerConfig, showContextMenu = _h.showContextMenu;
23799
+ // Resizable panels layout persistence
23800
+ var _j = useDefaultLayout({
23801
+ id: "section-logbook-entry-v2",
23802
+ storage: localStorage,
23803
+ }), savedLayout = _j.defaultLayout, onLayoutChange = _j.onLayoutChange;
23804
+ // Use saved layout or default to avoid flash on initial render
23805
+ var resolvedLayout = savedLayout !== null && savedLayout !== void 0 ? savedLayout : DEFAULT_LAYOUT$1;
23806
+ var _k = useEntries({
23807
+ shiftId: shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId,
23808
+ sectionIds: filterSections.map(function (s) { return s.SectionId; }),
23809
+ }), rows = _k.data, isLoading = _k.isLoading, e = _k.error, isError = _k.isError, refetch = _k.refetch;
23810
+ var columnDefs = useTableData$1({
23811
+ showContextMenu: showContextMenu,
23812
+ allowAttachments: allowAttachments,
23813
+ showShiftCrew: showShiftCrew,
23814
+ }).columnDefs;
23815
+ var defaultColDef = useGridDefinitions({}).defaultColDef;
23816
+ var onQuickFilterChange = function (text) {
23817
+ var _a;
23818
+ setQuickFilter(text);
23819
+ (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.setGridOption("quickFilterText", text);
23820
+ };
23821
+ var handleNewEntry = function () {
23822
+ var _a;
23823
+ (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
23824
+ setSelectedRowData(__assign({}, ENTRY_INITIAL_VALUES));
23825
+ navigate("".concat(routeLogbookEntry, "/").concat(shiftIdRef.current, "?action=new"), {
23826
+ replace: true,
23827
+ });
23828
+ setShow("edit");
23829
+ };
23830
+ var rowClicked = function (event) {
23831
+ var _a;
23832
+ var currentShiftId = shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId);
23833
+ setSelectedRowData(event === null || event === void 0 ? void 0 : event.data);
23834
+ navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "?entryId=").concat((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.EntryId, "&action=view"));
23835
+ setShow("view");
23836
+ };
23837
+ var onCellKeyDown = useCallback(function (event) {
23838
+ var api = event.api, node = event.node, keyEvent = event.event;
23839
+ if (!keyEvent)
23840
+ return;
23841
+ var key = keyEvent.key;
23842
+ if (key === "ArrowUp" || key === "ArrowDown") {
23843
+ keyEvent.preventDefault();
23844
+ var currentIndex = node.rowIndex !== null ? node.rowIndex : -1;
23845
+ var nextRowIndex = key === "ArrowUp" ? currentIndex - 1 : currentIndex + 1;
23846
+ var nextNode = api.getDisplayedRowAtIndex(nextRowIndex);
23847
+ if (nextNode) {
23848
+ var currentShiftId = shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId);
23849
+ nextNode.setSelected(true);
23850
+ api.ensureIndexVisible(nextRowIndex);
23851
+ setSelectedRowData(nextNode.data);
23852
+ navigate("".concat(routeLogbookEntry, "/").concat(currentShiftId, "/?entryId=").concat(nextNode.data.EntryId, "&action=view"));
23853
+ }
23854
+ }
23855
+ }, [setSelectedRowData, shiftId, shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId]);
23856
+ var getContextMenuItems = useCallback(function (params) {
23857
+ var _a, _b;
23858
+ var data = (_a = params.node) === null || _a === void 0 ? void 0 : _a.data;
23859
+ showContextMenu(event, data, "logbookEntryContext");
23860
+ if (data) {
23861
+ params.api.deselectAll();
23862
+ (_b = params.node) === null || _b === void 0 ? void 0 : _b.setSelected(true);
23863
+ }
23864
+ return [];
23865
+ }, [rows]);
23866
+ var getMenuOptions = useLogbookEntryOptionsFunctions({
23867
+ setSelectedRowData: setSelectedRowData,
23868
+ setShow: setShow,
23869
+ setShowRemoveDialog: setShowRemoveDialog,
23870
+ handleNewEntry: handleNewEntry,
23871
+ }).getMenuOptions;
23872
+ var handleExportToExcel = function () {
23873
+ if (!gridApiRef.current)
23874
+ return;
23875
+ var params = {
23876
+ fileName: "Logbook_Entries_Export.xlsx",
23877
+ columnKeys: [
23878
+ "AssetName",
23879
+ "CreateTimestamp",
23880
+ "Shift",
23881
+ "Crew",
23882
+ "Title",
23883
+ "CreatedBy",
23884
+ "Author",
23885
+ "Content",
23886
+ ],
23887
+ processCellCallback: function (params) {
23888
+ if (params.column.colId === "CreateTimestamp") {
23889
+ return moment$3(params.value).format("MM/DD/yy - HH:mm");
23890
+ }
23891
+ return params.value;
23892
+ },
23893
+ };
23894
+ gridApiRef.current.exportDataAsExcel(params);
23895
+ };
23896
+ useEffect(function () {
23897
+ var _a, _b;
23898
+ if (!isLoading && entryId && entryId !== "new" && gridApiRef.current) {
23899
+ var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId);
23900
+ if (rowNode) {
23901
+ (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
23902
+ rowNode.setSelected(true);
23903
+ setSelectedRowData(rowNode.data);
23904
+ setShow(isEditMode ? "edit" : "view");
23905
+ }
23906
+ else {
23907
+ // If the row node is not found, it might be a newly created entry
23908
+ // Try to refetch the data and then look for the entry
23909
+ setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
23910
+ var newRowNode;
23911
+ var _a, _b;
23912
+ return __generator(this, function (_c) {
23913
+ switch (_c.label) {
23914
+ case 0: return [4 /*yield*/, refetch()];
23915
+ case 1:
23916
+ _c.sent();
23917
+ newRowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId);
23918
+ if (newRowNode) {
23919
+ (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(newRowNode);
23920
+ newRowNode.setSelected(true);
23921
+ setSelectedRowData(newRowNode.data);
23922
+ setShow(isEditMode ? "edit" : "view");
23923
+ }
23924
+ return [2 /*return*/];
23925
+ }
23926
+ });
23927
+ }); }, 500);
23928
+ }
23929
+ }
23930
+ }, [gridApiRef.current, isLoading, entryId, isEditMode, refetch]);
23931
+ useEffect(function () {
23932
+ registerConfig({
23933
+ id: "logbookEntryContext",
23934
+ getOptions: getMenuOptions,
23935
+ });
23936
+ }, []);
23937
+ useEffect(function () {
23938
+ if (isError) {
23939
+ setError(e.message);
23940
+ }
23941
+ }, [isError, e]);
23942
+ useEffect(function () {
23943
+ if (shiftInfo) {
23944
+ setShow("");
23945
+ setSelectedRowData(null);
23946
+ if (entryId &&
23947
+ (shiftIdRef.current == null ||
23948
+ shiftIdRef.current === (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId))) {
23949
+ navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId, "?entryId=").concat(entryId, "&action=").concat(action));
23950
+ }
23951
+ else {
23952
+ navigate("".concat(routeLogbookEntry, "/").concat(shiftInfo.CurrentShiftId));
23953
+ }
23954
+ shiftIdRef.current = shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId;
23955
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
23956
+ return __generator(this, function (_a) {
23957
+ switch (_a.label) {
23958
+ case 0: return [4 /*yield*/, refetch()];
23959
+ case 1:
23960
+ _a.sent();
23961
+ return [2 /*return*/];
23962
+ }
23963
+ });
23964
+ }); })();
23965
+ }
23966
+ }, [shiftInfo]);
23967
+ useEffect(function () {
23968
+ if (shiftId) {
23969
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
23970
+ var shiftIdNumber;
23971
+ return __generator(this, function (_a) {
23972
+ switch (_a.label) {
23973
+ case 0:
23974
+ shiftIdNumber = Number(shiftId);
23975
+ return [4 /*yield*/, getShiftDataFromAPI(null, shiftIdNumber)];
23976
+ case 1:
23977
+ _a.sent();
23978
+ return [2 /*return*/];
23979
+ }
23980
+ });
23981
+ }); })();
23982
+ }
23983
+ else {
23984
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
23985
+ return __generator(this, function (_a) {
23986
+ switch (_a.label) {
23987
+ case 0: return [4 /*yield*/, getShiftDataFromAPI(null, 0)];
23988
+ case 1:
23989
+ _a.sent();
23990
+ return [2 /*return*/];
23991
+ }
23992
+ });
23993
+ }); })();
23994
+ }
23995
+ }, []);
23996
+ return (React__default.createElement(Box, { sx: {
23997
+ width: "100%",
23998
+ height: "calc(100vh - 130px)",
23999
+ display: "flex",
24000
+ flexDirection: "column",
24001
+ } },
24002
+ React__default.createElement(Box, { sx: { mb: 2 } },
24003
+ React__default.createElement(Typography$1, { variant: "h5", style: {
24004
+ fontWeight: 600,
24005
+ userSelect: "none",
24006
+ } }, "LOGBOOK")),
24007
+ React__default.createElement(Group$1, { id: "section-logbook-entry-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
24008
+ React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
24009
+ React__default.createElement(Box, { sx: {
24010
+ display: "flex",
24011
+ flexDirection: "column",
24012
+ gap: 1,
24013
+ height: "100%",
24014
+ pr: 1,
24015
+ } },
24016
+ React__default.createElement(Filters$1, { quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, selectedSections: filterSections, onSectionsChange: setFilterSections }),
24017
+ React__default.createElement(Paper, { elevation: 1, style: {
24018
+ flex: 1,
24019
+ width: "100%",
24020
+ } },
24021
+ React__default.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 38, headerHeight: 42, loadingOverlayComponent: CenteredLazyLoading, animateRows: true, getContextMenuItems: getContextMenuItems, onRowClicked: rowClicked, onCellKeyDown: onCellKeyDown, onGridReady: function (params) { return (gridApiRef.current = params.api); }, getRowId: function (params) { return "".concat(params.data.EntryId); }, gridOptions: {
24022
+ rowSelection: {
24023
+ mode: "singleRow",
24024
+ checkboxes: false,
24025
+ enableClickSelection: true,
24026
+ },
24027
+ statusBar: {
24028
+ statusPanels: [
24029
+ exportToExcel
24030
+ ? {
24031
+ statusPanel: function (params) { return (React__default.createElement("div", { style: {
24032
+ display: "flex",
24033
+ alignItems: "center",
24034
+ paddingTop: 5,
24035
+ } },
24036
+ React__default.createElement(ExcelButton, { handleExportToExcel: handleExportToExcel }))); },
24037
+ align: "right",
24038
+ }
24039
+ : {},
24040
+ {
24041
+ statusPanel: function (params) { return (React__default.createElement(CustomStatusPanel, { handleNew: handleNewEntry })); },
24042
+ align: "left",
24043
+ },
24044
+ ],
24045
+ },
24046
+ } })))),
24047
+ React__default.createElement(Separator, { style: {
24048
+ display: "flex",
24049
+ alignItems: "center",
24050
+ justifyContent: "center",
24051
+ cursor: "col-resize",
24052
+ } },
24053
+ React__default.createElement(Box, { sx: {
24054
+ width: 8,
24055
+ height: 48,
24056
+ borderRadius: 1,
24057
+ backgroundColor: "#e0e0e0",
24058
+ display: "flex",
24059
+ flexDirection: "column",
24060
+ alignItems: "center",
24061
+ justifyContent: "center",
24062
+ gap: "3px",
24063
+ transition: "background-color 0.2s",
24064
+ "&:hover": {
24065
+ backgroundColor: "primary.main",
24066
+ "& .grip-dot": {
24067
+ backgroundColor: "#fff",
24068
+ },
24069
+ },
24070
+ } }, __spreadArray([], Array(5), true).map(function (_, i) { return (React__default.createElement(Box, { key: i, className: "grip-dot", sx: {
24071
+ width: 4,
24072
+ height: 4,
24073
+ borderRadius: "50%",
24074
+ backgroundColor: "#9e9e9e",
24075
+ transition: "background-color 0.2s",
24076
+ } })); }))),
24077
+ React__default.createElement(Panel, { id: "right", defaultSize: 58, minSize: 30, style: { paddingBottom: 5 } },
24078
+ React__default.createElement(Box, { sx: { pl: 1, height: "100%" } },
24079
+ React__default.createElement(EntryViewer$1, { entry: selectedRowData, show: show, onChangeShow: function () {
24080
+ var newShow = show === "view" ? "edit" : "view";
24081
+ setShow(newShow);
24082
+ if (entryId && entryId !== "new") {
24083
+ var targetUrl = newShow === "edit"
24084
+ ? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
24085
+ : "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
24086
+ navigate(targetUrl);
24087
+ }
24088
+ }, canEditShift: canEditShift, allowAttachments: allowAttachments, shiftsRange: shiftsRange, withAssetFilter: withAssetFilter, canEditAsset: canEditAsset, filterAssets: filterAssets, onHide: function (entryId, shouldStayInEditMode) { return __awaiter(void 0, void 0, void 0, function () {
24089
+ var targetUrl;
24090
+ var _a;
24091
+ return __generator(this, function (_b) {
24092
+ switch (_b.label) {
24093
+ case 0:
24094
+ if (!entryId) return [3 /*break*/, 2];
24095
+ // First refetch to ensure we have the latest data
24096
+ return [4 /*yield*/, refetch()];
24097
+ case 1:
24098
+ // First refetch to ensure we have the latest data
24099
+ _b.sent();
24100
+ targetUrl = shouldStayInEditMode
24101
+ ? "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=edit")
24102
+ : "/logbook/entry/".concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId), "?entryId=").concat(entryId, "&action=view");
24103
+ navigate(targetUrl);
24104
+ setShow(shouldStayInEditMode ? "edit" : "view");
24105
+ // Additional delay to allow navigation and state updates to complete
24106
+ setTimeout(function () {
24107
+ var _a, _b;
24108
+ var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
24109
+ if (rowNode) {
24110
+ (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
24111
+ rowNode.setSelected(true);
24112
+ setSelectedRowData(rowNode.data);
24113
+ }
24114
+ else {
24115
+ // If still not found, try one more refetch
24116
+ setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
24117
+ var retryRowNode;
24118
+ var _a, _b, _c;
24119
+ return __generator(this, function (_d) {
24120
+ switch (_d.label) {
24121
+ case 0: return [4 /*yield*/, refetch()];
24122
+ case 1:
24123
+ _d.sent();
24124
+ retryRowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId.toString());
24125
+ if (retryRowNode) {
24126
+ (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(retryRowNode);
24127
+ retryRowNode.setSelected(true);
24128
+ setSelectedRowData(retryRowNode.data);
24129
+ }
24130
+ else {
24131
+ setShow("");
24132
+ setSelectedRowData(null);
24133
+ (_c = gridApiRef.current) === null || _c === void 0 ? void 0 : _c.deselectAll();
24134
+ }
24135
+ return [2 /*return*/];
24136
+ }
24137
+ });
24138
+ }); }, 500);
24139
+ }
24140
+ }, 200);
24141
+ return [3 /*break*/, 3];
24142
+ case 2:
24143
+ setShow("");
24144
+ setSelectedRowData(null);
24145
+ (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
24146
+ navigate("".concat(routeLogbookEntry, "/").concat(shiftId || (shiftInfo === null || shiftInfo === void 0 ? void 0 : shiftInfo.CurrentShiftId)));
24147
+ _b.label = 3;
24148
+ case 3: return [2 /*return*/];
24149
+ }
24150
+ });
24151
+ }); } })))),
24152
+ React__default.createElement(RemoveEntryDialog, { entry: selectedRowData, show: showRemoveDialog, onHide: function (shouldUpdate) {
24153
+ if (shouldUpdate) {
24154
+ refetch();
24155
+ }
24156
+ setShowRemoveDialog(false);
24157
+ setSelectedRowData(null);
24158
+ setShow("");
24159
+ } }),
24160
+ React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
24161
+ };
24162
+
24163
+ var LogbookPage$1 = function () {
24164
+ return (React__default.createElement(React__default.Fragment, null,
24165
+ React__default.createElement(HelmetDexteel, { title: "Logbook Entry" }),
24166
+ React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
24167
+ React__default.createElement(Logbook$1, null))));
24168
+ };
24169
+
24170
+ var MESFLogbookEntry = function () {
24171
+ return React__default.createElement(LogbookPage$1, null);
24172
+ };
24173
+
24174
+ var moment$2 = getMomentTz();
24175
+ var getEntriesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
24176
+ var apiService, parameters, resp, rows;
24177
+ var startShiftId = _b.startShiftId, endShiftId = _b.endShiftId, assetId = _b.assetId, sectionIds = _b.sectionIds, signal = _b.signal;
24178
+ return __generator(this, function (_c) {
24179
+ switch (_c.label) {
24180
+ case 0:
24181
+ apiService = new MESApiService();
24182
+ parameters = [
24183
+ { name: "StartShiftId", value: startShiftId },
24184
+ { name: "EndShiftId", value: endShiftId },
24185
+ ];
24186
+ if (assetId) {
24187
+ parameters.push({ name: "AssetId", value: assetId });
24188
+ }
24189
+ // Pass comma-separated sectionIds for multi-select filter
24190
+ if (sectionIds && sectionIds.length > 0) {
24191
+ parameters.push({ name: "SectionIds", value: sectionIds.join(",") });
24192
+ }
24193
+ return [4 /*yield*/, apiService.callV2("[SWV].[GetSectionLogbookEntries]", parameters, signal)];
24194
+ case 1:
24195
+ resp = _c.sent();
24196
+ if (resp.ok) {
24197
+ rows = get(resp, "data.tables[0].rows", []);
24198
+ rows = rows.map(function (entry) { return (__assign(__assign({}, entry), { CreateTimestamp: entry.CreateTimestamp
24199
+ ? moment$2.utc(entry["CreateTimestamp"]).toDate()
24200
+ : null, UpdateTimestamp: entry.UpdateTimestamp
24201
+ ? moment$2.utc(entry["UpdateTimestamp"]).toDate()
24202
+ : null })); });
24203
+ return [2 /*return*/, rows];
24204
+ }
24205
+ else {
24206
+ throw new Error(resp.message || "Error fetching entries");
24207
+ }
24208
+ }
24209
+ });
24210
+ }); };
24211
+
24212
+ var useEntriesReport = function (_a) {
24213
+ var startShiftId = _a.startShiftId, endShiftId = _a.endShiftId, assetId = _a.assetId, sectionIds = _a.sectionIds;
24214
+ return useQuery({
24215
+ queryKey: ["entriesReport", startShiftId, endShiftId, assetId, sectionIds],
24216
+ queryFn: function (_a) {
24217
+ var signal = _a.signal;
24218
+ return getEntriesReport({
24219
+ startShiftId: startShiftId,
24220
+ endShiftId: endShiftId,
24221
+ assetId: assetId,
24222
+ sectionIds: sectionIds,
24223
+ signal: signal,
24224
+ });
24225
+ },
24226
+ });
24227
+ };
24228
+
24229
+ var useTableData = function (_a) {
24230
+ var showAttachments = _a.showAttachments, showAsset = _a.showAsset, showShiftCrew = _a.showShiftCrew;
24231
+ var columnDefs = __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
24232
+ {
24233
+ field: "CreateTimestamp",
24234
+ headerName: "Created",
24235
+ flex: 2,
24236
+ valueGetter: function (params) {
24237
+ return dxtToLocalServerTime(params.data.CreateTimestamp, "MM/dd/yy HH:mm");
24238
+ },
24239
+ }
24240
+ ], (showAsset
24241
+ ? [
24242
+ {
24243
+ field: "AssetName",
24244
+ headerName: "Asset",
24245
+ sortable: true,
24246
+ flex: 2,
24247
+ minWidth: 70,
24248
+ wrapText: true,
24249
+ autoHeight: true,
24250
+ },
24251
+ ]
24252
+ : []), true), [
24253
+ {
24254
+ field: "Title",
24255
+ headerName: "Title",
24256
+ flex: 4,
24257
+ },
24258
+ {
24259
+ field: "SectionName",
24260
+ headerName: "Section",
24261
+ flex: 2,
24262
+ },
24263
+ {
24264
+ field: "Author",
24265
+ headerName: "Created By",
24266
+ flex: 2,
24267
+ }
24268
+ ], false), (showShiftCrew
24269
+ ? [
24270
+ {
24271
+ field: "Shift",
24272
+ headerName: "Shift",
24273
+ sortable: false,
24274
+ flex: 1,
24275
+ minWidth: 60,
24276
+ maxWidth: 60,
24277
+ },
24278
+ {
24279
+ field: "Crew",
24280
+ headerName: "Crew",
24281
+ sortable: false,
24282
+ flex: 1,
24283
+ minWidth: 60,
24284
+ maxWidth: 60,
24285
+ },
24286
+ ]
24287
+ : []), true), (showAttachments
24288
+ ? [
24289
+ {
24290
+ field: "AttachmentCount",
24291
+ headerName: "",
24292
+ flex: 1,
24293
+ headerComponent: function () { return (React__default.createElement("div", { style: {
24294
+ display: "flex",
24295
+ alignItems: "center",
24296
+ justifyContent: "center",
24297
+ height: "100%",
24298
+ width: "100%",
24299
+ textAlign: "center",
24300
+ } },
24301
+ React__default.createElement(AttachFile, { style: { fontSize: 18, color: "#666" } }))); },
24302
+ cellRenderer: function (params) {
24303
+ var count = params.data.AttachmentCount || 0;
24304
+ if (count === 0) {
24305
+ return null;
24306
+ }
24307
+ return (React__default.createElement("div", { style: {
24308
+ display: "flex",
24309
+ alignItems: "center",
24310
+ height: "100%",
24311
+ justifyContent: "center",
24312
+ } },
24313
+ React__default.createElement(Chip, { icon: React__default.createElement(AttachFile, { style: { fontSize: 16 } }), label: count, size: "small", variant: "outlined", color: "primary" })));
24314
+ },
24315
+ },
24316
+ ]
24317
+ : []), true), [
24318
+ {
24319
+ field: "Content",
24320
+ headerName: "Content",
24321
+ hide: true,
24322
+ },
24323
+ ], false);
24324
+ return { columnDefs: columnDefs };
24325
+ };
24326
+
24327
+ var moment$1 = getMomentTz();
24328
+ var EntryViewer = function (_a) {
24329
+ var entry = _a.entry, show = _a.show, onHide = _a.onHide, showAsset = _a.showAsset, _b = _a.showAttachments, showAttachments = _b === void 0 ? false : _b, _c = _a.showSection, showSection = _c === void 0 ? false : _c;
24330
+ var _d = useState(""), error = _d[0], setError = _d[1];
24331
+ var _e = useForm(), control = _e.control, setValue = _e.setValue, reset = _e.reset, watch = _e.watch; _e.getValues;
24332
+ var content = watch("Content");
24333
+ var updatedBy = watch("UpdatedBy");
24334
+ var updateTimestamp = watch("UpdateTimestamp");
24335
+ var entryId = watch("EntryId");
24336
+ var title = watch("Title");
24337
+ var author = watch("Author");
24338
+ var shiftId = watch("ShiftId");
24339
+ var assetId = watch("AssetId");
24340
+ var createTimestamp = watch("CreateTimestamp");
24341
+ useEffect(function () {
24342
+ reset(entry || ENTRY_INITIAL_VALUES);
24343
+ }, [entry, show]);
24344
+ return (React__default.createElement(React__default.Fragment, null,
24345
+ (entry === null || entry === void 0 ? void 0 : entry.EntryId) && (React__default.createElement(HelmetDexteel, { title: "'".concat(entry === null || entry === void 0 ? void 0 : entry.Title, "' by ").concat(entry.Author, " - Logbook Report") })),
24346
+ (entry === null || entry === void 0 ? void 0 : entry.EntryId) ? (React__default.createElement(Paper, { elevation: 1, sx: {
24347
+ width: "100%",
24348
+ height: "100%",
24349
+ display: "flex",
24350
+ flexDirection: "column",
24351
+ } },
24352
+ React__default.createElement(Grid2, { container: true, spacing: 1, component: "form", height: "100%", flexDirection: "column", flexWrap: "nowrap", p: 1 },
24353
+ React__default.createElement(Grid2, { size: { xs: 12 } },
24354
+ React__default.createElement(Controller, { name: "Title", control: control, render: function (_a) {
24355
+ var value = _a.field.value;
24356
+ return (React__default.createElement(TextField, { label: "Title", value: value !== null && value !== void 0 ? value : "", size: "medium", disabled: true }));
24357
+ } })),
24358
+ React__default.createElement(Grid2, { container: true, size: { xs: 12 }, spacing: 2 },
24359
+ React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
24360
+ React__default.createElement(Controller, { name: "CreateTimestamp", control: control, render: function (_a) {
24361
+ var value = _a.field.value;
24362
+ return (React__default.createElement(DateTimePicker, { label: "Creation Time", timezone: TimeService.getInstance().getServerTimeZone(), format: "MM/DD/YYYY HH:mm", value: value ? moment$1(value) : null, disabled: true, slotProps: {
24363
+ textField: {
24364
+ variant: "outlined",
24365
+ size: "small",
24366
+ fullWidth: true,
24367
+ InputLabelProps: {
24368
+ shrink: true,
24369
+ },
24370
+ },
24371
+ } }));
24372
+ } })),
24373
+ React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
24374
+ React__default.createElement(Controller, { name: "ShiftId", control: control, render: function (_a) {
24375
+ var field = _a.field;
24376
+ return (React__default.createElement(ShiftSelector, { value: field.value, disabled: true }));
24377
+ } })),
24378
+ React__default.createElement(Grid2, { size: { xs: 12, md: showAsset ? 2 : 6 } },
24379
+ React__default.createElement(Controller, { name: "Author", control: control, rules: {
24380
+ required: "Author is required",
24381
+ }, render: function (_a) {
24382
+ var value = _a.field.value; _a.fieldState.error;
24383
+ return (React__default.createElement(TextField, { label: "Author", variant: "outlined", value: value !== null && value !== void 0 ? value : "", fullWidth: true, disabled: true, size: "small" }));
24384
+ } })),
24385
+ showAsset ? (React__default.createElement(Grid2, { size: { md: 4, xs: 12 } },
24386
+ React__default.createElement(Controller, { name: "AssetId", control: control, render: function (_a) {
24387
+ var field = _a.field;
24388
+ return (React__default.createElement(AssetsFilter, { value: field.value, onChange: field.onChange, disabled: true }));
24389
+ } }))) : null),
24390
+ showSection && (entry === null || entry === void 0 ? void 0 : entry.SectionName) && (React__default.createElement(Grid2, { size: { xs: 12 }, sx: { display: "flex", alignItems: "center", gap: 1 } },
24391
+ React__default.createElement(Typography$1, { variant: "body2", color: "text.secondary" }, "Section:"),
24392
+ React__default.createElement(Chip, { label: entry.SectionName, size: "small", color: "primary", variant: "outlined" }))),
24393
+ React__default.createElement(Grid2, { size: { md: 12 }, height: "100%", flexGrow: 1, overflow: "auto" },
24394
+ React__default.createElement(Controller, { name: "Content", control: control, render: function (_a) {
24395
+ var _b = _a.field; _b.value; _b.onChange;
24396
+ return (React__default.createElement(ContentInput, { UpdatedBy: updatedBy, UpdateTimestamp: updateTimestamp, onChange: function (val) { return setValue("Content", val); }, value: content, isEditing: false, isNewEntry: false, entryId: entryId, entryData: {
24397
+ assetId: assetId,
24398
+ entryId: entryId,
24399
+ shiftId: shiftId,
24400
+ title: title,
24401
+ content: content,
24402
+ author: author,
24403
+ createTimestamp: createTimestamp,
24404
+ }, onEntrySubmitted: undefined, allowAttachments: showAttachments }));
24405
+ } })),
24406
+ React__default.createElement(Grid2, { container: true, size: { xs: 12 } },
24407
+ React__default.createElement(Grid2, { container: true, size: { md: 6, xs: 12 }, spacing: 1 },
24408
+ React__default.createElement(Grid2, { size: { md: 6, xs: 12 } },
24409
+ React__default.createElement(Button, { fullWidth: true, variant: "contained", color: "inherit", onClick: function () { return onHide(); } }, "Close"))))))) : null,
24410
+ React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
24411
+ };
24412
+
24413
+ var customPeriodOptions = [
24414
+ { value: "Day", label: "Day" },
24415
+ { value: "4Days", label: "4 Days" },
24416
+ { value: "Week", label: "Week" },
24417
+ { value: "Month", label: "Month" },
24418
+ { value: "Custom", label: "Custom" },
24419
+ ];
24420
+ var Filters = function (_a) {
24421
+ var quickFilter = _a.quickFilter, onQuickFilterChange = _a.onQuickFilterChange, shiftPeriod = _a.shiftPeriod, onChangeShiftPeriod = _a.onChangeShiftPeriod, actualPeriod = _a.actualPeriod, selectedSections = _a.selectedSections, onSectionsChange = _a.onSectionsChange;
24422
+ var handleShiftPeriodChange = function (value, period) {
24423
+ onChangeShiftPeriod(value, period);
24424
+ };
24425
+ useMesfRealtime({
24426
+ onReceiveMessage: function (author, message) {
24427
+ if (message.replaceAll("[", "").replaceAll("]", "") == "LB.GetEntries") ;
24428
+ },
24429
+ });
24430
+ return (React__default.createElement(Paper, { elevation: 1, style: { padding: 8 } },
24431
+ React__default.createElement(Grid2, { container: true, spacing: 1 },
24432
+ React__default.createElement(Grid2, { size: { xs: 12 }, alignItems: "center", justifyContent: "center" },
24433
+ React__default.createElement(ShiftPeriodNavigatorControl, { onChange: handleShiftPeriodChange, value: shiftPeriod, actualPeriod: actualPeriod, showShiftAndCrews: false, dateFormat: "MM/DD/YYYY", periodOptions: customPeriodOptions })),
24434
+ React__default.createElement(Grid2, { size: { xs: 12, md: 3 } },
24435
+ React__default.createElement(TextField, { fullWidth: true, label: "Search", variant: "outlined", size: "small", value: quickFilter, onChange: function (event) {
24436
+ onQuickFilterChange(event === null || event === void 0 ? void 0 : event.target.value);
24437
+ }, InputProps: {
24438
+ startAdornment: (React__default.createElement(InputAdornment, { position: "start" },
24439
+ React__default.createElement(IconButton$1, { edge: "start", type: "submit" },
24440
+ React__default.createElement(SearchIcon, null)))),
24441
+ } })),
24442
+ React__default.createElement(Grid2, { size: { xs: 12, md: 9 } },
24443
+ React__default.createElement(SectionMultiSelect, { value: selectedSections, onChange: onSectionsChange, label: "Sections" })))));
24444
+ };
24445
+
24446
+ var moment = getMomentTz();
24447
+ // Default layout matching original Grid md:5 / md:7 ratio (41.67% / 58.33%)
24448
+ var DEFAULT_LAYOUT = { left: 42, right: 58 };
24449
+ var Logbook = function () {
24450
+ var report = useLogbookSettings().report;
24451
+ var showAttachments = report.showAttachments;
24452
+ var showAsset = report.showAsset;
24453
+ var showShiftCrew = report.showShiftCrew;
24454
+ var exportToExcel = report.exportToExcel;
24455
+ var _a = useSearchParams(), searchParams = _a[0], setSearchParams = _a[1];
24456
+ var entryId = searchParams.get("entryId");
24457
+ var gridApiRef = useRef(null);
24458
+ var _b = useState(""), error = _b[0], setError = _b[1];
24459
+ var _c = useState(""), show = _c[0], setShow = _c[1];
24460
+ var _d = useState(function () {
24461
+ var startShiftIdParam = searchParams.get("startShiftId");
24462
+ var endShiftIdParam = searchParams.get("endShiftId");
24463
+ return {
24464
+ StartShiftId: startShiftIdParam ? Number(startShiftIdParam) : null,
24465
+ EndShiftId: endShiftIdParam ? Number(endShiftIdParam) : null,
24466
+ };
24467
+ }), shiftPeriod = _d[0], setShiftPeriod = _d[1];
24468
+ var _e = useState(""), quickFilter = _e[0], setQuickFilter = _e[1];
24469
+ var _f = useState(null), selectedRowData = _f[0], setSelectedRowData = _f[1];
24470
+ // Section filter state
24471
+ var _g = useState([]), filterSections = _g[0], setFilterSections = _g[1];
24472
+ var updateUrl = function (_a) {
24473
+ var startShiftId = _a.startShiftId, endShiftId = _a.endShiftId, period = _a.period, entryId = _a.entryId;
24474
+ var newParams = new URLSearchParams(searchParams);
24475
+ if (startShiftId) {
24476
+ newParams.set("startShiftId", startShiftId.toString());
24477
+ }
24478
+ else if (startShiftId === null) {
24479
+ newParams.delete("startShiftId");
24480
+ }
24481
+ if (endShiftId) {
24482
+ newParams.set("endShiftId", endShiftId.toString());
24483
+ }
24484
+ else if (endShiftId === null) {
24485
+ newParams.delete("endShiftId");
24486
+ }
24487
+ if (period) {
24488
+ newParams.set("period", period);
24489
+ }
24490
+ else if (period === null) {
24491
+ newParams.delete("period");
24492
+ }
24493
+ if (entryId) {
24494
+ newParams.set("entryId", entryId);
24495
+ }
24496
+ else if (entryId === null) {
24497
+ newParams.delete("entryId");
24498
+ }
24499
+ setSearchParams(newParams);
24500
+ };
24501
+ var _h = useEntriesReport({
24502
+ startShiftId: shiftPeriod.StartShiftId,
24503
+ endShiftId: shiftPeriod.EndShiftId,
24504
+ assetId: null,
24505
+ sectionIds: filterSections.map(function (s) { return s.SectionId; }),
24506
+ }), rows = _h.data, isLoading = _h.isLoading, e = _h.error, isError = _h.isError, refetch = _h.refetch;
24507
+ var columnDefs = useTableData({
24508
+ showAttachments: showAttachments,
24509
+ showAsset: showAsset,
24510
+ showShiftCrew: showShiftCrew,
24511
+ }).columnDefs;
24512
+ var defaultColDef = useGridDefinitions({}).defaultColDef;
24513
+ // Resizable panels layout persistence
24514
+ var _j = useDefaultLayout({
24515
+ id: "section-logbook-report-v2",
24516
+ storage: localStorage,
24517
+ }), savedLayout = _j.defaultLayout, onLayoutChange = _j.onLayoutChange;
24518
+ // Use saved layout or default to avoid flash on initial render
24519
+ var resolvedLayout = savedLayout !== null && savedLayout !== void 0 ? savedLayout : DEFAULT_LAYOUT;
24520
+ var onQuickFilterChange = function (text) {
24521
+ var _a;
24522
+ setQuickFilter(text);
24523
+ (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.setGridOption("quickFilterText", text);
24524
+ };
24525
+ var rowClicked = function (event) {
24526
+ var _a, _b;
24527
+ setSelectedRowData(event === null || event === void 0 ? void 0 : event.data);
24528
+ updateUrl({ entryId: (_b = (_a = event.data) === null || _a === void 0 ? void 0 : _a.EntryId) === null || _b === void 0 ? void 0 : _b.toString() });
24529
+ setShow("view");
24530
+ };
24531
+ var onCellKeyDown = useCallback(function (event) {
24532
+ var _a, _b;
24533
+ var api = event.api, node = event.node, keyEvent = event.event;
24534
+ if (!keyEvent)
24535
+ return;
24536
+ var key = keyEvent.key;
24537
+ if (key === "ArrowUp" || key === "ArrowDown") {
24538
+ keyEvent.preventDefault();
24539
+ var currentIndex = node.rowIndex !== null ? node.rowIndex : -1;
24540
+ var nextRowIndex = key === "ArrowUp" ? currentIndex - 1 : currentIndex + 1;
24541
+ var nextNode = api.getDisplayedRowAtIndex(nextRowIndex);
24542
+ if (nextNode) {
24543
+ nextNode.setSelected(true);
24544
+ api.ensureIndexVisible(nextRowIndex);
24545
+ setSelectedRowData(nextNode.data);
24546
+ updateUrl({ entryId: (_b = (_a = nextNode.data) === null || _a === void 0 ? void 0 : _a.EntryId) === null || _b === void 0 ? void 0 : _b.toString() });
24547
+ }
24548
+ }
24549
+ }, [setSelectedRowData]);
24550
+ var handleExportToExcel = function () {
24551
+ if (!gridApiRef.current)
24552
+ return;
24553
+ var params = {
24554
+ fileName: "Logbook_Report_Export.xlsx",
24555
+ columnKeys: [
24556
+ "AssetName",
24557
+ "CreateTimestamp",
24558
+ "Shift",
24559
+ "Crew",
24560
+ "Title",
24561
+ "CreatedBy",
24562
+ "Author",
24563
+ "Content",
24564
+ ],
24565
+ processCellCallback: function (params) {
24566
+ if (params.column.colId === "CreateTimestamp") {
24567
+ return moment(params.value).format("MM/DD/yy - HH:mm");
24568
+ }
24569
+ return params.value;
24570
+ },
24571
+ };
24572
+ gridApiRef.current.exportDataAsExcel(params);
24573
+ };
24574
+ useEffect(function () {
24575
+ var _a, _b, _c;
24576
+ if (!isLoading && entryId && gridApiRef.current) {
24577
+ var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryId);
24578
+ if (rowNode) {
24579
+ (_b = gridApiRef.current) === null || _b === void 0 ? void 0 : _b.ensureNodeVisible(rowNode);
24580
+ rowNode.setSelected(true);
24581
+ setSelectedRowData(rowNode.data);
24582
+ setShow("view");
24583
+ }
24584
+ }
24585
+ else if (!entryId) {
24586
+ setShow("");
24587
+ setSelectedRowData(null);
24588
+ (_c = gridApiRef.current) === null || _c === void 0 ? void 0 : _c.deselectAll();
24589
+ }
24590
+ }, [gridApiRef.current, isLoading, entryId]);
24591
+ useEffect(function () {
24592
+ if (isError) {
24593
+ setError(e.message);
24594
+ }
24595
+ }, [isError, e]);
24596
+ useEffect(function () {
24597
+ var _a;
24598
+ var startShiftIdParam = searchParams.get("startShiftId");
24599
+ var endShiftIdParam = searchParams.get("endShiftId");
24600
+ var entryIdParam = searchParams.get("entryId");
24601
+ if (startShiftIdParam || endShiftIdParam) {
24602
+ setShiftPeriod({
24603
+ StartShiftId: startShiftIdParam ? Number(startShiftIdParam) : null,
24604
+ EndShiftId: endShiftIdParam ? Number(endShiftIdParam) : null,
24605
+ });
24606
+ }
24607
+ // Handle entryId from URL on initial load
24608
+ if (entryIdParam && gridApiRef.current) {
24609
+ var rowNode = (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.getRowNode(entryIdParam);
24610
+ if (rowNode) {
24611
+ rowNode.setSelected(true);
24612
+ setSelectedRowData(rowNode.data);
24613
+ setShow("view");
24614
+ }
24615
+ }
24616
+ }, []);
24617
+ useEffect(function () {
24618
+ if (shiftPeriod.StartShiftId !== null || shiftPeriod.EndShiftId !== null) {
24619
+ setShow("");
24620
+ setSelectedRowData(null);
24621
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
24622
+ return __generator(this, function (_a) {
24623
+ switch (_a.label) {
24624
+ case 0: return [4 /*yield*/, refetch()];
24625
+ case 1:
24626
+ _a.sent();
24627
+ return [2 /*return*/];
24628
+ }
24629
+ });
24630
+ }); })();
24631
+ }
24632
+ }, [shiftPeriod.StartShiftId, shiftPeriod.EndShiftId]);
24633
+ return (React__default.createElement(Box, { sx: {
24634
+ width: "100%",
24635
+ height: "calc(100vh - 130px)",
24636
+ display: "flex",
24637
+ flexDirection: "column",
24638
+ } },
24639
+ React__default.createElement(Box, { sx: { mb: 2 } },
24640
+ React__default.createElement(Typography$1, { variant: "h5", style: {
24641
+ fontWeight: 600,
24642
+ userSelect: "none",
24643
+ } }, "LOGBOOK REPORT")),
24644
+ React__default.createElement(Group$1, { id: "section-logbook-report-group", orientation: "horizontal", defaultLayout: resolvedLayout, onLayoutChange: onLayoutChange, style: { flex: 1, width: "100%" } },
24645
+ React__default.createElement(Panel, { id: "left", defaultSize: 42, minSize: 25, style: { paddingBottom: 5 } },
24646
+ React__default.createElement(Box, { sx: {
24647
+ display: "flex",
24648
+ flexDirection: "column",
24649
+ gap: 1,
24650
+ height: "100%",
24651
+ pr: 1,
24652
+ } },
24653
+ React__default.createElement(Filters, { quickFilter: quickFilter, onQuickFilterChange: onQuickFilterChange, shiftPeriod: shiftPeriod, onChangeShiftPeriod: function (value, period) {
24654
+ setShiftPeriod(value);
24655
+ updateUrl({
24656
+ startShiftId: value.StartShiftId,
24657
+ endShiftId: value.EndShiftId,
24658
+ period: period,
24659
+ entryId: searchParams.get("entryId"),
24660
+ });
24661
+ }, actualPeriod: searchParams.get("period"), selectedSections: filterSections, onSectionsChange: setFilterSections }),
24662
+ React__default.createElement(Paper, { elevation: 1, style: {
24663
+ flex: 1,
24664
+ width: "100%",
24665
+ } },
24666
+ React__default.createElement(AgGridReact, { loading: isLoading, rowData: rows, columnDefs: columnDefs, defaultColDef: defaultColDef, rowHeight: 38, headerHeight: 42, loadingOverlayComponent: CenteredLazyLoading, animateRows: true, onRowClicked: rowClicked, onCellKeyDown: onCellKeyDown, onGridReady: function (params) { return (gridApiRef.current = params.api); }, getRowId: function (params) { return "".concat(params.data.EntryId); }, gridOptions: {
24667
+ rowSelection: {
24668
+ mode: "singleRow",
24669
+ checkboxes: false,
24670
+ enableClickSelection: true,
24671
+ },
24672
+ statusBar: {
24673
+ statusPanels: [
24674
+ exportToExcel
24675
+ ? {
24676
+ statusPanel: function (params) { return (React__default.createElement("div", { style: {
24677
+ display: "flex",
24678
+ alignItems: "center",
24679
+ paddingTop: 1,
24680
+ paddingBottom: 1,
24681
+ } },
24682
+ React__default.createElement(ExcelButton, { handleExportToExcel: handleExportToExcel }))); },
24683
+ align: "right",
24684
+ }
24685
+ : {},
24686
+ ],
24687
+ },
24688
+ } })))),
24689
+ React__default.createElement(Separator, { style: {
24690
+ display: "flex",
24691
+ alignItems: "center",
24692
+ justifyContent: "center",
24693
+ cursor: "col-resize",
24694
+ } },
24695
+ React__default.createElement(Box, { sx: {
24696
+ width: 8,
24697
+ height: 48,
24698
+ borderRadius: 1,
24699
+ backgroundColor: "#e0e0e0",
24700
+ display: "flex",
24701
+ flexDirection: "column",
24702
+ alignItems: "center",
24703
+ justifyContent: "center",
24704
+ gap: "3px",
24705
+ transition: "background-color 0.2s",
24706
+ "&:hover": {
24707
+ backgroundColor: "primary.main",
24708
+ "& .grip-dot": {
24709
+ backgroundColor: "#fff",
24710
+ },
24711
+ },
24712
+ } }, __spreadArray([], Array(5), true).map(function (_, i) { return (React__default.createElement(Box, { key: i, className: "grip-dot", sx: {
24713
+ width: 4,
24714
+ height: 4,
24715
+ borderRadius: "50%",
24716
+ backgroundColor: "#9e9e9e",
24717
+ transition: "background-color 0.2s",
24718
+ } })); }))),
24719
+ React__default.createElement(Panel, { id: "right", defaultSize: 58, minSize: 30, style: { paddingBottom: 5 } },
24720
+ React__default.createElement(Box, { sx: { pl: 1, height: "100%" } },
24721
+ React__default.createElement(EntryViewer, { entry: selectedRowData, show: show, onChangeShow: function () { return setShow(show === "view" ? "edit" : "view"); }, onHide: function () {
24722
+ var _a;
24723
+ setShow("");
24724
+ setSelectedRowData(null);
24725
+ (_a = gridApiRef.current) === null || _a === void 0 ? void 0 : _a.deselectAll();
24726
+ updateUrl({ entryId: null });
24727
+ }, showAsset: showAsset, showAttachments: showAttachments, showSection: true })))),
24728
+ React__default.createElement(ErrorModal, { error: error, onHide: function () { return setError(""); } })));
24729
+ };
24730
+
24731
+ var LogbookPage = function () {
24732
+ return (React__default.createElement(React__default.Fragment, null,
24733
+ React__default.createElement(HelmetDexteel, { title: "Logbook Report" }),
24734
+ React__default.createElement(Grid2, { container: true, style: { padding: "1.5rem" } },
24735
+ React__default.createElement(Logbook, null))));
24736
+ };
24737
+
24738
+ var MESFLogbookReport = function () {
24739
+ return React__default.createElement(LogbookPage, null);
24740
+ };
24741
+
24742
+ var sectionLogbookRoutesMESF = [
24743
+ {
24744
+ path: "/logbook/entry",
24745
+ element: React__default.createElement(MESFLogbookEntry),
24746
+ },
24747
+ {
24748
+ path: "/logbook/entry/:shiftId",
24749
+ element: React__default.createElement(MESFLogbookEntry),
24750
+ },
24751
+ {
24752
+ path: "/logbook/report",
24753
+ element: React__default.createElement(MESFLogbookReport),
24754
+ },
24755
+ ];
24756
+ var sectionLogbookNavbar = [
24757
+ {
24758
+ id: "logbook",
24759
+ label: "Logbook",
24760
+ items: [
24761
+ {
24762
+ label: "Logbook Entry",
24763
+ to: "/logbook/entry",
24764
+ },
24765
+ {
24766
+ label: "Logbook Report",
24767
+ to: "/logbook/report",
24768
+ },
24769
+ ],
24770
+ },
24771
+ ];
24772
+
21991
24773
  var AreaSelector = function () {
21992
24774
  var _a = useState(false), open = _a[0], setOpen = _a[1];
21993
24775
  var _b = useState(""), error = _b[0], setError = _b[1];
@@ -22116,5 +24898,5 @@ var areaSelector = /*#__PURE__*/Object.freeze({
22116
24898
  AreaSelector: AreaSelector
22117
24899
  });
22118
24900
 
22119
- 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, EditAssetDialog, ErrorModal, ExcelIcon, FetchError, FilterPanel, GenericPanel, GenericTable, GetCrewColor, GetShiftColor, HelmetDexteel, IntegerFormatter, LogbookSettingsInitialState, LogbookSettingsProvider, Login, Logout, LongFilterPanel, MESApiService, MESFLogbookEntry, MESFLogbookReport, MESFMain, MESSAGE_API, MESSAGE_ERRORS, MasterDetailPanel, MesfModal, ModalTreeFilterControl, MultipleSelectorControl, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, TrendingsPage, USER_LABELS, UTLSettingsProvider, UserProvider, axiosInstance, deleteUser, dxtServerTimeZone, dxtToLocalServerTime, dxtToUTC, formatNumber, getAuthTypes, getCrewStyle, getDataUser, getEntries, getError, getMomentTz, getShiftByParameters, getShiftStyle, getShiftsRangeByParameters, getTokenFromLS, getUserPermissionsFromAPI, getUsers, logbookNavbar, logbookRoutesMESF, renewToken, routeLogbookEntry, routeLogbookReport, useSearchAssets as searchAssets, useSearchSeries as searchSeries, useSearchTagsTree as searchTagsTree, useSearchViewTags as searchViewTags, useSearchViews as searchViews, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useToken, useUTLSettingsContext, useUserContext };
24901
+ 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, NumberFormatter, RemoveAssetDialog, SPExecutorPage, ShiftDayNavigatorControl, ShiftNavigatorProvider, ShiftPeriodNavigatorControl, SimplePasswordControl, SimpleSelectorControl, TimeAndUserMenu, TimeFormatter, TimeService, TreePickerControl, TreePickerControlV2, TrendingsPage, 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, useSearchSeries as searchSeries, useSearchTagsTree as searchTagsTree, useSearchViewTags as searchViewTags, useSearchViews as searchViews, sectionLogbookNavbar, sectionLogbookRoutesMESF, setPassword, setProfilesToUser, themeDXT, themeMESF, upsertUser, useAssetContext, useContextMenuMESF, useHasPermission, useHasProfile, useLogbookSettings, useMesfRealtime, useShiftNavigator, useShiftNavigatorManager, useToken, useUTLSettingsContext, useUserContext };
22120
24902
  //# sourceMappingURL=index.esm.js.map