@optifye/dashboard-core 6.9.14 → 6.9.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +0 -3
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +369 -273
- package/dist/index.mjs +370 -274
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32882,7 +32882,7 @@ var ShiftDisplay = React23.memo(({ className, variant = "default", lineId }) =>
|
|
|
32882
32882
|
return null;
|
|
32883
32883
|
}
|
|
32884
32884
|
};
|
|
32885
|
-
const
|
|
32885
|
+
const getShiftIcon = (shift) => {
|
|
32886
32886
|
if (shift === "Day") {
|
|
32887
32887
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fillRule: "evenodd", d: "M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z", clipRule: "evenodd" }) });
|
|
32888
32888
|
} else {
|
|
@@ -32908,7 +32908,7 @@ var ShiftDisplay = React23.memo(({ className, variant = "default", lineId }) =>
|
|
|
32908
32908
|
}
|
|
32909
32909
|
if (variant === "enhanced") {
|
|
32910
32910
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `inline-flex items-center gap-2 bg-blue-50 rounded-lg px-3 py-1.5 ${className ?? ""}`, children: [
|
|
32911
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-800", children:
|
|
32911
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-800", children: getShiftIcon(currentShiftText) }),
|
|
32912
32912
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-base font-medium text-blue-800", children: [
|
|
32913
32913
|
currentShiftText,
|
|
32914
32914
|
" Shift"
|
|
@@ -32916,7 +32916,7 @@ var ShiftDisplay = React23.memo(({ className, variant = "default", lineId }) =>
|
|
|
32916
32916
|
] });
|
|
32917
32917
|
}
|
|
32918
32918
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `inline-flex items-center gap-2 bg-blue-50 rounded-lg px-3 py-1.5 ${className ?? ""}`, children: [
|
|
32919
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-800", children:
|
|
32919
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-800", children: getShiftIcon(currentShiftText) }),
|
|
32920
32920
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-base font-medium text-blue-800", children: [
|
|
32921
32921
|
currentShiftText,
|
|
32922
32922
|
" Shift"
|
|
@@ -37414,7 +37414,7 @@ var DashboardHeader = React23.memo(({ lineTitle, className = "", headerControls,
|
|
|
37414
37414
|
const rawName = currentShift.shiftName || "Day";
|
|
37415
37415
|
return rawName.toLowerCase().includes("shift") ? rawName : `${rawName} Shift`;
|
|
37416
37416
|
};
|
|
37417
|
-
const
|
|
37417
|
+
const getShiftIcon = () => {
|
|
37418
37418
|
const currentShift = getCurrentShift(timezone, shiftConfig);
|
|
37419
37419
|
const shiftName = (currentShift.shiftName || "").toLowerCase();
|
|
37420
37420
|
if (shiftName.includes("day") || shiftName.includes("morning") || currentShift.shiftId === 0) {
|
|
@@ -37437,7 +37437,7 @@ var DashboardHeader = React23.memo(({ lineTitle, className = "", headerControls,
|
|
|
37437
37437
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-0.5 sm:mt-2 inline-flex flex-wrap items-center gap-1.5 sm:gap-3", children: [
|
|
37438
37438
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[10px] sm:text-xs md:text-sm font-medium text-gray-500 sm:text-gray-600 whitespace-nowrap", children: /* @__PURE__ */ jsxRuntime.jsx(Timer2, {}) }),
|
|
37439
37439
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center gap-0.5 sm:gap-1", children: isShiftConfigLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-16 sm:w-20 bg-gray-200 rounded animate-pulse" }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
37440
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-500 sm:text-gray-600 scale-90 sm:scale-100", children:
|
|
37440
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-500 sm:text-gray-600 scale-90 sm:scale-100", children: getShiftIcon() }),
|
|
37441
37441
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] sm:text-xs md:text-sm font-medium text-gray-500 sm:text-gray-600 whitespace-nowrap", children: getShiftName() })
|
|
37442
37442
|
] }) })
|
|
37443
37443
|
] })
|
|
@@ -42463,7 +42463,7 @@ var FactoryView = ({
|
|
|
42463
42463
|
const currentShift = getCurrentShiftInfo();
|
|
42464
42464
|
return (currentShift.shiftName || "Day").replace(/ Shift$/i, "");
|
|
42465
42465
|
};
|
|
42466
|
-
const
|
|
42466
|
+
const getShiftIcon = () => {
|
|
42467
42467
|
const currentShift = getCurrentShiftInfo();
|
|
42468
42468
|
const shiftNameLower = (currentShift.shiftName || "").toLowerCase();
|
|
42469
42469
|
if (shiftNameLower.includes("day") || shiftNameLower.includes("morning") || currentShift.shiftId === 0) {
|
|
@@ -42501,7 +42501,7 @@ var FactoryView = ({
|
|
|
42501
42501
|
" IST"
|
|
42502
42502
|
] }),
|
|
42503
42503
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-flex items-center gap-1", children: [
|
|
42504
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-600", children:
|
|
42504
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-600", children: getShiftIcon() }),
|
|
42505
42505
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm font-medium text-gray-600", children: [
|
|
42506
42506
|
getShiftName(),
|
|
42507
42507
|
" Shift"
|
|
@@ -44036,7 +44036,7 @@ var KPIDetailView = ({
|
|
|
44036
44036
|
const getShiftName = React23.useCallback((shiftId) => {
|
|
44037
44037
|
return getShiftNameById(shiftId, configuredTimezone, shiftConfig);
|
|
44038
44038
|
}, [configuredTimezone, shiftConfig]);
|
|
44039
|
-
const
|
|
44039
|
+
const getShiftIcon = React23.useCallback((shiftId) => {
|
|
44040
44040
|
if (shiftId === 0) {
|
|
44041
44041
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
|
|
44042
44042
|
}
|
|
@@ -44510,7 +44510,7 @@ var KPIDetailView = ({
|
|
|
44510
44510
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
44511
44511
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-gray-100 rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-gray-700", children: metrics2 && formatLocalDate(new Date(metrics2.date)) }) }),
|
|
44512
44512
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-gray-100 rounded-full", children: [
|
|
44513
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-700 scale-90", children:
|
|
44513
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-700 scale-90", children: getShiftIcon(metrics2.shift_id ?? 0) }),
|
|
44514
44514
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-gray-700", children: [
|
|
44515
44515
|
getShiftName(metrics2.shift_id ?? 0).replace(/ Shift$/i, ""),
|
|
44516
44516
|
" Shift"
|
|
@@ -44530,7 +44530,7 @@ var KPIDetailView = ({
|
|
|
44530
44530
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px h-4 bg-blue-300" })
|
|
44531
44531
|
] }),
|
|
44532
44532
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
44533
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children:
|
|
44533
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children: getShiftIcon(metrics2.shift_id ?? 0) }),
|
|
44534
44534
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm md:text-base font-medium text-blue-600", children: [
|
|
44535
44535
|
getShiftName(metrics2.shift_id ?? 0).replace(/ Shift$/i, ""),
|
|
44536
44536
|
" Shift"
|
|
@@ -44907,7 +44907,7 @@ var KPIsOverviewView = ({
|
|
|
44907
44907
|
};
|
|
44908
44908
|
const currentShiftDetails = getCurrentShift(configuredTimezone, shiftConfig);
|
|
44909
44909
|
const shiftName = (currentShiftDetails.shiftName || "Day").replace(/ Shift$/i, "");
|
|
44910
|
-
const
|
|
44910
|
+
const getShiftIcon = (shiftId) => {
|
|
44911
44911
|
const shiftNameLower = shiftName.toLowerCase();
|
|
44912
44912
|
if (shiftNameLower.includes("day") || shiftNameLower.includes("morning") || shiftId === 0) {
|
|
44913
44913
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
|
|
@@ -45028,7 +45028,7 @@ var KPIsOverviewView = ({
|
|
|
45028
45028
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
45029
45029
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-gray-100 rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-gray-700", children: formatLocalDate2(/* @__PURE__ */ new Date()) }) }),
|
|
45030
45030
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-gray-100 rounded-full", children: [
|
|
45031
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-700 scale-90", children:
|
|
45031
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-700 scale-90", children: getShiftIcon(currentShiftDetails.shiftId) }),
|
|
45032
45032
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-gray-700", children: shiftName })
|
|
45033
45033
|
] }),
|
|
45034
45034
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-green-100 rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-green-700", children: /* @__PURE__ */ jsxRuntime.jsx(ISTTimer_default, {}) }) })
|
|
@@ -45039,7 +45039,7 @@ var KPIsOverviewView = ({
|
|
|
45039
45039
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm md:text-base font-medium text-blue-600", children: formatLocalDate2(/* @__PURE__ */ new Date()) }),
|
|
45040
45040
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px h-4 bg-blue-300" }),
|
|
45041
45041
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
45042
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children:
|
|
45042
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children: getShiftIcon(currentShiftDetails.shiftId) }),
|
|
45043
45043
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm md:text-base font-medium text-blue-600", children: [
|
|
45044
45044
|
shiftName,
|
|
45045
45045
|
" Shift"
|
|
@@ -45067,10 +45067,10 @@ var HeaderRibbon = React23.memo(({
|
|
|
45067
45067
|
currentDate,
|
|
45068
45068
|
currentMobileDate,
|
|
45069
45069
|
shiftId,
|
|
45070
|
-
getShiftIcon
|
|
45070
|
+
getShiftIcon,
|
|
45071
45071
|
getShiftName
|
|
45072
45072
|
}) => {
|
|
45073
|
-
const shiftIcon = React23.useMemo(() =>
|
|
45073
|
+
const shiftIcon = React23.useMemo(() => getShiftIcon(shiftId), [getShiftIcon, shiftId]);
|
|
45074
45074
|
const shiftName = React23.useMemo(() => getShiftName(shiftId), [getShiftName, shiftId]);
|
|
45075
45075
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
45076
45076
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
@@ -45268,7 +45268,7 @@ var LeaderboardDetailView = React23.memo(({
|
|
|
45268
45268
|
const currentShift = getCurrentShift(timezone || "Asia/Kolkata", shiftConfig);
|
|
45269
45269
|
return currentShift.shiftName || getShiftNameById(currentShift.shiftId, timezone || "Asia/Kolkata", shiftConfig);
|
|
45270
45270
|
}, [timezone, shiftConfig]);
|
|
45271
|
-
const
|
|
45271
|
+
const getShiftIcon = React23.useCallback((shiftId2) => {
|
|
45272
45272
|
const effectiveShiftId = shiftId2 !== void 0 ? shiftId2 : getCurrentShift(timezone || "Asia/Kolkata", shiftConfig).shiftId;
|
|
45273
45273
|
const shiftNameLower = getShiftName(effectiveShiftId).toLowerCase();
|
|
45274
45274
|
if (shiftNameLower.includes("day") || shiftNameLower.includes("morning")) {
|
|
@@ -45478,7 +45478,7 @@ var LeaderboardDetailView = React23.memo(({
|
|
|
45478
45478
|
currentDate: currentDateFormatted,
|
|
45479
45479
|
currentMobileDate: currentMobileDateFormatted,
|
|
45480
45480
|
shiftId,
|
|
45481
|
-
getShiftIcon
|
|
45481
|
+
getShiftIcon,
|
|
45482
45482
|
getShiftName
|
|
45483
45483
|
}
|
|
45484
45484
|
)
|
|
@@ -45837,23 +45837,6 @@ var ProfileView = () => {
|
|
|
45837
45837
|
] }) });
|
|
45838
45838
|
};
|
|
45839
45839
|
var ProfileView_default = ProfileView;
|
|
45840
|
-
var DEFAULT_TIMEZONE = "Asia/Kolkata";
|
|
45841
|
-
var DEFAULT_SHIFTS = [
|
|
45842
|
-
{
|
|
45843
|
-
shiftId: 0,
|
|
45844
|
-
shiftName: "Day Shift",
|
|
45845
|
-
startTime: "08:00",
|
|
45846
|
-
endTime: "16:00",
|
|
45847
|
-
breaks: []
|
|
45848
|
-
},
|
|
45849
|
-
{
|
|
45850
|
-
shiftId: 1,
|
|
45851
|
-
shiftName: "Night Shift",
|
|
45852
|
-
startTime: "20:00",
|
|
45853
|
-
endTime: "04:00",
|
|
45854
|
-
breaks: []
|
|
45855
|
-
}
|
|
45856
|
-
];
|
|
45857
45840
|
var calculateShiftHours = (startTime, endTime, breaks = []) => {
|
|
45858
45841
|
if (!startTime || !endTime) return 8;
|
|
45859
45842
|
const [startHour, startMinute] = startTime.split(":").map(Number);
|
|
@@ -45920,19 +45903,6 @@ var formatBreaks = (breaks) => {
|
|
|
45920
45903
|
}))
|
|
45921
45904
|
};
|
|
45922
45905
|
};
|
|
45923
|
-
var getShiftIcon = (shiftId, shiftName) => {
|
|
45924
|
-
const nameLower = shiftName.toLowerCase();
|
|
45925
|
-
if (nameLower.includes("day") || nameLower.includes("morning") || shiftId === 0) {
|
|
45926
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
|
|
45927
|
-
}
|
|
45928
|
-
if (nameLower.includes("afternoon") || nameLower.includes("noon") || nameLower.includes("midday")) {
|
|
45929
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
|
|
45930
|
-
}
|
|
45931
|
-
if (nameLower.includes("night") || nameLower.includes("evening") || shiftId === 1) {
|
|
45932
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" }) });
|
|
45933
|
-
}
|
|
45934
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock, { className: "w-5 h-5 text-gray-600" });
|
|
45935
|
-
};
|
|
45936
45906
|
var BreakRow = React23.memo(({
|
|
45937
45907
|
break: breakItem,
|
|
45938
45908
|
onUpdate,
|
|
@@ -46060,13 +46030,9 @@ var ShiftPanel = React23.memo(({
|
|
|
46060
46030
|
onBreakUpdate,
|
|
46061
46031
|
onBreakRemove,
|
|
46062
46032
|
onBreakAdd,
|
|
46063
|
-
shiftHours
|
|
46064
|
-
shiftId,
|
|
46065
|
-
onShiftNameChange,
|
|
46066
|
-
canDelete = false,
|
|
46067
|
-
onDelete
|
|
46033
|
+
shiftHours
|
|
46068
46034
|
}) => {
|
|
46069
|
-
const panelId = `panel-${title.toLowerCase().replace(/\s+/g, "-")}
|
|
46035
|
+
const panelId = `panel-${title.toLowerCase().replace(/\s+/g, "-")}`;
|
|
46070
46036
|
const storageKey = `shift_panel_${panelId}_minimized`;
|
|
46071
46037
|
const [isMinimized, setIsMinimized] = React23.useState(true);
|
|
46072
46038
|
React23.useEffect(() => {
|
|
@@ -46093,7 +46059,7 @@ var ShiftPanel = React23.memo(({
|
|
|
46093
46059
|
"button",
|
|
46094
46060
|
{
|
|
46095
46061
|
onClick: toggleMinimize,
|
|
46096
|
-
className: "flex items-center gap-2 sm:gap-3 text-base sm:text-lg font-medium transition-colors duration-200\n focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 rounded-lg\n hover:bg-blue-50 px-2 sm:px-3 py-1.5 sm:py-2 group w-full sm:w-auto justify-start",
|
|
46062
|
+
className: "flex items-center gap-2 sm:gap-3 text-base sm:text-lg font-medium transition-colors duration-200 \n focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 rounded-lg \n hover:bg-blue-50 px-2 sm:px-3 py-1.5 sm:py-2 group w-full sm:w-auto justify-start",
|
|
46097
46063
|
"aria-expanded": !isMinimized,
|
|
46098
46064
|
"aria-controls": panelId,
|
|
46099
46065
|
children: [
|
|
@@ -46110,42 +46076,15 @@ var ShiftPanel = React23.memo(({
|
|
|
46110
46076
|
]
|
|
46111
46077
|
}
|
|
46112
46078
|
),
|
|
46113
|
-
/* @__PURE__ */ jsxRuntime.jsxs("
|
|
46114
|
-
|
|
46115
|
-
|
|
46116
|
-
|
|
46117
|
-
" hours"
|
|
46118
|
-
] }),
|
|
46119
|
-
canDelete && onDelete && /* @__PURE__ */ jsxRuntime.jsx(
|
|
46120
|
-
"button",
|
|
46121
|
-
{
|
|
46122
|
-
onClick: (e) => {
|
|
46123
|
-
e.stopPropagation();
|
|
46124
|
-
onDelete();
|
|
46125
|
-
},
|
|
46126
|
-
className: "p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded transition-colors",
|
|
46127
|
-
"aria-label": "Delete shift",
|
|
46128
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "w-4 h-4" })
|
|
46129
|
-
}
|
|
46130
|
-
)
|
|
46079
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs sm:text-sm font-medium text-gray-600 text-center sm:text-right sm:mr-2", children: [
|
|
46080
|
+
"Total Shift Hours: ",
|
|
46081
|
+
shiftHours,
|
|
46082
|
+
" hours"
|
|
46131
46083
|
] })
|
|
46132
46084
|
] })
|
|
46133
46085
|
}
|
|
46134
46086
|
),
|
|
46135
46087
|
!isMinimized && /* @__PURE__ */ jsxRuntime.jsxs("div", { id: panelId, className: "p-3 sm:p-4 md:p-6 border-t border-gray-200 w-full bg-white", children: [
|
|
46136
|
-
onShiftNameChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-4 sm:mb-6", children: [
|
|
46137
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "block text-xs sm:text-sm font-medium text-gray-700 mb-1", children: "Shift Name" }),
|
|
46138
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
46139
|
-
"input",
|
|
46140
|
-
{
|
|
46141
|
-
type: "text",
|
|
46142
|
-
value: title,
|
|
46143
|
-
onChange: (e) => onShiftNameChange(e.target.value),
|
|
46144
|
-
placeholder: "Enter shift name",
|
|
46145
|
-
className: "w-full sm:w-64 px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500"
|
|
46146
|
-
}
|
|
46147
|
-
)
|
|
46148
|
-
] }),
|
|
46149
46088
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-4 md:gap-6 mb-4 sm:mb-6 w-full", children: [
|
|
46150
46089
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
|
|
46151
46090
|
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "block text-xs sm:text-sm font-medium text-gray-700 mb-1", children: "Shift Start Time" }),
|
|
@@ -46239,9 +46178,16 @@ var ShiftsView = ({
|
|
|
46239
46178
|
() => lineIds.map((id3) => ({
|
|
46240
46179
|
id: id3,
|
|
46241
46180
|
name: lineNames[id3] || `Line ${id3.substring(0, 4)}`,
|
|
46242
|
-
|
|
46243
|
-
|
|
46244
|
-
|
|
46181
|
+
dayShift: {
|
|
46182
|
+
startTime: "08:00",
|
|
46183
|
+
endTime: "16:00",
|
|
46184
|
+
breaks: []
|
|
46185
|
+
},
|
|
46186
|
+
nightShift: {
|
|
46187
|
+
startTime: "20:00",
|
|
46188
|
+
endTime: "04:00",
|
|
46189
|
+
breaks: []
|
|
46190
|
+
},
|
|
46245
46191
|
isOpen: true,
|
|
46246
46192
|
isSaving: false,
|
|
46247
46193
|
saveSuccess: false
|
|
@@ -46265,47 +46211,77 @@ var ShiftsView = ({
|
|
|
46265
46211
|
try {
|
|
46266
46212
|
setLoading(true);
|
|
46267
46213
|
setError(null);
|
|
46268
|
-
const { data:
|
|
46269
|
-
if (
|
|
46270
|
-
console.error("
|
|
46271
|
-
showToast("error", "Error loading
|
|
46272
|
-
setError("Failed to load
|
|
46214
|
+
const { data: enabledLines, error: linesError } = await supabase.from("lines").select("id, enable").in("id", lineIds).eq("enable", true);
|
|
46215
|
+
if (linesError) {
|
|
46216
|
+
console.error("Error fetching enabled lines:", linesError);
|
|
46217
|
+
showToast("error", "Error loading lines");
|
|
46218
|
+
setError("Failed to load lines");
|
|
46219
|
+
setLoading(false);
|
|
46273
46220
|
return;
|
|
46274
46221
|
}
|
|
46275
|
-
|
|
46276
|
-
|
|
46277
|
-
|
|
46278
|
-
|
|
46279
|
-
|
|
46280
|
-
|
|
46281
|
-
|
|
46282
|
-
|
|
46283
|
-
|
|
46284
|
-
|
|
46285
|
-
|
|
46286
|
-
|
|
46287
|
-
|
|
46288
|
-
|
|
46222
|
+
const enabledLineIds = (enabledLines || []).map((line) => line.id);
|
|
46223
|
+
if (enabledLineIds.length === 0) {
|
|
46224
|
+
setLineConfigs([]);
|
|
46225
|
+
setLoading(false);
|
|
46226
|
+
return;
|
|
46227
|
+
}
|
|
46228
|
+
const { data: dayShiftOperatingHours, error: dayShiftError } = await supabase.from("line_operating_hours").select("line_id, start_time, end_time, breaks").eq("shift_id", 0).in("line_id", enabledLineIds);
|
|
46229
|
+
if (dayShiftError) {
|
|
46230
|
+
console.error("Error fetching day shift operating hours:", dayShiftError);
|
|
46231
|
+
showToast("error", "Error loading day shift data");
|
|
46232
|
+
setError("Failed to load day shift data");
|
|
46233
|
+
return;
|
|
46234
|
+
}
|
|
46235
|
+
const { data: nightShiftOperatingHours, error: nightShiftError } = await supabase.from("line_operating_hours").select("line_id, start_time, end_time, breaks").eq("shift_id", 1).in("line_id", enabledLineIds);
|
|
46236
|
+
if (nightShiftError) {
|
|
46237
|
+
console.error("Error fetching night shift operating hours:", nightShiftError);
|
|
46238
|
+
showToast("error", "Error loading night shift data");
|
|
46239
|
+
setError("Failed to load night shift data");
|
|
46240
|
+
return;
|
|
46241
|
+
}
|
|
46242
|
+
const dayShiftHoursMap = (dayShiftOperatingHours || []).reduce((map, item) => {
|
|
46243
|
+
map[item.line_id] = {
|
|
46244
|
+
startTime: item.start_time,
|
|
46245
|
+
endTime: item.end_time,
|
|
46246
|
+
breaks: parseBreaksFromDB(item.breaks)
|
|
46247
|
+
};
|
|
46248
|
+
return map;
|
|
46249
|
+
}, {});
|
|
46250
|
+
const nightShiftHoursMap = (nightShiftOperatingHours || []).reduce((map, item) => {
|
|
46251
|
+
map[item.line_id] = {
|
|
46252
|
+
startTime: item.start_time,
|
|
46253
|
+
endTime: item.end_time,
|
|
46254
|
+
breaks: parseBreaksFromDB(item.breaks)
|
|
46255
|
+
};
|
|
46256
|
+
return map;
|
|
46257
|
+
}, {});
|
|
46258
|
+
setLineConfigs((prev) => {
|
|
46259
|
+
const enabledConfigs = prev.filter((config) => enabledLineIds.includes(config.id));
|
|
46260
|
+
return enabledConfigs.map((config) => {
|
|
46261
|
+
const typedConfig = config;
|
|
46262
|
+
const lineId = typedConfig.id;
|
|
46263
|
+
const newConfig = { ...typedConfig };
|
|
46264
|
+
if (dayShiftHoursMap[lineId]) {
|
|
46265
|
+
newConfig.dayShift = {
|
|
46266
|
+
...newConfig.dayShift,
|
|
46267
|
+
...dayShiftHoursMap[lineId]
|
|
46268
|
+
};
|
|
46269
|
+
}
|
|
46270
|
+
if (nightShiftHoursMap[lineId]) {
|
|
46271
|
+
newConfig.nightShift = {
|
|
46272
|
+
...newConfig.nightShift,
|
|
46273
|
+
...nightShiftHoursMap[lineId]
|
|
46274
|
+
};
|
|
46275
|
+
}
|
|
46276
|
+
if (newConfig.isOpen === void 0) {
|
|
46277
|
+
newConfig.isOpen = getStoredLineState(lineId);
|
|
46278
|
+
}
|
|
46279
|
+
return newConfig;
|
|
46289
46280
|
});
|
|
46290
|
-
if (row.timezone && !timezoneByLine[row.line_id]) {
|
|
46291
|
-
timezoneByLine[row.line_id] = row.timezone;
|
|
46292
|
-
}
|
|
46293
46281
|
});
|
|
46294
|
-
setLineConfigs((prev) => prev.map((config) => {
|
|
46295
|
-
const lineId = config.id;
|
|
46296
|
-
const lineShifts = shiftsByLine[lineId];
|
|
46297
|
-
const lineTimezone = timezoneByLine[lineId] || DEFAULT_TIMEZONE;
|
|
46298
|
-
const shifts = lineShifts && lineShifts.length > 0 ? lineShifts.sort((a, b) => a.shiftId - b.shiftId) : DEFAULT_SHIFTS.map((s) => ({ ...s }));
|
|
46299
|
-
return {
|
|
46300
|
-
...config,
|
|
46301
|
-
timezone: lineTimezone,
|
|
46302
|
-
shifts,
|
|
46303
|
-
isOpen: config.isOpen ?? getStoredLineState(lineId)
|
|
46304
|
-
};
|
|
46305
|
-
}));
|
|
46306
46282
|
setLoading(false);
|
|
46307
46283
|
} catch (error2) {
|
|
46308
|
-
console.error("
|
|
46284
|
+
console.error("Error fetching shift configurations:", error2);
|
|
46309
46285
|
showToast("error", "Failed to load shift configurations");
|
|
46310
46286
|
setError("Failed to load shift configurations");
|
|
46311
46287
|
setLoading(false);
|
|
@@ -46315,125 +46291,195 @@ var ShiftsView = ({
|
|
|
46315
46291
|
}, [lineIds, showToast]);
|
|
46316
46292
|
React23.useCallback((lineId) => {
|
|
46317
46293
|
setLineConfigs((prev) => {
|
|
46318
|
-
const
|
|
46294
|
+
const typedPrev = prev;
|
|
46295
|
+
const newIsOpen = !typedPrev.find((config) => config.id === lineId)?.isOpen;
|
|
46319
46296
|
localStorage.setItem(`line_${lineId}_open`, JSON.stringify(newIsOpen));
|
|
46320
|
-
return
|
|
46297
|
+
return typedPrev.map(
|
|
46321
46298
|
(config) => config.id === lineId ? { ...config, isOpen: newIsOpen } : config
|
|
46322
46299
|
);
|
|
46323
46300
|
});
|
|
46324
46301
|
}, []);
|
|
46325
|
-
const
|
|
46302
|
+
const updateDayShiftStartTime = React23.useCallback((lineId, value) => {
|
|
46326
46303
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46327
|
-
|
|
46328
|
-
|
|
46329
|
-
|
|
46330
|
-
|
|
46331
|
-
|
|
46304
|
+
const typedConfig = config;
|
|
46305
|
+
if (typedConfig.id === lineId) {
|
|
46306
|
+
const updatedDayShift = { ...typedConfig.dayShift, startTime: value };
|
|
46307
|
+
return {
|
|
46308
|
+
...typedConfig,
|
|
46309
|
+
dayShift: updatedDayShift
|
|
46310
|
+
};
|
|
46332
46311
|
}
|
|
46333
|
-
return
|
|
46312
|
+
return typedConfig;
|
|
46334
46313
|
}));
|
|
46335
46314
|
}, []);
|
|
46336
|
-
const
|
|
46315
|
+
const updateDayShiftEndTime = React23.useCallback((lineId, value) => {
|
|
46337
46316
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46338
|
-
|
|
46339
|
-
|
|
46340
|
-
|
|
46341
|
-
|
|
46342
|
-
|
|
46317
|
+
const typedConfig = config;
|
|
46318
|
+
if (typedConfig.id === lineId) {
|
|
46319
|
+
const updatedDayShift = { ...typedConfig.dayShift, endTime: value };
|
|
46320
|
+
return {
|
|
46321
|
+
...typedConfig,
|
|
46322
|
+
dayShift: updatedDayShift
|
|
46323
|
+
};
|
|
46343
46324
|
}
|
|
46344
|
-
return
|
|
46325
|
+
return typedConfig;
|
|
46345
46326
|
}));
|
|
46346
46327
|
}, []);
|
|
46347
|
-
React23.useCallback((lineId, value) => {
|
|
46348
|
-
setLineConfigs((prev) => prev.map(
|
|
46349
|
-
|
|
46350
|
-
|
|
46328
|
+
const updateNightShiftStartTime = React23.useCallback((lineId, value) => {
|
|
46329
|
+
setLineConfigs((prev) => prev.map((config) => {
|
|
46330
|
+
const typedConfig = config;
|
|
46331
|
+
if (typedConfig.id === lineId) {
|
|
46332
|
+
const updatedNightShift = { ...typedConfig.nightShift, startTime: value };
|
|
46333
|
+
return {
|
|
46334
|
+
...typedConfig,
|
|
46335
|
+
nightShift: updatedNightShift
|
|
46336
|
+
};
|
|
46337
|
+
}
|
|
46338
|
+
return typedConfig;
|
|
46339
|
+
}));
|
|
46351
46340
|
}, []);
|
|
46352
|
-
const
|
|
46341
|
+
const updateNightShiftEndTime = React23.useCallback((lineId, value) => {
|
|
46353
46342
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46354
|
-
|
|
46355
|
-
|
|
46356
|
-
|
|
46357
|
-
|
|
46358
|
-
|
|
46359
|
-
|
|
46360
|
-
|
|
46361
|
-
|
|
46362
|
-
|
|
46363
|
-
|
|
46343
|
+
const typedConfig = config;
|
|
46344
|
+
if (typedConfig.id === lineId) {
|
|
46345
|
+
const updatedNightShift = { ...typedConfig.nightShift, endTime: value };
|
|
46346
|
+
return {
|
|
46347
|
+
...typedConfig,
|
|
46348
|
+
nightShift: updatedNightShift
|
|
46349
|
+
};
|
|
46350
|
+
}
|
|
46351
|
+
return typedConfig;
|
|
46352
|
+
}));
|
|
46353
|
+
}, []);
|
|
46354
|
+
const addDayShiftBreak = React23.useCallback((lineId) => {
|
|
46355
|
+
setLineConfigs((prev) => prev.map((config) => {
|
|
46356
|
+
const typedConfig = config;
|
|
46357
|
+
if (typedConfig.id === lineId) {
|
|
46358
|
+
const dayShift = { ...typedConfig.dayShift };
|
|
46359
|
+
const newBreak = {
|
|
46360
|
+
startTime: dayShift.startTime,
|
|
46361
|
+
endTime: dayShift.startTime,
|
|
46362
|
+
duration: 0,
|
|
46363
|
+
remarks: ""
|
|
46364
|
+
};
|
|
46365
|
+
return {
|
|
46366
|
+
...typedConfig,
|
|
46367
|
+
dayShift: {
|
|
46368
|
+
...dayShift,
|
|
46369
|
+
breaks: [...dayShift.breaks, newBreak]
|
|
46364
46370
|
}
|
|
46365
|
-
|
|
46366
|
-
});
|
|
46367
|
-
return { ...config, shifts: updatedShifts };
|
|
46371
|
+
};
|
|
46368
46372
|
}
|
|
46369
|
-
return
|
|
46373
|
+
return typedConfig;
|
|
46370
46374
|
}));
|
|
46371
46375
|
}, []);
|
|
46372
|
-
const
|
|
46376
|
+
const addNightShiftBreak = React23.useCallback((lineId) => {
|
|
46373
46377
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46374
|
-
|
|
46375
|
-
|
|
46376
|
-
|
|
46377
|
-
|
|
46378
|
-
|
|
46379
|
-
|
|
46380
|
-
|
|
46381
|
-
|
|
46382
|
-
|
|
46383
|
-
|
|
46384
|
-
|
|
46385
|
-
|
|
46378
|
+
const typedConfig = config;
|
|
46379
|
+
if (typedConfig.id === lineId) {
|
|
46380
|
+
const nightShift = { ...typedConfig.nightShift };
|
|
46381
|
+
const newBreak = {
|
|
46382
|
+
startTime: nightShift.startTime,
|
|
46383
|
+
endTime: nightShift.startTime,
|
|
46384
|
+
duration: 0
|
|
46385
|
+
};
|
|
46386
|
+
return {
|
|
46387
|
+
...typedConfig,
|
|
46388
|
+
nightShift: {
|
|
46389
|
+
...nightShift,
|
|
46390
|
+
breaks: [...nightShift.breaks, newBreak]
|
|
46386
46391
|
}
|
|
46387
|
-
|
|
46388
|
-
});
|
|
46389
|
-
return { ...config, shifts: updatedShifts };
|
|
46392
|
+
};
|
|
46390
46393
|
}
|
|
46391
|
-
return
|
|
46394
|
+
return typedConfig;
|
|
46392
46395
|
}));
|
|
46393
46396
|
}, []);
|
|
46394
|
-
const
|
|
46397
|
+
const updateDayShiftBreak = React23.useCallback((lineId, index, field, value) => {
|
|
46395
46398
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46396
|
-
|
|
46397
|
-
|
|
46398
|
-
|
|
46399
|
-
|
|
46399
|
+
const typedConfig = config;
|
|
46400
|
+
if (typedConfig.id === lineId) {
|
|
46401
|
+
const dayShift = { ...typedConfig.dayShift };
|
|
46402
|
+
const newBreaks = [...dayShift.breaks];
|
|
46403
|
+
newBreaks[index] = { ...newBreaks[index], [field]: value };
|
|
46404
|
+
if (field === "startTime" || field === "endTime") {
|
|
46405
|
+
const startParts = newBreaks[index].startTime.split(":").map(Number);
|
|
46406
|
+
const endParts = newBreaks[index].endTime.split(":").map(Number);
|
|
46407
|
+
let startMinutes = startParts[0] * 60 + startParts[1];
|
|
46408
|
+
let endMinutes = endParts[0] * 60 + endParts[1];
|
|
46409
|
+
if (endMinutes < startMinutes) {
|
|
46410
|
+
endMinutes += 24 * 60;
|
|
46411
|
+
}
|
|
46412
|
+
newBreaks[index].duration = endMinutes - startMinutes;
|
|
46413
|
+
}
|
|
46414
|
+
return {
|
|
46415
|
+
...typedConfig,
|
|
46416
|
+
dayShift: {
|
|
46417
|
+
...dayShift,
|
|
46418
|
+
breaks: newBreaks
|
|
46400
46419
|
}
|
|
46401
|
-
|
|
46402
|
-
});
|
|
46403
|
-
return { ...config, shifts: updatedShifts };
|
|
46420
|
+
};
|
|
46404
46421
|
}
|
|
46405
|
-
return
|
|
46422
|
+
return typedConfig;
|
|
46406
46423
|
}));
|
|
46407
46424
|
}, []);
|
|
46408
|
-
React23.useCallback((lineId) => {
|
|
46425
|
+
const updateNightShiftBreak = React23.useCallback((lineId, index, field, value) => {
|
|
46426
|
+
setLineConfigs((prev) => prev.map((config) => {
|
|
46427
|
+
const typedConfig = config;
|
|
46428
|
+
if (typedConfig.id === lineId) {
|
|
46429
|
+
const nightShift = { ...typedConfig.nightShift };
|
|
46430
|
+
const newBreaks = [...nightShift.breaks];
|
|
46431
|
+
newBreaks[index] = { ...newBreaks[index], [field]: value };
|
|
46432
|
+
if (field === "startTime" || field === "endTime") {
|
|
46433
|
+
const startParts = newBreaks[index].startTime.split(":").map(Number);
|
|
46434
|
+
const endParts = newBreaks[index].endTime.split(":").map(Number);
|
|
46435
|
+
let startMinutes = startParts[0] * 60 + startParts[1];
|
|
46436
|
+
let endMinutes = endParts[0] * 60 + endParts[1];
|
|
46437
|
+
if (endMinutes < startMinutes) {
|
|
46438
|
+
endMinutes += 24 * 60;
|
|
46439
|
+
}
|
|
46440
|
+
newBreaks[index].duration = endMinutes - startMinutes;
|
|
46441
|
+
}
|
|
46442
|
+
return {
|
|
46443
|
+
...typedConfig,
|
|
46444
|
+
nightShift: {
|
|
46445
|
+
...nightShift,
|
|
46446
|
+
breaks: newBreaks
|
|
46447
|
+
}
|
|
46448
|
+
};
|
|
46449
|
+
}
|
|
46450
|
+
return typedConfig;
|
|
46451
|
+
}));
|
|
46452
|
+
}, []);
|
|
46453
|
+
const removeDayShiftBreak = React23.useCallback((lineId, index) => {
|
|
46409
46454
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46410
46455
|
if (config.id === lineId) {
|
|
46411
|
-
const
|
|
46412
|
-
|
|
46413
|
-
|
|
46414
|
-
|
|
46415
|
-
|
|
46416
|
-
|
|
46417
|
-
|
|
46418
|
-
breaks: []
|
|
46456
|
+
const dayShift = { ...config.dayShift };
|
|
46457
|
+
return {
|
|
46458
|
+
...config,
|
|
46459
|
+
dayShift: {
|
|
46460
|
+
...dayShift,
|
|
46461
|
+
breaks: dayShift.breaks.filter((_, i) => i !== index)
|
|
46462
|
+
}
|
|
46419
46463
|
};
|
|
46420
|
-
return { ...config, shifts: [...config.shifts, newShift] };
|
|
46421
46464
|
}
|
|
46422
46465
|
return config;
|
|
46423
46466
|
}));
|
|
46424
46467
|
}, []);
|
|
46425
|
-
const
|
|
46468
|
+
const removeNightShiftBreak = React23.useCallback((lineId, index) => {
|
|
46426
46469
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46427
46470
|
if (config.id === lineId) {
|
|
46428
|
-
|
|
46429
|
-
|
|
46430
|
-
|
|
46431
|
-
|
|
46432
|
-
|
|
46471
|
+
const nightShift = { ...config.nightShift };
|
|
46472
|
+
return {
|
|
46473
|
+
...config,
|
|
46474
|
+
nightShift: {
|
|
46475
|
+
...nightShift,
|
|
46476
|
+
breaks: nightShift.breaks.filter((_, i) => i !== index)
|
|
46477
|
+
}
|
|
46478
|
+
};
|
|
46433
46479
|
}
|
|
46434
46480
|
return config;
|
|
46435
46481
|
}));
|
|
46436
|
-
}, [
|
|
46482
|
+
}, []);
|
|
46437
46483
|
const handleSaveShifts = React23.useCallback(async (lineId) => {
|
|
46438
46484
|
setLineConfigs((prev) => prev.map(
|
|
46439
46485
|
(config) => config.id === lineId ? { ...config, isSaving: true, saveSuccess: false } : config
|
|
@@ -46443,31 +46489,27 @@ var ShiftsView = ({
|
|
|
46443
46489
|
if (!lineConfig) {
|
|
46444
46490
|
throw new Error("Line configuration not found");
|
|
46445
46491
|
}
|
|
46446
|
-
|
|
46447
|
-
|
|
46448
|
-
|
|
46449
|
-
|
|
46450
|
-
|
|
46451
|
-
|
|
46452
|
-
|
|
46453
|
-
|
|
46454
|
-
|
|
46455
|
-
|
|
46456
|
-
|
|
46457
|
-
|
|
46458
|
-
|
|
46459
|
-
|
|
46460
|
-
|
|
46492
|
+
const dayShiftData = {
|
|
46493
|
+
line_id: lineId,
|
|
46494
|
+
shift_id: 0,
|
|
46495
|
+
start_time: lineConfig.dayShift.startTime,
|
|
46496
|
+
end_time: lineConfig.dayShift.endTime,
|
|
46497
|
+
breaks: formatBreaks(lineConfig.dayShift.breaks)
|
|
46498
|
+
};
|
|
46499
|
+
const nightShiftData = {
|
|
46500
|
+
line_id: lineId,
|
|
46501
|
+
shift_id: 1,
|
|
46502
|
+
start_time: lineConfig.nightShift.startTime,
|
|
46503
|
+
end_time: lineConfig.nightShift.endTime,
|
|
46504
|
+
breaks: formatBreaks(lineConfig.nightShift.breaks)
|
|
46505
|
+
};
|
|
46506
|
+
const dayResult = await supabase.from("line_operating_hours").upsert(dayShiftData).select();
|
|
46507
|
+
if (dayResult.error) {
|
|
46508
|
+
throw new Error(`Failed to save day shift: ${dayResult.error.message}`);
|
|
46461
46509
|
}
|
|
46462
|
-
const
|
|
46463
|
-
|
|
46464
|
-
|
|
46465
|
-
if (shiftsToDelete.length > 0) {
|
|
46466
|
-
console.log("[ShiftsView] Deleting removed shifts:", shiftsToDelete);
|
|
46467
|
-
const { error: deleteError } = await supabase.from("line_operating_hours").delete().eq("line_id", lineId).in("shift_id", shiftsToDelete);
|
|
46468
|
-
if (deleteError) {
|
|
46469
|
-
console.error("[ShiftsView] Error deleting shifts:", deleteError);
|
|
46470
|
-
}
|
|
46510
|
+
const nightResult = await supabase.from("line_operating_hours").upsert(nightShiftData).select();
|
|
46511
|
+
if (nightResult.error) {
|
|
46512
|
+
throw new Error(`Failed to save night shift: ${nightResult.error.message}`);
|
|
46471
46513
|
}
|
|
46472
46514
|
setLineConfigs((prev) => prev.map(
|
|
46473
46515
|
(config) => config.id === lineId ? { ...config, isSaving: false, saveSuccess: true } : config
|
|
@@ -46479,7 +46521,7 @@ var ShiftsView = ({
|
|
|
46479
46521
|
));
|
|
46480
46522
|
}, 3e3);
|
|
46481
46523
|
} catch (error2) {
|
|
46482
|
-
console.error("
|
|
46524
|
+
console.error("Error saving shift configurations:", error2);
|
|
46483
46525
|
showToast("error", "Failed to save shift configurations");
|
|
46484
46526
|
setLineConfigs((prev) => prev.map(
|
|
46485
46527
|
(config) => config.id === lineId ? { ...config, isSaving: false, saveSuccess: false } : config
|
|
@@ -46499,7 +46541,7 @@ var ShiftsView = ({
|
|
|
46499
46541
|
) }),
|
|
46500
46542
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center mt-2 sm:mt-0", children: [
|
|
46501
46543
|
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg sm:text-xl md:text-2xl lg:text-3xl font-semibold text-gray-900 text-center", children: "Shift Management" }),
|
|
46502
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs sm:text-sm text-gray-500 mt-0.5 sm:mt-1 text-center px-2 sm:px-0", children: "Configure shift timings and breaks for each production line" })
|
|
46544
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs sm:text-sm text-gray-500 mt-0.5 sm:mt-1 text-center px-2 sm:px-0", children: "Configure day and night shift timings and breaks for each production line" })
|
|
46503
46545
|
] }),
|
|
46504
46546
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:block absolute right-0 w-24" })
|
|
46505
46547
|
] }) }) }),
|
|
@@ -46519,11 +46561,6 @@ var ShiftsView = ({
|
|
|
46519
46561
|
/* @__PURE__ */ jsxRuntime.jsxs("h2", { className: "text-base sm:text-lg font-semibold text-gray-800", children: [
|
|
46520
46562
|
config.name,
|
|
46521
46563
|
" Shifts"
|
|
46522
|
-
] }),
|
|
46523
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-gray-400", children: [
|
|
46524
|
-
"(",
|
|
46525
|
-
config.shifts.length,
|
|
46526
|
-
" shifts)"
|
|
46527
46564
|
] })
|
|
46528
46565
|
] }),
|
|
46529
46566
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row items-start sm:items-center gap-2 sm:gap-4 w-full sm:w-auto", children: [
|
|
@@ -46551,27 +46588,48 @@ var ShiftsView = ({
|
|
|
46551
46588
|
)
|
|
46552
46589
|
] })
|
|
46553
46590
|
] }) }),
|
|
46554
|
-
/* @__PURE__ */ jsxRuntime.
|
|
46555
|
-
|
|
46556
|
-
|
|
46557
|
-
|
|
46558
|
-
|
|
46559
|
-
|
|
46560
|
-
|
|
46561
|
-
|
|
46562
|
-
|
|
46563
|
-
|
|
46564
|
-
|
|
46565
|
-
|
|
46566
|
-
|
|
46567
|
-
|
|
46568
|
-
|
|
46569
|
-
|
|
46570
|
-
|
|
46571
|
-
|
|
46572
|
-
|
|
46573
|
-
|
|
46574
|
-
|
|
46591
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { id: `shift-panel-${config.id}`, className: "p-3 sm:p-4 md:p-6 border-t border-gray-200 w-full", children: [
|
|
46592
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
46593
|
+
ShiftPanel,
|
|
46594
|
+
{
|
|
46595
|
+
title: "Day Shift",
|
|
46596
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) }),
|
|
46597
|
+
startTime: config.dayShift.startTime,
|
|
46598
|
+
endTime: config.dayShift.endTime,
|
|
46599
|
+
breaks: config.dayShift.breaks,
|
|
46600
|
+
onStartTimeChange: (value) => updateDayShiftStartTime(config.id, value),
|
|
46601
|
+
onEndTimeChange: (value) => updateDayShiftEndTime(config.id, value),
|
|
46602
|
+
onBreakUpdate: (index, field, value) => updateDayShiftBreak(config.id, index, field, value),
|
|
46603
|
+
onBreakRemove: (index) => removeDayShiftBreak(config.id, index),
|
|
46604
|
+
onBreakAdd: () => addDayShiftBreak(config.id),
|
|
46605
|
+
shiftHours: calculateShiftHours(
|
|
46606
|
+
config.dayShift.startTime,
|
|
46607
|
+
config.dayShift.endTime,
|
|
46608
|
+
config.dayShift.breaks
|
|
46609
|
+
)
|
|
46610
|
+
}
|
|
46611
|
+
),
|
|
46612
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
46613
|
+
ShiftPanel,
|
|
46614
|
+
{
|
|
46615
|
+
title: "Night Shift",
|
|
46616
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" }) }),
|
|
46617
|
+
startTime: config.nightShift.startTime,
|
|
46618
|
+
endTime: config.nightShift.endTime,
|
|
46619
|
+
breaks: config.nightShift.breaks,
|
|
46620
|
+
onStartTimeChange: (value) => updateNightShiftStartTime(config.id, value),
|
|
46621
|
+
onEndTimeChange: (value) => updateNightShiftEndTime(config.id, value),
|
|
46622
|
+
onBreakUpdate: (index, field, value) => updateNightShiftBreak(config.id, index, field, value),
|
|
46623
|
+
onBreakRemove: (index) => removeNightShiftBreak(config.id, index),
|
|
46624
|
+
onBreakAdd: () => addNightShiftBreak(config.id),
|
|
46625
|
+
shiftHours: calculateShiftHours(
|
|
46626
|
+
config.nightShift.startTime,
|
|
46627
|
+
config.nightShift.endTime,
|
|
46628
|
+
config.nightShift.breaks
|
|
46629
|
+
)
|
|
46630
|
+
}
|
|
46631
|
+
)
|
|
46632
|
+
] })
|
|
46575
46633
|
] }, config.id)) })
|
|
46576
46634
|
] })
|
|
46577
46635
|
] });
|
|
@@ -47767,7 +47825,7 @@ var TargetsView = ({
|
|
|
47767
47825
|
onSaveChanges
|
|
47768
47826
|
}) => {
|
|
47769
47827
|
const timezone = useAppTimezone();
|
|
47770
|
-
|
|
47828
|
+
React23.useMemo(() => {
|
|
47771
47829
|
return lineIds.reduce((acc, lineId) => ({
|
|
47772
47830
|
...acc,
|
|
47773
47831
|
[lineId]: {
|
|
@@ -47805,7 +47863,7 @@ var TargetsView = ({
|
|
|
47805
47863
|
const canSaveTargets = useCanSaveTargets();
|
|
47806
47864
|
const [dbValues, setDbValues] = React23.useState({ 0: {}, 1: {} });
|
|
47807
47865
|
const [userEditedFields, setUserEditedFields] = React23.useState(/* @__PURE__ */ new Set());
|
|
47808
|
-
const lineWorkspaces = allShiftsData[selectedShift] ||
|
|
47866
|
+
const lineWorkspaces = allShiftsData[selectedShift] || {};
|
|
47809
47867
|
const setLineWorkspaces = React23.useCallback((updater) => {
|
|
47810
47868
|
setAllShiftsData((prev) => ({
|
|
47811
47869
|
...prev,
|
|
@@ -47934,6 +47992,37 @@ var TargetsView = ({
|
|
|
47934
47992
|
newAllShiftsData[shiftId][lineId].workspaces = mappedWorkspaces;
|
|
47935
47993
|
});
|
|
47936
47994
|
});
|
|
47995
|
+
effectiveShiftOptions.forEach(({ id: shiftId }) => {
|
|
47996
|
+
lineIds.forEach((lineId) => {
|
|
47997
|
+
if (!newAllShiftsData[shiftId][lineId]) {
|
|
47998
|
+
const lineData = data.lines[lineId];
|
|
47999
|
+
const shift0Data = newAllShiftsData[0]?.[lineId];
|
|
48000
|
+
const enabledWorkspaces = lineData?.workspaces?.filter((ws) => ws.enable === true) || [];
|
|
48001
|
+
const workspaces = enabledWorkspaces.map((ws) => ({
|
|
48002
|
+
id: ws.id,
|
|
48003
|
+
name: ws.workspace_id,
|
|
48004
|
+
targetPPH: "",
|
|
48005
|
+
targetCycleTime: "",
|
|
48006
|
+
targetDayOutput: "",
|
|
48007
|
+
actionType: "assembly",
|
|
48008
|
+
actionId: actionIdsData.assembly
|
|
48009
|
+
})).sort(
|
|
48010
|
+
(a, b) => a.name.localeCompare(b.name, void 0, { numeric: true })
|
|
48011
|
+
);
|
|
48012
|
+
newAllShiftsData[shiftId][lineId] = {
|
|
48013
|
+
productId: "",
|
|
48014
|
+
shiftStartTime: shift0Data?.shiftStartTime || "08:00",
|
|
48015
|
+
shiftEndTime: shift0Data?.shiftEndTime || "19:00",
|
|
48016
|
+
shiftHours: shift0Data?.shiftHours || 11,
|
|
48017
|
+
breaks: shift0Data?.breaks || [],
|
|
48018
|
+
workspaces,
|
|
48019
|
+
factoryId: shift0Data?.factoryId || lineData?.line_info?.factory_id
|
|
48020
|
+
};
|
|
48021
|
+
newDbValues[shiftId][lineId] = {};
|
|
48022
|
+
console.log(`[TargetsView] Initialized empty data for shift ${shiftId}, line ${lineId}`);
|
|
48023
|
+
}
|
|
48024
|
+
});
|
|
48025
|
+
});
|
|
47937
48026
|
setAllShiftsData(newAllShiftsData);
|
|
47938
48027
|
setDbValues(newDbValues);
|
|
47939
48028
|
console.log("[TargetsView] Successfully loaded all data with bulk endpoint:", {
|
|
@@ -48080,20 +48169,27 @@ var TargetsView = ({
|
|
|
48080
48169
|
};
|
|
48081
48170
|
const handleActionTypeChange = React23.useCallback((lineId, workspaceId, newActionType) => {
|
|
48082
48171
|
if (!actionIds) return;
|
|
48083
|
-
setLineWorkspaces((prev) =>
|
|
48084
|
-
|
|
48085
|
-
|
|
48086
|
-
|
|
48087
|
-
|
|
48088
|
-
(ws) => ws.id === workspaceId ? {
|
|
48089
|
-
...ws,
|
|
48090
|
-
actionType: newActionType,
|
|
48091
|
-
actionId: actionIds[newActionType]
|
|
48092
|
-
} : ws
|
|
48093
|
-
)
|
|
48172
|
+
setLineWorkspaces((prev) => {
|
|
48173
|
+
const currentLineData = prev?.[lineId];
|
|
48174
|
+
if (!currentLineData?.workspaces) {
|
|
48175
|
+
console.warn(`[handleActionTypeChange] No data for line ${lineId} in current shift`);
|
|
48176
|
+
return prev;
|
|
48094
48177
|
}
|
|
48095
|
-
|
|
48096
|
-
|
|
48178
|
+
return {
|
|
48179
|
+
...prev,
|
|
48180
|
+
[lineId]: {
|
|
48181
|
+
...currentLineData,
|
|
48182
|
+
workspaces: currentLineData.workspaces.map(
|
|
48183
|
+
(ws) => ws.id === workspaceId ? {
|
|
48184
|
+
...ws,
|
|
48185
|
+
actionType: newActionType,
|
|
48186
|
+
actionId: actionIds[newActionType]
|
|
48187
|
+
} : ws
|
|
48188
|
+
)
|
|
48189
|
+
}
|
|
48190
|
+
};
|
|
48191
|
+
});
|
|
48192
|
+
}, [actionIds, setLineWorkspaces]);
|
|
48097
48193
|
const handleSaveLine = React23.useCallback(async (lineId) => {
|
|
48098
48194
|
console.log(`[handleSaveLine] Attempting to save line: ${lineId}`);
|
|
48099
48195
|
if (!canSaveTargets) {
|
|
@@ -48642,7 +48738,7 @@ var WorkspaceDetailView = ({
|
|
|
48642
48738
|
}
|
|
48643
48739
|
}
|
|
48644
48740
|
};
|
|
48645
|
-
const
|
|
48741
|
+
const getShiftIcon = (shiftType) => {
|
|
48646
48742
|
const shiftTypeLower = shiftType?.toLowerCase() || "";
|
|
48647
48743
|
if (shiftTypeLower.includes("day") || shiftTypeLower.includes("morning")) {
|
|
48648
48744
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
|
|
@@ -48802,7 +48898,7 @@ var WorkspaceDetailView = ({
|
|
|
48802
48898
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
48803
48899
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-gray-100 rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-gray-700", children: formatISTDate2(new Date(workspace.date)) }) }),
|
|
48804
48900
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-gray-100 rounded-full", children: [
|
|
48805
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-700 scale-90", children:
|
|
48901
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-gray-700 scale-90", children: getShiftIcon(workspace.shift_type) }),
|
|
48806
48902
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-gray-700", children: workspace.shift_type })
|
|
48807
48903
|
] }),
|
|
48808
48904
|
!date && !shift && !usingFallbackData ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-green-100 rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-green-700", children: /* @__PURE__ */ jsxRuntime.jsx(LiveTimer, {}) }) }) : date ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-blue-100 rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-blue-700", children: getDaysDifference(workspace.date, timezone, dashboardConfig?.shiftConfig?.dayShift?.startTime || "06:00") }) }) : usingFallbackData ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-amber-100 rounded-full", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-amber-700", children: getDaysDifference(workspace.date, timezone, dashboardConfig?.shiftConfig?.dayShift?.startTime || "06:00") }) }) : null
|
|
@@ -48827,7 +48923,7 @@ var WorkspaceDetailView = ({
|
|
|
48827
48923
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-px h-4 bg-blue-300" })
|
|
48828
48924
|
] }),
|
|
48829
48925
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
48830
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children:
|
|
48926
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children: getShiftIcon(workspace.shift_type) }),
|
|
48831
48927
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm md:text-base font-medium text-blue-600", children: workspace.shift_type })
|
|
48832
48928
|
] })
|
|
48833
48929
|
] }) })
|
|
@@ -49918,7 +50014,7 @@ var WorkspaceHealthView = ({
|
|
|
49918
50014
|
timeZone: effectiveTimezone
|
|
49919
50015
|
});
|
|
49920
50016
|
};
|
|
49921
|
-
const
|
|
50017
|
+
const getShiftIcon = () => {
|
|
49922
50018
|
const shiftName = (currentShiftDetails.shiftName || "").toLowerCase();
|
|
49923
50019
|
if (shiftName.includes("night") || shiftName.includes("evening") || currentShiftDetails.shiftId === 1) {
|
|
49924
50020
|
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Moon, { className: "h-4 w-4" });
|
|
@@ -50109,7 +50205,7 @@ var WorkspaceHealthView = ({
|
|
|
50109
50205
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm md:text-base font-medium text-blue-600", children: formatDate(operationalDate) }),
|
|
50110
50206
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:block w-px h-4 bg-blue-300" }),
|
|
50111
50207
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 sm:gap-2", children: [
|
|
50112
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children:
|
|
50208
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-blue-600", children: getShiftIcon() }),
|
|
50113
50209
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs sm:text-sm md:text-base font-medium text-blue-600", children: [
|
|
50114
50210
|
shiftType,
|
|
50115
50211
|
" Shift"
|