@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.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import Hls3, { Events, ErrorTypes } from 'hls.js';
|
|
|
11
11
|
import useSWR from 'swr';
|
|
12
12
|
import { noop, warning, invariant, progress, secondsToMilliseconds, millisecondsToSeconds, memo as memo$1 } from 'motion-utils';
|
|
13
13
|
import { getValueTransition, hover, press, isPrimaryPointer, GroupPlaybackControls, setDragLock, supportsLinearEasing, attachTimeline, isGenerator, calcGeneratorDuration, isWaapiSupportedEasing, mapEasingToNativeEasing, maxGeneratorDuration, generateLinearEasing, isBezierDefinition } from 'motion-dom';
|
|
14
|
-
import { Camera, ChevronDown, ChevronUp, Check, Map as Map$1, Video, ShieldCheck, Star, Award, ArrowLeft, X,
|
|
14
|
+
import { Camera, ChevronDown, ChevronUp, Check, Map as Map$1, Video, ShieldCheck, Star, Award, ArrowLeft, X, Coffee, Plus, Clock, Calendar, Save, AlertCircle, Loader2, Minus, ArrowDown, ArrowUp, ChevronLeft, ChevronRight, Pause, Play, XCircle, Sparkles, TrendingUp, Settings2, CheckCircle2, RefreshCw, TrendingDown, FolderOpen, Folder, HelpCircle, Sliders, Activity, Layers, Filter, Search, Edit2, AlertTriangle, CheckCircle, Building2, Mail, Users, User, Lock, ArrowRight, Info, Share2, Trophy, Target, Download, Sun, Moon, MousePointer, MessageSquare, Trash2, Menu, Send, Copy, UserCheck, LogOut, Package, UserPlus, Settings, LifeBuoy, EyeOff, Eye, MoreVertical, UserCog, Zap, Shield, UserCircle } from 'lucide-react';
|
|
15
15
|
import { toast } from 'sonner';
|
|
16
16
|
import { BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, Tooltip, Legend, Bar, LabelList, ResponsiveContainer, LineChart as LineChart$1, Line, PieChart, Pie, Cell, ReferenceLine, ComposedChart, Area, ScatterChart, Scatter } from 'recharts';
|
|
17
17
|
import { Slot } from '@radix-ui/react-slot';
|
|
@@ -32853,7 +32853,7 @@ var ShiftDisplay = memo(({ className, variant = "default", lineId }) => {
|
|
|
32853
32853
|
return null;
|
|
32854
32854
|
}
|
|
32855
32855
|
};
|
|
32856
|
-
const
|
|
32856
|
+
const getShiftIcon = (shift) => {
|
|
32857
32857
|
if (shift === "Day") {
|
|
32858
32858
|
return /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ 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" }) });
|
|
32859
32859
|
} else {
|
|
@@ -32879,7 +32879,7 @@ var ShiftDisplay = memo(({ className, variant = "default", lineId }) => {
|
|
|
32879
32879
|
}
|
|
32880
32880
|
if (variant === "enhanced") {
|
|
32881
32881
|
return /* @__PURE__ */ jsxs("div", { className: `inline-flex items-center gap-2 bg-blue-50 rounded-lg px-3 py-1.5 ${className ?? ""}`, children: [
|
|
32882
|
-
/* @__PURE__ */ jsx("div", { className: "text-blue-800", children:
|
|
32882
|
+
/* @__PURE__ */ jsx("div", { className: "text-blue-800", children: getShiftIcon(currentShiftText) }),
|
|
32883
32883
|
/* @__PURE__ */ jsxs("span", { className: "text-base font-medium text-blue-800", children: [
|
|
32884
32884
|
currentShiftText,
|
|
32885
32885
|
" Shift"
|
|
@@ -32887,7 +32887,7 @@ var ShiftDisplay = memo(({ className, variant = "default", lineId }) => {
|
|
|
32887
32887
|
] });
|
|
32888
32888
|
}
|
|
32889
32889
|
return /* @__PURE__ */ jsxs("div", { className: `inline-flex items-center gap-2 bg-blue-50 rounded-lg px-3 py-1.5 ${className ?? ""}`, children: [
|
|
32890
|
-
/* @__PURE__ */ jsx("div", { className: "text-blue-800", children:
|
|
32890
|
+
/* @__PURE__ */ jsx("div", { className: "text-blue-800", children: getShiftIcon(currentShiftText) }),
|
|
32891
32891
|
/* @__PURE__ */ jsxs("span", { className: "text-base font-medium text-blue-800", children: [
|
|
32892
32892
|
currentShiftText,
|
|
32893
32893
|
" Shift"
|
|
@@ -37385,7 +37385,7 @@ var DashboardHeader = memo(({ lineTitle, className = "", headerControls, lineId
|
|
|
37385
37385
|
const rawName = currentShift.shiftName || "Day";
|
|
37386
37386
|
return rawName.toLowerCase().includes("shift") ? rawName : `${rawName} Shift`;
|
|
37387
37387
|
};
|
|
37388
|
-
const
|
|
37388
|
+
const getShiftIcon = () => {
|
|
37389
37389
|
const currentShift = getCurrentShift(timezone, shiftConfig);
|
|
37390
37390
|
const shiftName = (currentShift.shiftName || "").toLowerCase();
|
|
37391
37391
|
if (shiftName.includes("day") || shiftName.includes("morning") || currentShift.shiftId === 0) {
|
|
@@ -37408,7 +37408,7 @@ var DashboardHeader = memo(({ lineTitle, className = "", headerControls, lineId
|
|
|
37408
37408
|
/* @__PURE__ */ jsxs("div", { className: "mt-0.5 sm:mt-2 inline-flex flex-wrap items-center gap-1.5 sm:gap-3", children: [
|
|
37409
37409
|
/* @__PURE__ */ jsx("div", { className: "text-[10px] sm:text-xs md:text-sm font-medium text-gray-500 sm:text-gray-600 whitespace-nowrap", children: /* @__PURE__ */ jsx(Timer2, {}) }),
|
|
37410
37410
|
/* @__PURE__ */ jsx("div", { className: "inline-flex items-center gap-0.5 sm:gap-1", children: isShiftConfigLoading ? /* @__PURE__ */ jsx("div", { className: "h-4 w-16 sm:w-20 bg-gray-200 rounded animate-pulse" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37411
|
-
/* @__PURE__ */ jsx("div", { className: "text-gray-500 sm:text-gray-600 scale-90 sm:scale-100", children:
|
|
37411
|
+
/* @__PURE__ */ jsx("div", { className: "text-gray-500 sm:text-gray-600 scale-90 sm:scale-100", children: getShiftIcon() }),
|
|
37412
37412
|
/* @__PURE__ */ jsx("span", { className: "text-[10px] sm:text-xs md:text-sm font-medium text-gray-500 sm:text-gray-600 whitespace-nowrap", children: getShiftName() })
|
|
37413
37413
|
] }) })
|
|
37414
37414
|
] })
|
|
@@ -42434,7 +42434,7 @@ var FactoryView = ({
|
|
|
42434
42434
|
const currentShift = getCurrentShiftInfo();
|
|
42435
42435
|
return (currentShift.shiftName || "Day").replace(/ Shift$/i, "");
|
|
42436
42436
|
};
|
|
42437
|
-
const
|
|
42437
|
+
const getShiftIcon = () => {
|
|
42438
42438
|
const currentShift = getCurrentShiftInfo();
|
|
42439
42439
|
const shiftNameLower = (currentShift.shiftName || "").toLowerCase();
|
|
42440
42440
|
if (shiftNameLower.includes("day") || shiftNameLower.includes("morning") || currentShift.shiftId === 0) {
|
|
@@ -42472,7 +42472,7 @@ var FactoryView = ({
|
|
|
42472
42472
|
" IST"
|
|
42473
42473
|
] }),
|
|
42474
42474
|
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-1", children: [
|
|
42475
|
-
/* @__PURE__ */ jsx("div", { className: "text-gray-600", children:
|
|
42475
|
+
/* @__PURE__ */ jsx("div", { className: "text-gray-600", children: getShiftIcon() }),
|
|
42476
42476
|
/* @__PURE__ */ jsxs("span", { className: "text-sm font-medium text-gray-600", children: [
|
|
42477
42477
|
getShiftName(),
|
|
42478
42478
|
" Shift"
|
|
@@ -44007,7 +44007,7 @@ var KPIDetailView = ({
|
|
|
44007
44007
|
const getShiftName = useCallback((shiftId) => {
|
|
44008
44008
|
return getShiftNameById(shiftId, configuredTimezone, shiftConfig);
|
|
44009
44009
|
}, [configuredTimezone, shiftConfig]);
|
|
44010
|
-
const
|
|
44010
|
+
const getShiftIcon = useCallback((shiftId) => {
|
|
44011
44011
|
if (shiftId === 0) {
|
|
44012
44012
|
return /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) });
|
|
44013
44013
|
}
|
|
@@ -44481,7 +44481,7 @@ var KPIDetailView = ({
|
|
|
44481
44481
|
/* @__PURE__ */ jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
44482
44482
|
/* @__PURE__ */ jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-gray-100 rounded-full", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: metrics2 && formatLocalDate(new Date(metrics2.date)) }) }),
|
|
44483
44483
|
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-gray-100 rounded-full", children: [
|
|
44484
|
-
/* @__PURE__ */ jsx("div", { className: "text-gray-700 scale-90", children:
|
|
44484
|
+
/* @__PURE__ */ jsx("div", { className: "text-gray-700 scale-90", children: getShiftIcon(metrics2.shift_id ?? 0) }),
|
|
44485
44485
|
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium text-gray-700", children: [
|
|
44486
44486
|
getShiftName(metrics2.shift_id ?? 0).replace(/ Shift$/i, ""),
|
|
44487
44487
|
" Shift"
|
|
@@ -44501,7 +44501,7 @@ var KPIDetailView = ({
|
|
|
44501
44501
|
/* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-blue-300" })
|
|
44502
44502
|
] }),
|
|
44503
44503
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
44504
|
-
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children:
|
|
44504
|
+
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children: getShiftIcon(metrics2.shift_id ?? 0) }),
|
|
44505
44505
|
/* @__PURE__ */ jsxs("span", { className: "text-sm md:text-base font-medium text-blue-600", children: [
|
|
44506
44506
|
getShiftName(metrics2.shift_id ?? 0).replace(/ Shift$/i, ""),
|
|
44507
44507
|
" Shift"
|
|
@@ -44878,7 +44878,7 @@ var KPIsOverviewView = ({
|
|
|
44878
44878
|
};
|
|
44879
44879
|
const currentShiftDetails = getCurrentShift(configuredTimezone, shiftConfig);
|
|
44880
44880
|
const shiftName = (currentShiftDetails.shiftName || "Day").replace(/ Shift$/i, "");
|
|
44881
|
-
const
|
|
44881
|
+
const getShiftIcon = (shiftId) => {
|
|
44882
44882
|
const shiftNameLower = shiftName.toLowerCase();
|
|
44883
44883
|
if (shiftNameLower.includes("day") || shiftNameLower.includes("morning") || shiftId === 0) {
|
|
44884
44884
|
return /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) });
|
|
@@ -44999,7 +44999,7 @@ var KPIsOverviewView = ({
|
|
|
44999
44999
|
/* @__PURE__ */ jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
45000
45000
|
/* @__PURE__ */ jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-gray-100 rounded-full", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: formatLocalDate2(/* @__PURE__ */ new Date()) }) }),
|
|
45001
45001
|
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-gray-100 rounded-full", children: [
|
|
45002
|
-
/* @__PURE__ */ jsx("div", { className: "text-gray-700 scale-90", children:
|
|
45002
|
+
/* @__PURE__ */ jsx("div", { className: "text-gray-700 scale-90", children: getShiftIcon(currentShiftDetails.shiftId) }),
|
|
45003
45003
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: shiftName })
|
|
45004
45004
|
] }),
|
|
45005
45005
|
/* @__PURE__ */ jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-green-100 rounded-full", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-green-700", children: /* @__PURE__ */ jsx(ISTTimer_default, {}) }) })
|
|
@@ -45010,7 +45010,7 @@ var KPIsOverviewView = ({
|
|
|
45010
45010
|
/* @__PURE__ */ jsx("span", { className: "text-sm md:text-base font-medium text-blue-600", children: formatLocalDate2(/* @__PURE__ */ new Date()) }),
|
|
45011
45011
|
/* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-blue-300" }),
|
|
45012
45012
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
45013
|
-
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children:
|
|
45013
|
+
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children: getShiftIcon(currentShiftDetails.shiftId) }),
|
|
45014
45014
|
/* @__PURE__ */ jsxs("span", { className: "text-sm md:text-base font-medium text-blue-600", children: [
|
|
45015
45015
|
shiftName,
|
|
45016
45016
|
" Shift"
|
|
@@ -45038,10 +45038,10 @@ var HeaderRibbon = memo(({
|
|
|
45038
45038
|
currentDate,
|
|
45039
45039
|
currentMobileDate,
|
|
45040
45040
|
shiftId,
|
|
45041
|
-
getShiftIcon
|
|
45041
|
+
getShiftIcon,
|
|
45042
45042
|
getShiftName
|
|
45043
45043
|
}) => {
|
|
45044
|
-
const shiftIcon = useMemo(() =>
|
|
45044
|
+
const shiftIcon = useMemo(() => getShiftIcon(shiftId), [getShiftIcon, shiftId]);
|
|
45045
45045
|
const shiftName = useMemo(() => getShiftName(shiftId), [getShiftName, shiftId]);
|
|
45046
45046
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45047
45047
|
/* @__PURE__ */ jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
@@ -45239,7 +45239,7 @@ var LeaderboardDetailView = memo(({
|
|
|
45239
45239
|
const currentShift = getCurrentShift(timezone || "Asia/Kolkata", shiftConfig);
|
|
45240
45240
|
return currentShift.shiftName || getShiftNameById(currentShift.shiftId, timezone || "Asia/Kolkata", shiftConfig);
|
|
45241
45241
|
}, [timezone, shiftConfig]);
|
|
45242
|
-
const
|
|
45242
|
+
const getShiftIcon = useCallback((shiftId2) => {
|
|
45243
45243
|
const effectiveShiftId = shiftId2 !== void 0 ? shiftId2 : getCurrentShift(timezone || "Asia/Kolkata", shiftConfig).shiftId;
|
|
45244
45244
|
const shiftNameLower = getShiftName(effectiveShiftId).toLowerCase();
|
|
45245
45245
|
if (shiftNameLower.includes("day") || shiftNameLower.includes("morning")) {
|
|
@@ -45449,7 +45449,7 @@ var LeaderboardDetailView = memo(({
|
|
|
45449
45449
|
currentDate: currentDateFormatted,
|
|
45450
45450
|
currentMobileDate: currentMobileDateFormatted,
|
|
45451
45451
|
shiftId,
|
|
45452
|
-
getShiftIcon
|
|
45452
|
+
getShiftIcon,
|
|
45453
45453
|
getShiftName
|
|
45454
45454
|
}
|
|
45455
45455
|
)
|
|
@@ -45808,23 +45808,6 @@ var ProfileView = () => {
|
|
|
45808
45808
|
] }) });
|
|
45809
45809
|
};
|
|
45810
45810
|
var ProfileView_default = ProfileView;
|
|
45811
|
-
var DEFAULT_TIMEZONE = "Asia/Kolkata";
|
|
45812
|
-
var DEFAULT_SHIFTS = [
|
|
45813
|
-
{
|
|
45814
|
-
shiftId: 0,
|
|
45815
|
-
shiftName: "Day Shift",
|
|
45816
|
-
startTime: "08:00",
|
|
45817
|
-
endTime: "16:00",
|
|
45818
|
-
breaks: []
|
|
45819
|
-
},
|
|
45820
|
-
{
|
|
45821
|
-
shiftId: 1,
|
|
45822
|
-
shiftName: "Night Shift",
|
|
45823
|
-
startTime: "20:00",
|
|
45824
|
-
endTime: "04:00",
|
|
45825
|
-
breaks: []
|
|
45826
|
-
}
|
|
45827
|
-
];
|
|
45828
45811
|
var calculateShiftHours = (startTime, endTime, breaks = []) => {
|
|
45829
45812
|
if (!startTime || !endTime) return 8;
|
|
45830
45813
|
const [startHour, startMinute] = startTime.split(":").map(Number);
|
|
@@ -45891,19 +45874,6 @@ var formatBreaks = (breaks) => {
|
|
|
45891
45874
|
}))
|
|
45892
45875
|
};
|
|
45893
45876
|
};
|
|
45894
|
-
var getShiftIcon = (shiftId, shiftName) => {
|
|
45895
|
-
const nameLower = shiftName.toLowerCase();
|
|
45896
|
-
if (nameLower.includes("day") || nameLower.includes("morning") || shiftId === 0) {
|
|
45897
|
-
return /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) });
|
|
45898
|
-
}
|
|
45899
|
-
if (nameLower.includes("afternoon") || nameLower.includes("noon") || nameLower.includes("midday")) {
|
|
45900
|
-
return /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) });
|
|
45901
|
-
}
|
|
45902
|
-
if (nameLower.includes("night") || nameLower.includes("evening") || shiftId === 1) {
|
|
45903
|
-
return /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) });
|
|
45904
|
-
}
|
|
45905
|
-
return /* @__PURE__ */ jsx(Clock, { className: "w-5 h-5 text-gray-600" });
|
|
45906
|
-
};
|
|
45907
45877
|
var BreakRow = memo(({
|
|
45908
45878
|
break: breakItem,
|
|
45909
45879
|
onUpdate,
|
|
@@ -46031,13 +46001,9 @@ var ShiftPanel = memo(({
|
|
|
46031
46001
|
onBreakUpdate,
|
|
46032
46002
|
onBreakRemove,
|
|
46033
46003
|
onBreakAdd,
|
|
46034
|
-
shiftHours
|
|
46035
|
-
shiftId,
|
|
46036
|
-
onShiftNameChange,
|
|
46037
|
-
canDelete = false,
|
|
46038
|
-
onDelete
|
|
46004
|
+
shiftHours
|
|
46039
46005
|
}) => {
|
|
46040
|
-
const panelId = `panel-${title.toLowerCase().replace(/\s+/g, "-")}
|
|
46006
|
+
const panelId = `panel-${title.toLowerCase().replace(/\s+/g, "-")}`;
|
|
46041
46007
|
const storageKey = `shift_panel_${panelId}_minimized`;
|
|
46042
46008
|
const [isMinimized, setIsMinimized] = useState(true);
|
|
46043
46009
|
useEffect(() => {
|
|
@@ -46064,7 +46030,7 @@ var ShiftPanel = memo(({
|
|
|
46064
46030
|
"button",
|
|
46065
46031
|
{
|
|
46066
46032
|
onClick: toggleMinimize,
|
|
46067
|
-
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",
|
|
46033
|
+
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",
|
|
46068
46034
|
"aria-expanded": !isMinimized,
|
|
46069
46035
|
"aria-controls": panelId,
|
|
46070
46036
|
children: [
|
|
@@ -46081,42 +46047,15 @@ var ShiftPanel = memo(({
|
|
|
46081
46047
|
]
|
|
46082
46048
|
}
|
|
46083
46049
|
),
|
|
46084
|
-
/* @__PURE__ */ jsxs("
|
|
46085
|
-
|
|
46086
|
-
|
|
46087
|
-
|
|
46088
|
-
" hours"
|
|
46089
|
-
] }),
|
|
46090
|
-
canDelete && onDelete && /* @__PURE__ */ jsx(
|
|
46091
|
-
"button",
|
|
46092
|
-
{
|
|
46093
|
-
onClick: (e) => {
|
|
46094
|
-
e.stopPropagation();
|
|
46095
|
-
onDelete();
|
|
46096
|
-
},
|
|
46097
|
-
className: "p-1.5 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded transition-colors",
|
|
46098
|
-
"aria-label": "Delete shift",
|
|
46099
|
-
children: /* @__PURE__ */ jsx(Trash2, { className: "w-4 h-4" })
|
|
46100
|
-
}
|
|
46101
|
-
)
|
|
46050
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs sm:text-sm font-medium text-gray-600 text-center sm:text-right sm:mr-2", children: [
|
|
46051
|
+
"Total Shift Hours: ",
|
|
46052
|
+
shiftHours,
|
|
46053
|
+
" hours"
|
|
46102
46054
|
] })
|
|
46103
46055
|
] })
|
|
46104
46056
|
}
|
|
46105
46057
|
),
|
|
46106
46058
|
!isMinimized && /* @__PURE__ */ jsxs("div", { id: panelId, className: "p-3 sm:p-4 md:p-6 border-t border-gray-200 w-full bg-white", children: [
|
|
46107
|
-
onShiftNameChange && /* @__PURE__ */ jsxs("div", { className: "mb-4 sm:mb-6", children: [
|
|
46108
|
-
/* @__PURE__ */ jsx("label", { className: "block text-xs sm:text-sm font-medium text-gray-700 mb-1", children: "Shift Name" }),
|
|
46109
|
-
/* @__PURE__ */ jsx(
|
|
46110
|
-
"input",
|
|
46111
|
-
{
|
|
46112
|
-
type: "text",
|
|
46113
|
-
value: title,
|
|
46114
|
-
onChange: (e) => onShiftNameChange(e.target.value),
|
|
46115
|
-
placeholder: "Enter shift name",
|
|
46116
|
-
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"
|
|
46117
|
-
}
|
|
46118
|
-
)
|
|
46119
|
-
] }),
|
|
46120
46059
|
/* @__PURE__ */ 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: [
|
|
46121
46060
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
46122
46061
|
/* @__PURE__ */ jsx("label", { className: "block text-xs sm:text-sm font-medium text-gray-700 mb-1", children: "Shift Start Time" }),
|
|
@@ -46210,9 +46149,16 @@ var ShiftsView = ({
|
|
|
46210
46149
|
() => lineIds.map((id3) => ({
|
|
46211
46150
|
id: id3,
|
|
46212
46151
|
name: lineNames[id3] || `Line ${id3.substring(0, 4)}`,
|
|
46213
|
-
|
|
46214
|
-
|
|
46215
|
-
|
|
46152
|
+
dayShift: {
|
|
46153
|
+
startTime: "08:00",
|
|
46154
|
+
endTime: "16:00",
|
|
46155
|
+
breaks: []
|
|
46156
|
+
},
|
|
46157
|
+
nightShift: {
|
|
46158
|
+
startTime: "20:00",
|
|
46159
|
+
endTime: "04:00",
|
|
46160
|
+
breaks: []
|
|
46161
|
+
},
|
|
46216
46162
|
isOpen: true,
|
|
46217
46163
|
isSaving: false,
|
|
46218
46164
|
saveSuccess: false
|
|
@@ -46236,47 +46182,77 @@ var ShiftsView = ({
|
|
|
46236
46182
|
try {
|
|
46237
46183
|
setLoading(true);
|
|
46238
46184
|
setError(null);
|
|
46239
|
-
const { data:
|
|
46240
|
-
if (
|
|
46241
|
-
console.error("
|
|
46242
|
-
showToast("error", "Error loading
|
|
46243
|
-
setError("Failed to load
|
|
46185
|
+
const { data: enabledLines, error: linesError } = await supabase.from("lines").select("id, enable").in("id", lineIds).eq("enable", true);
|
|
46186
|
+
if (linesError) {
|
|
46187
|
+
console.error("Error fetching enabled lines:", linesError);
|
|
46188
|
+
showToast("error", "Error loading lines");
|
|
46189
|
+
setError("Failed to load lines");
|
|
46190
|
+
setLoading(false);
|
|
46244
46191
|
return;
|
|
46245
46192
|
}
|
|
46246
|
-
|
|
46247
|
-
|
|
46248
|
-
|
|
46249
|
-
|
|
46250
|
-
|
|
46251
|
-
|
|
46252
|
-
|
|
46253
|
-
|
|
46254
|
-
|
|
46255
|
-
|
|
46256
|
-
|
|
46257
|
-
|
|
46258
|
-
|
|
46259
|
-
|
|
46193
|
+
const enabledLineIds = (enabledLines || []).map((line) => line.id);
|
|
46194
|
+
if (enabledLineIds.length === 0) {
|
|
46195
|
+
setLineConfigs([]);
|
|
46196
|
+
setLoading(false);
|
|
46197
|
+
return;
|
|
46198
|
+
}
|
|
46199
|
+
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);
|
|
46200
|
+
if (dayShiftError) {
|
|
46201
|
+
console.error("Error fetching day shift operating hours:", dayShiftError);
|
|
46202
|
+
showToast("error", "Error loading day shift data");
|
|
46203
|
+
setError("Failed to load day shift data");
|
|
46204
|
+
return;
|
|
46205
|
+
}
|
|
46206
|
+
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);
|
|
46207
|
+
if (nightShiftError) {
|
|
46208
|
+
console.error("Error fetching night shift operating hours:", nightShiftError);
|
|
46209
|
+
showToast("error", "Error loading night shift data");
|
|
46210
|
+
setError("Failed to load night shift data");
|
|
46211
|
+
return;
|
|
46212
|
+
}
|
|
46213
|
+
const dayShiftHoursMap = (dayShiftOperatingHours || []).reduce((map, item) => {
|
|
46214
|
+
map[item.line_id] = {
|
|
46215
|
+
startTime: item.start_time,
|
|
46216
|
+
endTime: item.end_time,
|
|
46217
|
+
breaks: parseBreaksFromDB(item.breaks)
|
|
46218
|
+
};
|
|
46219
|
+
return map;
|
|
46220
|
+
}, {});
|
|
46221
|
+
const nightShiftHoursMap = (nightShiftOperatingHours || []).reduce((map, item) => {
|
|
46222
|
+
map[item.line_id] = {
|
|
46223
|
+
startTime: item.start_time,
|
|
46224
|
+
endTime: item.end_time,
|
|
46225
|
+
breaks: parseBreaksFromDB(item.breaks)
|
|
46226
|
+
};
|
|
46227
|
+
return map;
|
|
46228
|
+
}, {});
|
|
46229
|
+
setLineConfigs((prev) => {
|
|
46230
|
+
const enabledConfigs = prev.filter((config) => enabledLineIds.includes(config.id));
|
|
46231
|
+
return enabledConfigs.map((config) => {
|
|
46232
|
+
const typedConfig = config;
|
|
46233
|
+
const lineId = typedConfig.id;
|
|
46234
|
+
const newConfig = { ...typedConfig };
|
|
46235
|
+
if (dayShiftHoursMap[lineId]) {
|
|
46236
|
+
newConfig.dayShift = {
|
|
46237
|
+
...newConfig.dayShift,
|
|
46238
|
+
...dayShiftHoursMap[lineId]
|
|
46239
|
+
};
|
|
46240
|
+
}
|
|
46241
|
+
if (nightShiftHoursMap[lineId]) {
|
|
46242
|
+
newConfig.nightShift = {
|
|
46243
|
+
...newConfig.nightShift,
|
|
46244
|
+
...nightShiftHoursMap[lineId]
|
|
46245
|
+
};
|
|
46246
|
+
}
|
|
46247
|
+
if (newConfig.isOpen === void 0) {
|
|
46248
|
+
newConfig.isOpen = getStoredLineState(lineId);
|
|
46249
|
+
}
|
|
46250
|
+
return newConfig;
|
|
46260
46251
|
});
|
|
46261
|
-
if (row.timezone && !timezoneByLine[row.line_id]) {
|
|
46262
|
-
timezoneByLine[row.line_id] = row.timezone;
|
|
46263
|
-
}
|
|
46264
46252
|
});
|
|
46265
|
-
setLineConfigs((prev) => prev.map((config) => {
|
|
46266
|
-
const lineId = config.id;
|
|
46267
|
-
const lineShifts = shiftsByLine[lineId];
|
|
46268
|
-
const lineTimezone = timezoneByLine[lineId] || DEFAULT_TIMEZONE;
|
|
46269
|
-
const shifts = lineShifts && lineShifts.length > 0 ? lineShifts.sort((a, b) => a.shiftId - b.shiftId) : DEFAULT_SHIFTS.map((s) => ({ ...s }));
|
|
46270
|
-
return {
|
|
46271
|
-
...config,
|
|
46272
|
-
timezone: lineTimezone,
|
|
46273
|
-
shifts,
|
|
46274
|
-
isOpen: config.isOpen ?? getStoredLineState(lineId)
|
|
46275
|
-
};
|
|
46276
|
-
}));
|
|
46277
46253
|
setLoading(false);
|
|
46278
46254
|
} catch (error2) {
|
|
46279
|
-
console.error("
|
|
46255
|
+
console.error("Error fetching shift configurations:", error2);
|
|
46280
46256
|
showToast("error", "Failed to load shift configurations");
|
|
46281
46257
|
setError("Failed to load shift configurations");
|
|
46282
46258
|
setLoading(false);
|
|
@@ -46286,125 +46262,195 @@ var ShiftsView = ({
|
|
|
46286
46262
|
}, [lineIds, showToast]);
|
|
46287
46263
|
useCallback((lineId) => {
|
|
46288
46264
|
setLineConfigs((prev) => {
|
|
46289
|
-
const
|
|
46265
|
+
const typedPrev = prev;
|
|
46266
|
+
const newIsOpen = !typedPrev.find((config) => config.id === lineId)?.isOpen;
|
|
46290
46267
|
localStorage.setItem(`line_${lineId}_open`, JSON.stringify(newIsOpen));
|
|
46291
|
-
return
|
|
46268
|
+
return typedPrev.map(
|
|
46292
46269
|
(config) => config.id === lineId ? { ...config, isOpen: newIsOpen } : config
|
|
46293
46270
|
);
|
|
46294
46271
|
});
|
|
46295
46272
|
}, []);
|
|
46296
|
-
const
|
|
46273
|
+
const updateDayShiftStartTime = useCallback((lineId, value) => {
|
|
46297
46274
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46298
|
-
|
|
46299
|
-
|
|
46300
|
-
|
|
46301
|
-
|
|
46302
|
-
|
|
46275
|
+
const typedConfig = config;
|
|
46276
|
+
if (typedConfig.id === lineId) {
|
|
46277
|
+
const updatedDayShift = { ...typedConfig.dayShift, startTime: value };
|
|
46278
|
+
return {
|
|
46279
|
+
...typedConfig,
|
|
46280
|
+
dayShift: updatedDayShift
|
|
46281
|
+
};
|
|
46303
46282
|
}
|
|
46304
|
-
return
|
|
46283
|
+
return typedConfig;
|
|
46305
46284
|
}));
|
|
46306
46285
|
}, []);
|
|
46307
|
-
const
|
|
46286
|
+
const updateDayShiftEndTime = useCallback((lineId, value) => {
|
|
46308
46287
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46309
|
-
|
|
46310
|
-
|
|
46311
|
-
|
|
46312
|
-
|
|
46313
|
-
|
|
46288
|
+
const typedConfig = config;
|
|
46289
|
+
if (typedConfig.id === lineId) {
|
|
46290
|
+
const updatedDayShift = { ...typedConfig.dayShift, endTime: value };
|
|
46291
|
+
return {
|
|
46292
|
+
...typedConfig,
|
|
46293
|
+
dayShift: updatedDayShift
|
|
46294
|
+
};
|
|
46314
46295
|
}
|
|
46315
|
-
return
|
|
46296
|
+
return typedConfig;
|
|
46316
46297
|
}));
|
|
46317
46298
|
}, []);
|
|
46318
|
-
useCallback((lineId, value) => {
|
|
46319
|
-
setLineConfigs((prev) => prev.map(
|
|
46320
|
-
|
|
46321
|
-
|
|
46299
|
+
const updateNightShiftStartTime = useCallback((lineId, value) => {
|
|
46300
|
+
setLineConfigs((prev) => prev.map((config) => {
|
|
46301
|
+
const typedConfig = config;
|
|
46302
|
+
if (typedConfig.id === lineId) {
|
|
46303
|
+
const updatedNightShift = { ...typedConfig.nightShift, startTime: value };
|
|
46304
|
+
return {
|
|
46305
|
+
...typedConfig,
|
|
46306
|
+
nightShift: updatedNightShift
|
|
46307
|
+
};
|
|
46308
|
+
}
|
|
46309
|
+
return typedConfig;
|
|
46310
|
+
}));
|
|
46322
46311
|
}, []);
|
|
46323
|
-
const
|
|
46312
|
+
const updateNightShiftEndTime = useCallback((lineId, value) => {
|
|
46324
46313
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46325
|
-
|
|
46326
|
-
|
|
46327
|
-
|
|
46328
|
-
|
|
46329
|
-
|
|
46330
|
-
|
|
46331
|
-
|
|
46332
|
-
|
|
46333
|
-
|
|
46334
|
-
|
|
46314
|
+
const typedConfig = config;
|
|
46315
|
+
if (typedConfig.id === lineId) {
|
|
46316
|
+
const updatedNightShift = { ...typedConfig.nightShift, endTime: value };
|
|
46317
|
+
return {
|
|
46318
|
+
...typedConfig,
|
|
46319
|
+
nightShift: updatedNightShift
|
|
46320
|
+
};
|
|
46321
|
+
}
|
|
46322
|
+
return typedConfig;
|
|
46323
|
+
}));
|
|
46324
|
+
}, []);
|
|
46325
|
+
const addDayShiftBreak = useCallback((lineId) => {
|
|
46326
|
+
setLineConfigs((prev) => prev.map((config) => {
|
|
46327
|
+
const typedConfig = config;
|
|
46328
|
+
if (typedConfig.id === lineId) {
|
|
46329
|
+
const dayShift = { ...typedConfig.dayShift };
|
|
46330
|
+
const newBreak = {
|
|
46331
|
+
startTime: dayShift.startTime,
|
|
46332
|
+
endTime: dayShift.startTime,
|
|
46333
|
+
duration: 0,
|
|
46334
|
+
remarks: ""
|
|
46335
|
+
};
|
|
46336
|
+
return {
|
|
46337
|
+
...typedConfig,
|
|
46338
|
+
dayShift: {
|
|
46339
|
+
...dayShift,
|
|
46340
|
+
breaks: [...dayShift.breaks, newBreak]
|
|
46335
46341
|
}
|
|
46336
|
-
|
|
46337
|
-
});
|
|
46338
|
-
return { ...config, shifts: updatedShifts };
|
|
46342
|
+
};
|
|
46339
46343
|
}
|
|
46340
|
-
return
|
|
46344
|
+
return typedConfig;
|
|
46341
46345
|
}));
|
|
46342
46346
|
}, []);
|
|
46343
|
-
const
|
|
46347
|
+
const addNightShiftBreak = useCallback((lineId) => {
|
|
46344
46348
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46345
|
-
|
|
46346
|
-
|
|
46347
|
-
|
|
46348
|
-
|
|
46349
|
-
|
|
46350
|
-
|
|
46351
|
-
|
|
46352
|
-
|
|
46353
|
-
|
|
46354
|
-
|
|
46355
|
-
|
|
46356
|
-
|
|
46349
|
+
const typedConfig = config;
|
|
46350
|
+
if (typedConfig.id === lineId) {
|
|
46351
|
+
const nightShift = { ...typedConfig.nightShift };
|
|
46352
|
+
const newBreak = {
|
|
46353
|
+
startTime: nightShift.startTime,
|
|
46354
|
+
endTime: nightShift.startTime,
|
|
46355
|
+
duration: 0
|
|
46356
|
+
};
|
|
46357
|
+
return {
|
|
46358
|
+
...typedConfig,
|
|
46359
|
+
nightShift: {
|
|
46360
|
+
...nightShift,
|
|
46361
|
+
breaks: [...nightShift.breaks, newBreak]
|
|
46357
46362
|
}
|
|
46358
|
-
|
|
46359
|
-
});
|
|
46360
|
-
return { ...config, shifts: updatedShifts };
|
|
46363
|
+
};
|
|
46361
46364
|
}
|
|
46362
|
-
return
|
|
46365
|
+
return typedConfig;
|
|
46363
46366
|
}));
|
|
46364
46367
|
}, []);
|
|
46365
|
-
const
|
|
46368
|
+
const updateDayShiftBreak = useCallback((lineId, index, field, value) => {
|
|
46366
46369
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46367
|
-
|
|
46368
|
-
|
|
46369
|
-
|
|
46370
|
-
|
|
46370
|
+
const typedConfig = config;
|
|
46371
|
+
if (typedConfig.id === lineId) {
|
|
46372
|
+
const dayShift = { ...typedConfig.dayShift };
|
|
46373
|
+
const newBreaks = [...dayShift.breaks];
|
|
46374
|
+
newBreaks[index] = { ...newBreaks[index], [field]: value };
|
|
46375
|
+
if (field === "startTime" || field === "endTime") {
|
|
46376
|
+
const startParts = newBreaks[index].startTime.split(":").map(Number);
|
|
46377
|
+
const endParts = newBreaks[index].endTime.split(":").map(Number);
|
|
46378
|
+
let startMinutes = startParts[0] * 60 + startParts[1];
|
|
46379
|
+
let endMinutes = endParts[0] * 60 + endParts[1];
|
|
46380
|
+
if (endMinutes < startMinutes) {
|
|
46381
|
+
endMinutes += 24 * 60;
|
|
46382
|
+
}
|
|
46383
|
+
newBreaks[index].duration = endMinutes - startMinutes;
|
|
46384
|
+
}
|
|
46385
|
+
return {
|
|
46386
|
+
...typedConfig,
|
|
46387
|
+
dayShift: {
|
|
46388
|
+
...dayShift,
|
|
46389
|
+
breaks: newBreaks
|
|
46371
46390
|
}
|
|
46372
|
-
|
|
46373
|
-
});
|
|
46374
|
-
return { ...config, shifts: updatedShifts };
|
|
46391
|
+
};
|
|
46375
46392
|
}
|
|
46376
|
-
return
|
|
46393
|
+
return typedConfig;
|
|
46377
46394
|
}));
|
|
46378
46395
|
}, []);
|
|
46379
|
-
useCallback((lineId) => {
|
|
46396
|
+
const updateNightShiftBreak = useCallback((lineId, index, field, value) => {
|
|
46397
|
+
setLineConfigs((prev) => prev.map((config) => {
|
|
46398
|
+
const typedConfig = config;
|
|
46399
|
+
if (typedConfig.id === lineId) {
|
|
46400
|
+
const nightShift = { ...typedConfig.nightShift };
|
|
46401
|
+
const newBreaks = [...nightShift.breaks];
|
|
46402
|
+
newBreaks[index] = { ...newBreaks[index], [field]: value };
|
|
46403
|
+
if (field === "startTime" || field === "endTime") {
|
|
46404
|
+
const startParts = newBreaks[index].startTime.split(":").map(Number);
|
|
46405
|
+
const endParts = newBreaks[index].endTime.split(":").map(Number);
|
|
46406
|
+
let startMinutes = startParts[0] * 60 + startParts[1];
|
|
46407
|
+
let endMinutes = endParts[0] * 60 + endParts[1];
|
|
46408
|
+
if (endMinutes < startMinutes) {
|
|
46409
|
+
endMinutes += 24 * 60;
|
|
46410
|
+
}
|
|
46411
|
+
newBreaks[index].duration = endMinutes - startMinutes;
|
|
46412
|
+
}
|
|
46413
|
+
return {
|
|
46414
|
+
...typedConfig,
|
|
46415
|
+
nightShift: {
|
|
46416
|
+
...nightShift,
|
|
46417
|
+
breaks: newBreaks
|
|
46418
|
+
}
|
|
46419
|
+
};
|
|
46420
|
+
}
|
|
46421
|
+
return typedConfig;
|
|
46422
|
+
}));
|
|
46423
|
+
}, []);
|
|
46424
|
+
const removeDayShiftBreak = useCallback((lineId, index) => {
|
|
46380
46425
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46381
46426
|
if (config.id === lineId) {
|
|
46382
|
-
const
|
|
46383
|
-
|
|
46384
|
-
|
|
46385
|
-
|
|
46386
|
-
|
|
46387
|
-
|
|
46388
|
-
|
|
46389
|
-
breaks: []
|
|
46427
|
+
const dayShift = { ...config.dayShift };
|
|
46428
|
+
return {
|
|
46429
|
+
...config,
|
|
46430
|
+
dayShift: {
|
|
46431
|
+
...dayShift,
|
|
46432
|
+
breaks: dayShift.breaks.filter((_, i) => i !== index)
|
|
46433
|
+
}
|
|
46390
46434
|
};
|
|
46391
|
-
return { ...config, shifts: [...config.shifts, newShift] };
|
|
46392
46435
|
}
|
|
46393
46436
|
return config;
|
|
46394
46437
|
}));
|
|
46395
46438
|
}, []);
|
|
46396
|
-
const
|
|
46439
|
+
const removeNightShiftBreak = useCallback((lineId, index) => {
|
|
46397
46440
|
setLineConfigs((prev) => prev.map((config) => {
|
|
46398
46441
|
if (config.id === lineId) {
|
|
46399
|
-
|
|
46400
|
-
|
|
46401
|
-
|
|
46402
|
-
|
|
46403
|
-
|
|
46442
|
+
const nightShift = { ...config.nightShift };
|
|
46443
|
+
return {
|
|
46444
|
+
...config,
|
|
46445
|
+
nightShift: {
|
|
46446
|
+
...nightShift,
|
|
46447
|
+
breaks: nightShift.breaks.filter((_, i) => i !== index)
|
|
46448
|
+
}
|
|
46449
|
+
};
|
|
46404
46450
|
}
|
|
46405
46451
|
return config;
|
|
46406
46452
|
}));
|
|
46407
|
-
}, [
|
|
46453
|
+
}, []);
|
|
46408
46454
|
const handleSaveShifts = useCallback(async (lineId) => {
|
|
46409
46455
|
setLineConfigs((prev) => prev.map(
|
|
46410
46456
|
(config) => config.id === lineId ? { ...config, isSaving: true, saveSuccess: false } : config
|
|
@@ -46414,31 +46460,27 @@ var ShiftsView = ({
|
|
|
46414
46460
|
if (!lineConfig) {
|
|
46415
46461
|
throw new Error("Line configuration not found");
|
|
46416
46462
|
}
|
|
46417
|
-
|
|
46418
|
-
|
|
46419
|
-
|
|
46420
|
-
|
|
46421
|
-
|
|
46422
|
-
|
|
46423
|
-
|
|
46424
|
-
|
|
46425
|
-
|
|
46426
|
-
|
|
46427
|
-
|
|
46428
|
-
|
|
46429
|
-
|
|
46430
|
-
|
|
46431
|
-
|
|
46463
|
+
const dayShiftData = {
|
|
46464
|
+
line_id: lineId,
|
|
46465
|
+
shift_id: 0,
|
|
46466
|
+
start_time: lineConfig.dayShift.startTime,
|
|
46467
|
+
end_time: lineConfig.dayShift.endTime,
|
|
46468
|
+
breaks: formatBreaks(lineConfig.dayShift.breaks)
|
|
46469
|
+
};
|
|
46470
|
+
const nightShiftData = {
|
|
46471
|
+
line_id: lineId,
|
|
46472
|
+
shift_id: 1,
|
|
46473
|
+
start_time: lineConfig.nightShift.startTime,
|
|
46474
|
+
end_time: lineConfig.nightShift.endTime,
|
|
46475
|
+
breaks: formatBreaks(lineConfig.nightShift.breaks)
|
|
46476
|
+
};
|
|
46477
|
+
const dayResult = await supabase.from("line_operating_hours").upsert(dayShiftData).select();
|
|
46478
|
+
if (dayResult.error) {
|
|
46479
|
+
throw new Error(`Failed to save day shift: ${dayResult.error.message}`);
|
|
46432
46480
|
}
|
|
46433
|
-
const
|
|
46434
|
-
|
|
46435
|
-
|
|
46436
|
-
if (shiftsToDelete.length > 0) {
|
|
46437
|
-
console.log("[ShiftsView] Deleting removed shifts:", shiftsToDelete);
|
|
46438
|
-
const { error: deleteError } = await supabase.from("line_operating_hours").delete().eq("line_id", lineId).in("shift_id", shiftsToDelete);
|
|
46439
|
-
if (deleteError) {
|
|
46440
|
-
console.error("[ShiftsView] Error deleting shifts:", deleteError);
|
|
46441
|
-
}
|
|
46481
|
+
const nightResult = await supabase.from("line_operating_hours").upsert(nightShiftData).select();
|
|
46482
|
+
if (nightResult.error) {
|
|
46483
|
+
throw new Error(`Failed to save night shift: ${nightResult.error.message}`);
|
|
46442
46484
|
}
|
|
46443
46485
|
setLineConfigs((prev) => prev.map(
|
|
46444
46486
|
(config) => config.id === lineId ? { ...config, isSaving: false, saveSuccess: true } : config
|
|
@@ -46450,7 +46492,7 @@ var ShiftsView = ({
|
|
|
46450
46492
|
));
|
|
46451
46493
|
}, 3e3);
|
|
46452
46494
|
} catch (error2) {
|
|
46453
|
-
console.error("
|
|
46495
|
+
console.error("Error saving shift configurations:", error2);
|
|
46454
46496
|
showToast("error", "Failed to save shift configurations");
|
|
46455
46497
|
setLineConfigs((prev) => prev.map(
|
|
46456
46498
|
(config) => config.id === lineId ? { ...config, isSaving: false, saveSuccess: false } : config
|
|
@@ -46470,7 +46512,7 @@ var ShiftsView = ({
|
|
|
46470
46512
|
) }),
|
|
46471
46513
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col items-center mt-2 sm:mt-0", children: [
|
|
46472
46514
|
/* @__PURE__ */ jsx("h1", { className: "text-lg sm:text-xl md:text-2xl lg:text-3xl font-semibold text-gray-900 text-center", children: "Shift Management" }),
|
|
46473
|
-
/* @__PURE__ */ 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" })
|
|
46515
|
+
/* @__PURE__ */ 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" })
|
|
46474
46516
|
] }),
|
|
46475
46517
|
/* @__PURE__ */ jsx("div", { className: "hidden sm:block absolute right-0 w-24" })
|
|
46476
46518
|
] }) }) }),
|
|
@@ -46490,11 +46532,6 @@ var ShiftsView = ({
|
|
|
46490
46532
|
/* @__PURE__ */ jsxs("h2", { className: "text-base sm:text-lg font-semibold text-gray-800", children: [
|
|
46491
46533
|
config.name,
|
|
46492
46534
|
" Shifts"
|
|
46493
|
-
] }),
|
|
46494
|
-
/* @__PURE__ */ jsxs("span", { className: "text-xs text-gray-400", children: [
|
|
46495
|
-
"(",
|
|
46496
|
-
config.shifts.length,
|
|
46497
|
-
" shifts)"
|
|
46498
46535
|
] })
|
|
46499
46536
|
] }),
|
|
46500
46537
|
/* @__PURE__ */ 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: [
|
|
@@ -46522,27 +46559,48 @@ var ShiftsView = ({
|
|
|
46522
46559
|
)
|
|
46523
46560
|
] })
|
|
46524
46561
|
] }) }),
|
|
46525
|
-
/* @__PURE__ */
|
|
46526
|
-
|
|
46527
|
-
|
|
46528
|
-
|
|
46529
|
-
|
|
46530
|
-
|
|
46531
|
-
|
|
46532
|
-
|
|
46533
|
-
|
|
46534
|
-
|
|
46535
|
-
|
|
46536
|
-
|
|
46537
|
-
|
|
46538
|
-
|
|
46539
|
-
|
|
46540
|
-
|
|
46541
|
-
|
|
46542
|
-
|
|
46543
|
-
|
|
46544
|
-
|
|
46545
|
-
|
|
46562
|
+
/* @__PURE__ */ jsxs("div", { id: `shift-panel-${config.id}`, className: "p-3 sm:p-4 md:p-6 border-t border-gray-200 w-full", children: [
|
|
46563
|
+
/* @__PURE__ */ jsx(
|
|
46564
|
+
ShiftPanel,
|
|
46565
|
+
{
|
|
46566
|
+
title: "Day Shift",
|
|
46567
|
+
icon: /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) }),
|
|
46568
|
+
startTime: config.dayShift.startTime,
|
|
46569
|
+
endTime: config.dayShift.endTime,
|
|
46570
|
+
breaks: config.dayShift.breaks,
|
|
46571
|
+
onStartTimeChange: (value) => updateDayShiftStartTime(config.id, value),
|
|
46572
|
+
onEndTimeChange: (value) => updateDayShiftEndTime(config.id, value),
|
|
46573
|
+
onBreakUpdate: (index, field, value) => updateDayShiftBreak(config.id, index, field, value),
|
|
46574
|
+
onBreakRemove: (index) => removeDayShiftBreak(config.id, index),
|
|
46575
|
+
onBreakAdd: () => addDayShiftBreak(config.id),
|
|
46576
|
+
shiftHours: calculateShiftHours(
|
|
46577
|
+
config.dayShift.startTime,
|
|
46578
|
+
config.dayShift.endTime,
|
|
46579
|
+
config.dayShift.breaks
|
|
46580
|
+
)
|
|
46581
|
+
}
|
|
46582
|
+
),
|
|
46583
|
+
/* @__PURE__ */ jsx(
|
|
46584
|
+
ShiftPanel,
|
|
46585
|
+
{
|
|
46586
|
+
title: "Night Shift",
|
|
46587
|
+
icon: /* @__PURE__ */ jsx("svg", { className: "w-5 h-5 text-gray-600", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) }),
|
|
46588
|
+
startTime: config.nightShift.startTime,
|
|
46589
|
+
endTime: config.nightShift.endTime,
|
|
46590
|
+
breaks: config.nightShift.breaks,
|
|
46591
|
+
onStartTimeChange: (value) => updateNightShiftStartTime(config.id, value),
|
|
46592
|
+
onEndTimeChange: (value) => updateNightShiftEndTime(config.id, value),
|
|
46593
|
+
onBreakUpdate: (index, field, value) => updateNightShiftBreak(config.id, index, field, value),
|
|
46594
|
+
onBreakRemove: (index) => removeNightShiftBreak(config.id, index),
|
|
46595
|
+
onBreakAdd: () => addNightShiftBreak(config.id),
|
|
46596
|
+
shiftHours: calculateShiftHours(
|
|
46597
|
+
config.nightShift.startTime,
|
|
46598
|
+
config.nightShift.endTime,
|
|
46599
|
+
config.nightShift.breaks
|
|
46600
|
+
)
|
|
46601
|
+
}
|
|
46602
|
+
)
|
|
46603
|
+
] })
|
|
46546
46604
|
] }, config.id)) })
|
|
46547
46605
|
] })
|
|
46548
46606
|
] });
|
|
@@ -47738,7 +47796,7 @@ var TargetsView = ({
|
|
|
47738
47796
|
onSaveChanges
|
|
47739
47797
|
}) => {
|
|
47740
47798
|
const timezone = useAppTimezone();
|
|
47741
|
-
|
|
47799
|
+
useMemo(() => {
|
|
47742
47800
|
return lineIds.reduce((acc, lineId) => ({
|
|
47743
47801
|
...acc,
|
|
47744
47802
|
[lineId]: {
|
|
@@ -47776,7 +47834,7 @@ var TargetsView = ({
|
|
|
47776
47834
|
const canSaveTargets = useCanSaveTargets();
|
|
47777
47835
|
const [dbValues, setDbValues] = useState({ 0: {}, 1: {} });
|
|
47778
47836
|
const [userEditedFields, setUserEditedFields] = useState(/* @__PURE__ */ new Set());
|
|
47779
|
-
const lineWorkspaces = allShiftsData[selectedShift] ||
|
|
47837
|
+
const lineWorkspaces = allShiftsData[selectedShift] || {};
|
|
47780
47838
|
const setLineWorkspaces = useCallback((updater) => {
|
|
47781
47839
|
setAllShiftsData((prev) => ({
|
|
47782
47840
|
...prev,
|
|
@@ -47905,6 +47963,37 @@ var TargetsView = ({
|
|
|
47905
47963
|
newAllShiftsData[shiftId][lineId].workspaces = mappedWorkspaces;
|
|
47906
47964
|
});
|
|
47907
47965
|
});
|
|
47966
|
+
effectiveShiftOptions.forEach(({ id: shiftId }) => {
|
|
47967
|
+
lineIds.forEach((lineId) => {
|
|
47968
|
+
if (!newAllShiftsData[shiftId][lineId]) {
|
|
47969
|
+
const lineData = data.lines[lineId];
|
|
47970
|
+
const shift0Data = newAllShiftsData[0]?.[lineId];
|
|
47971
|
+
const enabledWorkspaces = lineData?.workspaces?.filter((ws) => ws.enable === true) || [];
|
|
47972
|
+
const workspaces = enabledWorkspaces.map((ws) => ({
|
|
47973
|
+
id: ws.id,
|
|
47974
|
+
name: ws.workspace_id,
|
|
47975
|
+
targetPPH: "",
|
|
47976
|
+
targetCycleTime: "",
|
|
47977
|
+
targetDayOutput: "",
|
|
47978
|
+
actionType: "assembly",
|
|
47979
|
+
actionId: actionIdsData.assembly
|
|
47980
|
+
})).sort(
|
|
47981
|
+
(a, b) => a.name.localeCompare(b.name, void 0, { numeric: true })
|
|
47982
|
+
);
|
|
47983
|
+
newAllShiftsData[shiftId][lineId] = {
|
|
47984
|
+
productId: "",
|
|
47985
|
+
shiftStartTime: shift0Data?.shiftStartTime || "08:00",
|
|
47986
|
+
shiftEndTime: shift0Data?.shiftEndTime || "19:00",
|
|
47987
|
+
shiftHours: shift0Data?.shiftHours || 11,
|
|
47988
|
+
breaks: shift0Data?.breaks || [],
|
|
47989
|
+
workspaces,
|
|
47990
|
+
factoryId: shift0Data?.factoryId || lineData?.line_info?.factory_id
|
|
47991
|
+
};
|
|
47992
|
+
newDbValues[shiftId][lineId] = {};
|
|
47993
|
+
console.log(`[TargetsView] Initialized empty data for shift ${shiftId}, line ${lineId}`);
|
|
47994
|
+
}
|
|
47995
|
+
});
|
|
47996
|
+
});
|
|
47908
47997
|
setAllShiftsData(newAllShiftsData);
|
|
47909
47998
|
setDbValues(newDbValues);
|
|
47910
47999
|
console.log("[TargetsView] Successfully loaded all data with bulk endpoint:", {
|
|
@@ -48051,20 +48140,27 @@ var TargetsView = ({
|
|
|
48051
48140
|
};
|
|
48052
48141
|
const handleActionTypeChange = useCallback((lineId, workspaceId, newActionType) => {
|
|
48053
48142
|
if (!actionIds) return;
|
|
48054
|
-
setLineWorkspaces((prev) =>
|
|
48055
|
-
|
|
48056
|
-
|
|
48057
|
-
|
|
48058
|
-
|
|
48059
|
-
(ws) => ws.id === workspaceId ? {
|
|
48060
|
-
...ws,
|
|
48061
|
-
actionType: newActionType,
|
|
48062
|
-
actionId: actionIds[newActionType]
|
|
48063
|
-
} : ws
|
|
48064
|
-
)
|
|
48143
|
+
setLineWorkspaces((prev) => {
|
|
48144
|
+
const currentLineData = prev?.[lineId];
|
|
48145
|
+
if (!currentLineData?.workspaces) {
|
|
48146
|
+
console.warn(`[handleActionTypeChange] No data for line ${lineId} in current shift`);
|
|
48147
|
+
return prev;
|
|
48065
48148
|
}
|
|
48066
|
-
|
|
48067
|
-
|
|
48149
|
+
return {
|
|
48150
|
+
...prev,
|
|
48151
|
+
[lineId]: {
|
|
48152
|
+
...currentLineData,
|
|
48153
|
+
workspaces: currentLineData.workspaces.map(
|
|
48154
|
+
(ws) => ws.id === workspaceId ? {
|
|
48155
|
+
...ws,
|
|
48156
|
+
actionType: newActionType,
|
|
48157
|
+
actionId: actionIds[newActionType]
|
|
48158
|
+
} : ws
|
|
48159
|
+
)
|
|
48160
|
+
}
|
|
48161
|
+
};
|
|
48162
|
+
});
|
|
48163
|
+
}, [actionIds, setLineWorkspaces]);
|
|
48068
48164
|
const handleSaveLine = useCallback(async (lineId) => {
|
|
48069
48165
|
console.log(`[handleSaveLine] Attempting to save line: ${lineId}`);
|
|
48070
48166
|
if (!canSaveTargets) {
|
|
@@ -48613,7 +48709,7 @@ var WorkspaceDetailView = ({
|
|
|
48613
48709
|
}
|
|
48614
48710
|
}
|
|
48615
48711
|
};
|
|
48616
|
-
const
|
|
48712
|
+
const getShiftIcon = (shiftType) => {
|
|
48617
48713
|
const shiftTypeLower = shiftType?.toLowerCase() || "";
|
|
48618
48714
|
if (shiftTypeLower.includes("day") || shiftTypeLower.includes("morning")) {
|
|
48619
48715
|
return /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ 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" }) });
|
|
@@ -48773,7 +48869,7 @@ var WorkspaceDetailView = ({
|
|
|
48773
48869
|
/* @__PURE__ */ jsxs("div", { className: "sm:hidden mt-3 flex items-center justify-center gap-2", children: [
|
|
48774
48870
|
/* @__PURE__ */ jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-gray-100 rounded-full", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: formatISTDate2(new Date(workspace.date)) }) }),
|
|
48775
48871
|
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-gray-100 rounded-full", children: [
|
|
48776
|
-
/* @__PURE__ */ jsx("div", { className: "text-gray-700 scale-90", children:
|
|
48872
|
+
/* @__PURE__ */ jsx("div", { className: "text-gray-700 scale-90", children: getShiftIcon(workspace.shift_type) }),
|
|
48777
48873
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: workspace.shift_type })
|
|
48778
48874
|
] }),
|
|
48779
48875
|
!date && !shift && !usingFallbackData ? /* @__PURE__ */ jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-green-100 rounded-full", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-green-700", children: /* @__PURE__ */ jsx(LiveTimer, {}) }) }) : date ? /* @__PURE__ */ jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-blue-100 rounded-full", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-blue-700", children: getDaysDifference(workspace.date, timezone, dashboardConfig?.shiftConfig?.dayShift?.startTime || "06:00") }) }) : usingFallbackData ? /* @__PURE__ */ jsx("div", { className: "inline-flex items-center px-2.5 py-1 bg-amber-100 rounded-full", children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-amber-700", children: getDaysDifference(workspace.date, timezone, dashboardConfig?.shiftConfig?.dayShift?.startTime || "06:00") }) }) : null
|
|
@@ -48798,7 +48894,7 @@ var WorkspaceDetailView = ({
|
|
|
48798
48894
|
/* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-blue-300" })
|
|
48799
48895
|
] }),
|
|
48800
48896
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
48801
|
-
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children:
|
|
48897
|
+
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children: getShiftIcon(workspace.shift_type) }),
|
|
48802
48898
|
/* @__PURE__ */ jsx("span", { className: "text-sm md:text-base font-medium text-blue-600", children: workspace.shift_type })
|
|
48803
48899
|
] })
|
|
48804
48900
|
] }) })
|
|
@@ -49889,7 +49985,7 @@ var WorkspaceHealthView = ({
|
|
|
49889
49985
|
timeZone: effectiveTimezone
|
|
49890
49986
|
});
|
|
49891
49987
|
};
|
|
49892
|
-
const
|
|
49988
|
+
const getShiftIcon = () => {
|
|
49893
49989
|
const shiftName = (currentShiftDetails.shiftName || "").toLowerCase();
|
|
49894
49990
|
if (shiftName.includes("night") || shiftName.includes("evening") || currentShiftDetails.shiftId === 1) {
|
|
49895
49991
|
return /* @__PURE__ */ jsx(Moon, { className: "h-4 w-4" });
|
|
@@ -50080,7 +50176,7 @@ var WorkspaceHealthView = ({
|
|
|
50080
50176
|
/* @__PURE__ */ jsx("span", { className: "text-xs sm:text-sm md:text-base font-medium text-blue-600", children: formatDate(operationalDate) }),
|
|
50081
50177
|
/* @__PURE__ */ jsx("div", { className: "hidden sm:block w-px h-4 bg-blue-300" }),
|
|
50082
50178
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 sm:gap-2", children: [
|
|
50083
|
-
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children:
|
|
50179
|
+
/* @__PURE__ */ jsx("div", { className: "text-blue-600", children: getShiftIcon() }),
|
|
50084
50180
|
/* @__PURE__ */ jsxs("span", { className: "text-xs sm:text-sm md:text-base font-medium text-blue-600", children: [
|
|
50085
50181
|
shiftType,
|
|
50086
50182
|
" Shift"
|