@optifye/dashboard-core 6.0.7 → 6.0.9

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.mjs CHANGED
@@ -4584,20 +4584,13 @@ var useRealtimeLineMetrics = ({
4584
4584
  workspaceData: workspaceData?.length
4585
4585
  });
4586
4586
  }
4587
- let avgEfficiency = 0;
4588
- if (workspaceData && workspaceData.length > 0) {
4589
- const activeWorkspaces = workspaceData.filter((w) => w.efficiency >= 10);
4590
- if (activeWorkspaces.length > 0) {
4591
- const totalEfficiency = activeWorkspaces.reduce((sum, workspace) => sum + (workspace.efficiency || 0), 0);
4592
- avgEfficiency = totalEfficiency / activeWorkspaces.length;
4593
- }
4594
- }
4587
+ const avgEfficiency = metricsData.reduce((sum, m) => sum + (m.avg_efficiency || 0), 0) / metricsData.length;
4595
4588
  const combinedMetrics = {
4596
4589
  line_id: factoryViewId,
4597
4590
  shift_id: shiftId,
4598
4591
  date,
4599
4592
  factory_id: firstLine.factory_id,
4600
- avg_efficiency: avgEfficiency > 0 ? avgEfficiency : metricsData.reduce((sum, m) => sum + (m.avg_efficiency || 0), 0) / metricsData.length,
4593
+ avg_efficiency: avgEfficiency,
4601
4594
  avg_cycle_time: metricsData.reduce((sum, m) => sum + (m.avg_cycle_time || 0), 0) / metricsData.length,
4602
4595
  current_output: metricsData.reduce((sum, m) => sum + (m.current_output || 0), 0),
4603
4596
  ideal_output: metricsData.reduce((sum, m) => sum + (m.ideal_output || 0), 0),
@@ -4649,22 +4642,14 @@ var useRealtimeLineMetrics = ({
4649
4642
  workspaceData: workspaceData?.length
4650
4643
  });
4651
4644
  }
4652
- let avgEfficiency = 0;
4653
- if (workspaceData && workspaceData.length > 0) {
4654
- const activeWorkspaces = workspaceData.filter((w) => w.efficiency >= 10);
4655
- if (activeWorkspaces.length > 0) {
4656
- const totalEfficiency = activeWorkspaces.reduce((sum, workspace) => sum + (workspace.efficiency || 0), 0);
4657
- avgEfficiency = totalEfficiency / activeWorkspaces.length;
4658
- }
4659
- }
4660
4645
  if (!metricsData) {
4661
4646
  setMetrics({
4662
4647
  line_id: lineIdRef.current,
4663
4648
  shift_id: shiftId,
4664
4649
  date,
4665
4650
  factory_id: "",
4666
- avg_efficiency: avgEfficiency,
4667
- // Use calculated workspace average
4651
+ avg_efficiency: 0,
4652
+ // Default to 0 when no data
4668
4653
  avg_cycle_time: 0,
4669
4654
  current_output: 0,
4670
4655
  ideal_output: 0,
@@ -4683,7 +4668,6 @@ var useRealtimeLineMetrics = ({
4683
4668
  } else {
4684
4669
  setMetrics({
4685
4670
  ...metricsData,
4686
- avg_efficiency: avgEfficiency > 0 ? avgEfficiency : metricsData.avg_efficiency,
4687
4671
  poorest_performing_workspaces: poorestPerformingWorkspaces
4688
4672
  });
4689
4673
  }
@@ -5532,6 +5516,7 @@ console.log("\u{1F504} workspaceDisplayNames.ts module loaded");
5532
5516
  var runtimeWorkspaceDisplayNames = {};
5533
5517
  var isInitialized = false;
5534
5518
  var isInitializing = false;
5519
+ var initializedWithLineIds = [];
5535
5520
  function getCurrentLineIds() {
5536
5521
  try {
5537
5522
  const config = _getDashboardConfigInstance();
@@ -5563,28 +5548,29 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
5563
5548
  targetLineIds = getCurrentLineIds();
5564
5549
  }
5565
5550
  console.log("\u{1F504} Target line IDs for workspace filtering:", targetLineIds);
5566
- const allDisplayNamesMap = /* @__PURE__ */ new Map();
5551
+ runtimeWorkspaceDisplayNames = {};
5567
5552
  if (targetLineIds.length > 0) {
5568
5553
  for (const lineId of targetLineIds) {
5569
5554
  console.log(`\u{1F504} Fetching workspaces for line: ${lineId}`);
5570
5555
  const lineDisplayNamesMap = await workspaceService.getWorkspaceDisplayNames(void 0, lineId);
5556
+ runtimeWorkspaceDisplayNames[lineId] = {};
5571
5557
  lineDisplayNamesMap.forEach((displayName, workspaceId) => {
5572
- allDisplayNamesMap.set(workspaceId, displayName);
5558
+ runtimeWorkspaceDisplayNames[lineId][workspaceId] = displayName;
5573
5559
  });
5560
+ console.log(`\u2705 Stored ${lineDisplayNamesMap.size} workspaces for line ${lineId}`);
5574
5561
  }
5575
5562
  } else {
5576
5563
  console.warn("\u26A0\uFE0F No line IDs found, fetching all workspaces (less efficient)");
5577
5564
  const allWorkspacesMap = await workspaceService.getWorkspaceDisplayNames();
5565
+ runtimeWorkspaceDisplayNames["global"] = {};
5578
5566
  allWorkspacesMap.forEach((displayName, workspaceId) => {
5579
- allDisplayNamesMap.set(workspaceId, displayName);
5567
+ runtimeWorkspaceDisplayNames["global"][workspaceId] = displayName;
5580
5568
  });
5581
5569
  }
5582
- runtimeWorkspaceDisplayNames = {};
5583
- allDisplayNamesMap.forEach((displayName, workspaceId) => {
5584
- runtimeWorkspaceDisplayNames[workspaceId] = displayName;
5585
- });
5586
5570
  isInitialized = true;
5571
+ initializedWithLineIds = targetLineIds;
5587
5572
  console.log("\u2705 Workspace display names initialized from Supabase:", runtimeWorkspaceDisplayNames);
5573
+ console.log("\u2705 Initialized with line IDs:", initializedWithLineIds);
5588
5574
  } catch (error) {
5589
5575
  console.error("\u274C Failed to initialize workspace display names from Supabase:", error);
5590
5576
  } finally {
@@ -5594,7 +5580,20 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
5594
5580
  var preInitializeWorkspaceDisplayNames = async (lineId) => {
5595
5581
  console.log("\u{1F504} preInitializeWorkspaceDisplayNames called for lineId:", lineId);
5596
5582
  if (isInitialized || isInitializing) {
5597
- console.log("\u{1F504} Already initialized or initializing, skipping pre-init");
5583
+ console.log("\u{1F504} Already initialized or initializing");
5584
+ if (lineId && !runtimeWorkspaceDisplayNames[lineId]) {
5585
+ console.log(`\u{1F504} Line ${lineId} not in cache, fetching...`);
5586
+ try {
5587
+ const lineDisplayNamesMap = await workspaceService.getWorkspaceDisplayNames(void 0, lineId);
5588
+ runtimeWorkspaceDisplayNames[lineId] = {};
5589
+ lineDisplayNamesMap.forEach((displayName, workspaceId) => {
5590
+ runtimeWorkspaceDisplayNames[lineId][workspaceId] = displayName;
5591
+ });
5592
+ console.log(`\u2705 Added ${lineDisplayNamesMap.size} workspaces for line ${lineId}`);
5593
+ } catch (error) {
5594
+ console.error(`\u274C Failed to fetch workspaces for line ${lineId}:`, error);
5595
+ }
5596
+ }
5598
5597
  return;
5599
5598
  }
5600
5599
  await initializeWorkspaceDisplayNames(lineId);
@@ -5607,45 +5606,91 @@ var forceRefreshWorkspaceDisplayNames = async (lineId) => {
5607
5606
  console.log("\u{1F504} Module loaded, will initialize lazily when first function is called");
5608
5607
  var getWorkspaceDisplayName = (workspaceId, lineId) => {
5609
5608
  if (!isInitialized && !isInitializing) {
5610
- console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Not initialized, triggering lazy init...`);
5609
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) - Not initialized, triggering lazy init...`);
5611
5610
  } else if (isInitializing) {
5612
- console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Currently initializing...`);
5611
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) - Currently initializing...`);
5613
5612
  }
5614
5613
  if (!isInitialized && !isInitializing) {
5615
- console.log("\u{1F504} Lazy initialization triggered by getWorkspaceDisplayName");
5614
+ console.log("\u{1F504} Lazy initialization triggered by getWorkspaceDisplayName with lineId:", lineId);
5616
5615
  initializeWorkspaceDisplayNames(lineId).catch((error) => {
5617
5616
  console.error("\u274C Lazy initialization failed:", error);
5618
5617
  });
5619
5618
  }
5620
- const displayName = runtimeWorkspaceDisplayNames[workspaceId];
5619
+ if (isInitialized && lineId && !runtimeWorkspaceDisplayNames[lineId]) {
5620
+ console.log(`\u{1F504} Line ${lineId} not in cache, fetching its workspaces...`);
5621
+ workspaceService.getWorkspaceDisplayNames(void 0, lineId).then((lineDisplayNamesMap) => {
5622
+ runtimeWorkspaceDisplayNames[lineId] = {};
5623
+ lineDisplayNamesMap.forEach((displayName2, workspaceId2) => {
5624
+ runtimeWorkspaceDisplayNames[lineId][workspaceId2] = displayName2;
5625
+ });
5626
+ console.log(`\u2705 Added ${lineDisplayNamesMap.size} workspaces for line ${lineId} to cache`);
5627
+ }).catch((error) => {
5628
+ console.error(`\u274C Failed to fetch workspaces for line ${lineId}:`, error);
5629
+ });
5630
+ }
5631
+ let displayName;
5632
+ if (lineId && runtimeWorkspaceDisplayNames[lineId]) {
5633
+ displayName = runtimeWorkspaceDisplayNames[lineId][workspaceId];
5634
+ } else if (!lineId) {
5635
+ for (const cachedLineId of Object.keys(runtimeWorkspaceDisplayNames)) {
5636
+ if (runtimeWorkspaceDisplayNames[cachedLineId][workspaceId]) {
5637
+ displayName = runtimeWorkspaceDisplayNames[cachedLineId][workspaceId];
5638
+ console.warn(`\u26A0\uFE0F No lineId provided for ${workspaceId}, found in line ${cachedLineId}`);
5639
+ break;
5640
+ }
5641
+ }
5642
+ }
5621
5643
  if (displayName) {
5622
- console.log(`getWorkspaceDisplayName(${workspaceId}) -> ${displayName} (from Supabase)`);
5644
+ console.log(`getWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) -> ${displayName} (from Supabase)`);
5623
5645
  return displayName;
5624
5646
  } else {
5625
5647
  if (isInitialized) {
5626
- console.log(`getWorkspaceDisplayName(${workspaceId}) -> ${workspaceId} (not found in Supabase data)`);
5648
+ console.log(`getWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) -> ${workspaceId} (not found in Supabase data)`);
5627
5649
  } else {
5628
- console.log(`getWorkspaceDisplayName(${workspaceId}) -> ${workspaceId} (Supabase not initialized yet)`);
5650
+ console.log(`getWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) -> ${workspaceId} (Supabase not initialized yet)`);
5629
5651
  }
5630
5652
  return workspaceId;
5631
5653
  }
5632
5654
  };
5633
5655
  var getShortWorkspaceDisplayName = (workspaceId, lineId) => {
5634
5656
  if (!isInitialized && !isInitializing) {
5635
- console.log("\u{1F504} Lazy initialization triggered by getShortWorkspaceDisplayName");
5657
+ console.log("\u{1F504} Lazy initialization triggered by getShortWorkspaceDisplayName with lineId:", lineId);
5636
5658
  initializeWorkspaceDisplayNames(lineId).catch((error) => {
5637
5659
  console.error("\u274C Lazy initialization failed:", error);
5638
5660
  });
5639
5661
  }
5640
- const displayName = runtimeWorkspaceDisplayNames[workspaceId];
5662
+ if (isInitialized && lineId && !runtimeWorkspaceDisplayNames[lineId]) {
5663
+ console.log(`\u{1F504} Line ${lineId} not in cache, fetching its workspaces...`);
5664
+ workspaceService.getWorkspaceDisplayNames(void 0, lineId).then((lineDisplayNamesMap) => {
5665
+ runtimeWorkspaceDisplayNames[lineId] = {};
5666
+ lineDisplayNamesMap.forEach((displayName2, workspaceId2) => {
5667
+ runtimeWorkspaceDisplayNames[lineId][workspaceId2] = displayName2;
5668
+ });
5669
+ console.log(`\u2705 Added ${lineDisplayNamesMap.size} workspaces for line ${lineId} to cache`);
5670
+ }).catch((error) => {
5671
+ console.error(`\u274C Failed to fetch workspaces for line ${lineId}:`, error);
5672
+ });
5673
+ }
5674
+ let displayName;
5675
+ if (lineId && runtimeWorkspaceDisplayNames[lineId]) {
5676
+ displayName = runtimeWorkspaceDisplayNames[lineId][workspaceId];
5677
+ } else if (!lineId) {
5678
+ for (const cachedLineId of Object.keys(runtimeWorkspaceDisplayNames)) {
5679
+ if (runtimeWorkspaceDisplayNames[cachedLineId][workspaceId]) {
5680
+ displayName = runtimeWorkspaceDisplayNames[cachedLineId][workspaceId];
5681
+ console.warn(`\u26A0\uFE0F No lineId provided for ${workspaceId}, found in line ${cachedLineId}`);
5682
+ break;
5683
+ }
5684
+ }
5685
+ }
5641
5686
  if (displayName) {
5642
- console.log(`getShortWorkspaceDisplayName(${workspaceId}) -> ${displayName} (from Supabase)`);
5687
+ console.log(`getShortWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) -> ${displayName} (from Supabase)`);
5643
5688
  return displayName;
5644
5689
  } else {
5645
5690
  if (isInitialized) {
5646
- console.log(`getShortWorkspaceDisplayName(${workspaceId}) -> ${workspaceId} (not found in Supabase data)`);
5691
+ console.log(`getShortWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) -> ${workspaceId} (not found in Supabase data)`);
5647
5692
  } else {
5648
- console.log(`getShortWorkspaceDisplayName(${workspaceId}) -> ${workspaceId} (Supabase not initialized yet)`);
5693
+ console.log(`getShortWorkspaceDisplayName(${workspaceId}, lineId: ${lineId}) -> ${workspaceId} (Supabase not initialized yet)`);
5649
5694
  }
5650
5695
  return workspaceId;
5651
5696
  }
@@ -5666,7 +5711,14 @@ var getAllWorkspaceDisplayNamesAsync = async (companyId, lineId) => {
5666
5711
  while (isInitializing) {
5667
5712
  await new Promise((resolve) => setTimeout(resolve, 100));
5668
5713
  }
5669
- return { ...runtimeWorkspaceDisplayNames };
5714
+ if (lineId && runtimeWorkspaceDisplayNames[lineId]) {
5715
+ return { ...runtimeWorkspaceDisplayNames[lineId] };
5716
+ }
5717
+ const allNames = {};
5718
+ Object.values(runtimeWorkspaceDisplayNames).forEach((lineNames) => {
5719
+ Object.assign(allNames, lineNames);
5720
+ });
5721
+ return allNames;
5670
5722
  };
5671
5723
  var getWorkspaceDisplayNamesMap = async (workspaceIds, companyId, lineId) => {
5672
5724
  const allNames = await getAllWorkspaceDisplayNamesAsync(companyId, lineId);
@@ -5695,10 +5747,11 @@ var clearWorkspaceDisplayNamesCache = () => {
5695
5747
  runtimeWorkspaceDisplayNames = {};
5696
5748
  isInitialized = false;
5697
5749
  isInitializing = false;
5750
+ initializedWithLineIds = [];
5698
5751
  };
5699
5752
 
5700
5753
  // src/lib/hooks/useWorkspaceDisplayNames.ts
5701
- var useWorkspaceDisplayNames = (companyId, lineId) => {
5754
+ var useWorkspaceDisplayNames = (lineId, companyId) => {
5702
5755
  const [displayNames, setDisplayNames] = useState({});
5703
5756
  const [loading, setLoading] = useState(true);
5704
5757
  const [error, setError] = useState(null);
@@ -5724,7 +5777,7 @@ var useWorkspaceDisplayNames = (companyId, lineId) => {
5724
5777
  refetch: fetchDisplayNames
5725
5778
  };
5726
5779
  };
5727
- var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
5780
+ var useWorkspaceDisplayName = (workspaceId, lineId, companyId) => {
5728
5781
  const [displayName, setDisplayName] = useState(workspaceId);
5729
5782
  const [loading, setLoading] = useState(true);
5730
5783
  const [error, setError] = useState(null);
@@ -5751,7 +5804,7 @@ var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
5751
5804
  refetch: fetchDisplayName
5752
5805
  };
5753
5806
  };
5754
- var useWorkspaceDisplayNamesMap = (workspaceIds, companyId, lineId) => {
5807
+ var useWorkspaceDisplayNamesMap = (workspaceIds, lineId, companyId) => {
5755
5808
  const [displayNames, setDisplayNames] = useState({});
5756
5809
  const [loading, setLoading] = useState(true);
5757
5810
  const [error, setError] = useState(null);
@@ -18462,7 +18515,7 @@ var VideoCard = React19__default.memo(({
18462
18515
  onFatalError: onFatalError ?? (() => throttledReloadDashboard())
18463
18516
  });
18464
18517
  }
18465
- const displayName = getWorkspaceDisplayName(workspace.workspace_name);
18518
+ const displayName = getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id);
18466
18519
  const getEfficiencyOverlayColor = (efficiency) => {
18467
18520
  if (efficiency >= 80) {
18468
18521
  return "bg-[#00D654]/25";
@@ -18584,7 +18637,9 @@ var VideoGridView = React19__default.memo(({
18584
18637
  const containerRef = useRef(null);
18585
18638
  const observerRef = useRef(null);
18586
18639
  const [gridCols, setGridCols] = useState(4);
18640
+ const [gridRows, setGridRows] = useState(1);
18587
18641
  const [visibleWorkspaces, setVisibleWorkspaces] = useState(/* @__PURE__ */ new Set());
18642
+ const [cardDimensions, setCardDimensions] = useState({ width: 0, height: 0 });
18588
18643
  const videoConfig = useVideoConfig();
18589
18644
  const { cropping, canvasConfig, hlsUrls } = videoConfig;
18590
18645
  const mergedVideoSources = {
@@ -18645,35 +18700,51 @@ var VideoGridView = React19__default.memo(({
18645
18700
  setGridCols(1);
18646
18701
  return;
18647
18702
  }
18648
- let bestCols = 1;
18649
- let bestScore = 0;
18703
+ const optimalLayouts = {
18704
+ 1: 1,
18705
+ 2: 2,
18706
+ 3: 3,
18707
+ 4: 2,
18708
+ 5: 3,
18709
+ 6: 3,
18710
+ 7: 4,
18711
+ 8: 4,
18712
+ 9: 3,
18713
+ 10: 5,
18714
+ 11: 4,
18715
+ 12: 4,
18716
+ 13: 5,
18717
+ 14: 5,
18718
+ 15: 5,
18719
+ 16: 4,
18720
+ 17: 6,
18721
+ 18: 6,
18722
+ 19: 5,
18723
+ 20: 5,
18724
+ 21: 7,
18725
+ 22: 6,
18726
+ 23: 6,
18727
+ 24: 6
18728
+ };
18729
+ let bestCols = optimalLayouts[count] || Math.ceil(Math.sqrt(count));
18730
+ const containerAspectRatio = containerWidth / containerHeight;
18650
18731
  const targetAspectRatio = 16 / 9;
18651
18732
  const gap = 8;
18652
- const maxCols = Math.min(count, selectedLine ? 6 : 12);
18653
- for (let cols = 1; cols <= maxCols; cols++) {
18654
- const rows = Math.ceil(count / cols);
18655
- const availableWidth = containerWidth - gap * (cols - 1);
18656
- const availableHeight = containerHeight - gap * (rows - 1);
18657
- const cellWidth = availableWidth / cols;
18658
- const cellHeight = availableHeight / rows;
18659
- const minCellWidth = selectedLine ? containerWidth < 800 ? 120 : 150 : containerWidth < 800 ? 80 : 100;
18660
- const minCellHeight = selectedLine ? containerHeight < 600 ? 80 : 100 : containerHeight < 600 ? 60 : 80;
18661
- if (cellWidth < minCellWidth || cellHeight < minCellHeight) continue;
18662
- const totalUsedArea = cellWidth * cellHeight * count;
18663
- const totalAvailableArea = containerWidth * containerHeight;
18664
- const spaceUtilization = totalUsedArea / totalAvailableArea;
18665
- const actualAspectRatio = cellWidth / cellHeight;
18666
- const aspectRatioScore = 1 / (1 + Math.abs(actualAspectRatio - targetAspectRatio) * 0.3);
18667
- const score = spaceUtilization * 0.9 + aspectRatioScore * 0.1;
18668
- if (score > bestScore) {
18669
- bestScore = score;
18670
- bestCols = cols;
18671
- }
18672
- }
18673
- if (bestScore === 0) {
18674
- bestCols = Math.ceil(Math.sqrt(count));
18733
+ if (containerAspectRatio > targetAspectRatio * 1.5 && count > 6) {
18734
+ bestCols = Math.min(bestCols + 1, Math.ceil(count / 2));
18735
+ }
18736
+ const minCellWidth = selectedLine ? 150 : 100;
18737
+ const availableWidth = containerWidth - gap * (bestCols - 1);
18738
+ const cellWidth = availableWidth / bestCols;
18739
+ if (cellWidth < minCellWidth && bestCols > 1) {
18740
+ bestCols = Math.floor((containerWidth + gap) / (minCellWidth + gap));
18675
18741
  }
18742
+ const rows = Math.ceil(count / bestCols);
18676
18743
  setGridCols(bestCols);
18744
+ setGridRows(rows);
18745
+ const cardWidth = (containerWidth - gap * (bestCols - 1)) / bestCols;
18746
+ const cardHeight = (containerHeight - gap * (rows - 1)) / rows;
18747
+ setCardDimensions({ width: Math.floor(cardWidth), height: Math.floor(cardHeight) });
18677
18748
  }, [filteredWorkspaces.length, selectedLine]);
18678
18749
  useEffect(() => {
18679
18750
  calculateOptimalGrid();
@@ -18719,7 +18790,7 @@ var VideoGridView = React19__default.memo(({
18719
18790
  efficiency: workspace.efficiency,
18720
18791
  action_count: workspace.action_count
18721
18792
  });
18722
- const displayName = getWorkspaceDisplayName(workspace.workspace_name);
18793
+ const displayName = getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id);
18723
18794
  const navParams = getWorkspaceNavigationParams(workspaceId, displayName);
18724
18795
  router.push(`/workspace/${workspaceId}${navParams}`);
18725
18796
  }, [router]);
@@ -18729,8 +18800,8 @@ var VideoGridView = React19__default.memo(({
18729
18800
  className: "grid h-full w-full gap-2",
18730
18801
  style: {
18731
18802
  gridTemplateColumns: `repeat(${gridCols}, 1fr)`,
18732
- gridTemplateRows: `repeat(${Math.ceil(filteredWorkspaces.length / gridCols)}, 1fr)`,
18733
- minHeight: "100%"
18803
+ gridTemplateRows: `repeat(${gridRows}, 1fr)`,
18804
+ gridAutoFlow: "row"
18734
18805
  },
18735
18806
  children: filteredWorkspaces.sort((a, b) => {
18736
18807
  if (a.line_id !== b.line_id) {
@@ -18753,9 +18824,8 @@ var VideoGridView = React19__default.memo(({
18753
18824
  "div",
18754
18825
  {
18755
18826
  "data-workspace-id": workspaceId,
18756
- className: "workspace-card relative min-h-0 min-w-0",
18757
- style: { width: "100%", height: "100%" },
18758
- children: /* @__PURE__ */ jsx(
18827
+ className: "workspace-card relative w-full h-full",
18828
+ children: /* @__PURE__ */ jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsx(
18759
18829
  VideoCard,
18760
18830
  {
18761
18831
  workspace,
@@ -18769,7 +18839,7 @@ var VideoGridView = React19__default.memo(({
18769
18839
  useRAF: canvasConfig?.useRAF,
18770
18840
  compact: !selectedLine
18771
18841
  }
18772
- )
18842
+ ) })
18773
18843
  },
18774
18844
  workspaceId
18775
18845
  );
@@ -20194,7 +20264,7 @@ var LineMonthlyHistory = ({
20194
20264
  className: "block hover:bg-gray-50 transition-colors rounded-lg w-full text-left",
20195
20265
  children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between py-3 px-2 border-b border-gray-100 last:border-b-0", children: [
20196
20266
  /* @__PURE__ */ jsxs("div", { className: "font-medium text-gray-900", children: [
20197
- getWorkspaceDisplayName(workspace.workspace_name),
20267
+ getWorkspaceDisplayName(workspace.workspace_name, lineId),
20198
20268
  workspace.avg_efficiency !== void 0 && /* @__PURE__ */ jsxs("span", { className: "ml-2 text-sm text-gray-500", children: [
20199
20269
  "(",
20200
20270
  workspace.avg_efficiency.toFixed(1),
@@ -20778,7 +20848,7 @@ var LinePdfGenerator = ({
20778
20848
  doc.setFillColor(252, 252, 252);
20779
20849
  doc.roundedRect(20, yPos - 5, 170, 8, 1, 1, "F");
20780
20850
  }
20781
- const workspaceName = getWorkspaceDisplayName(ws.workspace_name);
20851
+ const workspaceName = getWorkspaceDisplayName(ws.workspace_name, lineInfo.line_id);
20782
20852
  const maxWidth = 55;
20783
20853
  const truncatedName = workspaceName.length > 25 ? workspaceName.substring(0, 22) + "..." : workspaceName;
20784
20854
  doc.text(truncatedName, 25, yPos);
@@ -21459,7 +21529,7 @@ var WorkspacePdfGenerator = ({ workspace, className }) => {
21459
21529
  doc.setFontSize(22);
21460
21530
  doc.setFont("helvetica", "normal");
21461
21531
  doc.setTextColor(40, 40, 40);
21462
- doc.text(getWorkspaceDisplayName(workspace.workspace_name), 20, 52);
21532
+ doc.text(getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id), 20, 52);
21463
21533
  doc.setFontSize(13);
21464
21534
  doc.setFont("helvetica", "normal");
21465
21535
  doc.setTextColor(60, 60, 60);
@@ -23928,7 +23998,7 @@ var WorkspaceGridItem = React19__default.memo(({
23928
23998
  const handleClick = useCallback((e) => {
23929
23999
  e.preventDefault();
23930
24000
  if (isInactive) return;
23931
- const displayName = getWorkspaceDisplayName(data.workspace_name);
24001
+ const displayName = getWorkspaceDisplayName(data.workspace_name, data.line_id);
23932
24002
  const navParams = getWorkspaceNavigationParams(data.workspace_id, displayName);
23933
24003
  navigate(`/workspace/${data.workspace_id}${navParams}`, {
23934
24004
  trackingEvent: {
@@ -23976,7 +24046,7 @@ var WorkspaceGridItem = React19__default.memo(({
23976
24046
  onClick: handleClick,
23977
24047
  className: `${styles2} ${colorClass} ${isBottleneck ? "ring-2 ring-red-500/70" : ""} ${isVeryLowEfficiency ? "ring-2 ring-red-500/50" : ""} ${isInactive ? "bg-gray-200" : ""} shadow-lg`,
23978
24048
  "aria-label": isInactive ? `Inactive workspace ${workspaceNumber}` : `View details for workspace ${workspaceNumber}`,
23979
- title: isInactive ? `Inactive: ${getWorkspaceDisplayName(data.workspace_name)}` : getWorkspaceDisplayName(data.workspace_name),
24049
+ title: isInactive ? `Inactive: ${getWorkspaceDisplayName(data.workspace_name, data.line_id)}` : getWorkspaceDisplayName(data.workspace_name, data.line_id),
23980
24050
  children: /* @__PURE__ */ jsx("div", { className: `font-semibold tracking-wide text-[min(4vw,2rem)] uppercase ${isInactive ? "text-gray-400" : "text-white"} drop-shadow-sm`, children: workspaceNumber })
23981
24051
  }
23982
24052
  ),
@@ -28791,6 +28861,7 @@ var MetricCards = memo(({ lineInfo }) => {
28791
28861
  MetricCards.displayName = "MetricCards";
28792
28862
  var BottomSection = memo(({
28793
28863
  lineInfo,
28864
+ lineId,
28794
28865
  workspaceData,
28795
28866
  sortedByEfficiency,
28796
28867
  hourlyOutputData,
@@ -28848,7 +28919,7 @@ var BottomSection = memo(({
28848
28919
  return null;
28849
28920
  }
28850
28921
  const clickHandler = () => handleWorkspaceClick(ws, index);
28851
- const displayName = getWorkspaceDisplayName(ws.workspace_name);
28922
+ const displayName = getWorkspaceDisplayName(ws.workspace_name, lineId);
28852
28923
  const navParams = wsUuid ? getWorkspaceNavigationParams2(wsUuid, displayName) : "";
28853
28924
  const dateShiftParams = urlDate ? `&date=${urlDate}&shift=${urlShift || "0"}` : "";
28854
28925
  const returnToParam = `&returnTo=${encodeURIComponent(`/kpis/${lineInfo?.line_id}`)}`;
@@ -28882,7 +28953,7 @@ var BottomSection = memo(({
28882
28953
  // Fallback to sorted workspaces if no poorest performing workspaces provided
28883
28954
  sortedByEfficiency.map((ws, index) => {
28884
28955
  const clickHandler = () => handleWorkspaceClick(ws, index);
28885
- const displayName = getWorkspaceDisplayName(ws.workspace_name);
28956
+ const displayName = getWorkspaceDisplayName(ws.workspace_name, lineId);
28886
28957
  const navParams = ws.workspace_uuid ? getWorkspaceNavigationParams2(ws.workspace_uuid, displayName) : "";
28887
28958
  const dateShiftParams = urlDate ? `&date=${urlDate}&shift=${urlShift || "0"}` : "";
28888
28959
  const returnToParam = `&returnTo=${encodeURIComponent(`/kpis/${lineInfo?.line_id}`)}`;
@@ -29379,6 +29450,7 @@ var KPIDetailView = ({
29379
29450
  BottomSection,
29380
29451
  {
29381
29452
  lineInfo,
29453
+ lineId,
29382
29454
  workspaceData: workspaces || [],
29383
29455
  sortedByEfficiency,
29384
29456
  hourlyOutputData,
@@ -29481,6 +29553,7 @@ var KPIDetailView = ({
29481
29553
  BottomSection,
29482
29554
  {
29483
29555
  lineInfo,
29556
+ lineId,
29484
29557
  workspaceData: workspaces || [],
29485
29558
  sortedByEfficiency,
29486
29559
  hourlyOutputData,
@@ -29499,34 +29572,10 @@ var KPIDetailView = ({
29499
29572
  var KPIDetailView_default = KPIDetailView;
29500
29573
  var LineCard = ({ line, onClick }) => {
29501
29574
  const { kpis, isLoading, error } = useLineKPIs({ lineId: line.id });
29502
- const shiftConfig = useShiftConfig();
29503
- const dateTimeConfig = useDateTimeConfig();
29504
29575
  const isOnTrack = React19__default.useMemo(() => {
29505
29576
  if (!kpis) return null;
29506
- const currentTime = /* @__PURE__ */ new Date();
29507
- const timezone = dateTimeConfig.defaultTimezone || "Asia/Kolkata";
29508
- const currentShiftDetails = getCurrentShift(timezone, shiftConfig);
29509
- const shiftStartTime = currentShiftDetails.shiftId === 0 ? shiftConfig.dayShift?.startTime || "06:00" : shiftConfig.nightShift?.startTime || "18:00";
29510
- const shiftEndTime = currentShiftDetails.shiftId === 0 ? shiftConfig.dayShift?.endTime || "14:00" : shiftConfig.nightShift?.endTime || "02:00";
29511
- const [startHour, startMin] = shiftStartTime.split(":").map(Number);
29512
- const [endHour, endMin] = shiftEndTime.split(":").map(Number);
29513
- const shiftStart = /* @__PURE__ */ new Date();
29514
- shiftStart.setHours(startHour, startMin, 0, 0);
29515
- const shiftEnd = /* @__PURE__ */ new Date();
29516
- shiftEnd.setHours(endHour, endMin, 0, 0);
29517
- if (endHour < startHour) {
29518
- if (currentTime.getHours() < endHour) {
29519
- shiftStart.setDate(shiftStart.getDate() - 1);
29520
- } else {
29521
- shiftEnd.setDate(shiftEnd.getDate() + 1);
29522
- }
29523
- }
29524
- const totalShiftMinutes = (shiftEnd.getTime() - shiftStart.getTime()) / (1e3 * 60);
29525
- const elapsedMinutes = (currentTime.getTime() - shiftStart.getTime()) / (1e3 * 60);
29526
- const shiftProgress = Math.max(0, Math.min(1, elapsedMinutes / totalShiftMinutes));
29527
- const outputProgress = kpis.outputProgress.current / kpis.outputProgress.target;
29528
- return outputProgress >= shiftProgress - 0.05;
29529
- }, [kpis, shiftConfig, dateTimeConfig]);
29577
+ return kpis.efficiency.value > 90;
29578
+ }, [kpis]);
29530
29579
  return /* @__PURE__ */ jsxs(
29531
29580
  motion.div,
29532
29581
  {
@@ -29842,7 +29891,7 @@ var MobileWorkspaceCard = memo(({
29842
29891
  getMedalIcon(rank)
29843
29892
  ] }),
29844
29893
  /* @__PURE__ */ jsxs("div", { children: [
29845
- /* @__PURE__ */ jsx("div", { className: "font-semibold text-gray-900", children: getWorkspaceDisplayName(workspace.workspace_name) }),
29894
+ /* @__PURE__ */ jsx("div", { className: "font-semibold text-gray-900", children: getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id) }),
29846
29895
  /* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500", children: getLineName(workspace.line_id) })
29847
29896
  ] })
29848
29897
  ] }),
@@ -29892,7 +29941,7 @@ var DesktopWorkspaceRow = memo(({
29892
29941
  /* @__PURE__ */ jsx("span", { children: index + 1 }),
29893
29942
  getMedalIcon(index + 1)
29894
29943
  ] }) }),
29895
- /* @__PURE__ */ jsx("td", { className: "px-3 py-2.5 sm:p-4 text-sm sm:text-base whitespace-nowrap", children: /* @__PURE__ */ jsx("div", { className: "font-medium", children: getWorkspaceDisplayName(workspace.workspace_name) }) }),
29944
+ /* @__PURE__ */ jsx("td", { className: "px-3 py-2.5 sm:p-4 text-sm sm:text-base whitespace-nowrap", children: /* @__PURE__ */ jsx("div", { className: "font-medium", children: getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id) }) }),
29896
29945
  /* @__PURE__ */ jsx("td", { className: "px-3 py-2.5 sm:p-4 text-sm sm:text-base whitespace-nowrap", children: /* @__PURE__ */ jsx("div", { className: "font-medium", children: getLineName(workspace.line_id) }) }),
29897
29946
  /* @__PURE__ */ jsxs("td", { className: "px-3 py-2.5 sm:p-4 text-sm sm:text-base font-medium whitespace-nowrap", children: [
29898
29947
  (workspace.efficiency || 0).toFixed(1),
@@ -30009,7 +30058,7 @@ var LeaderboardDetailView = memo(({
30009
30058
  action_count: workspace.action_count,
30010
30059
  action_threshold: workspace.action_threshold
30011
30060
  });
30012
- const displayName = getWorkspaceDisplayName(workspace.workspace_name);
30061
+ const displayName = getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id);
30013
30062
  const navParams = workspace.workspace_uuid ? getWorkspaceNavigationParams(workspace.workspace_uuid, displayName) : "";
30014
30063
  const returnToParam = `&returnTo=${encodeURIComponent(`/leaderboard`)}`;
30015
30064
  if (onWorkspaceClick) {
@@ -31237,8 +31286,8 @@ var calculateDayOutput = (pph, shiftHours, breaks = []) => {
31237
31286
  const realWorkHours = shiftHours - totalBreakHours;
31238
31287
  return Math.round(pph * realWorkHours);
31239
31288
  };
31240
- var formatWorkspaceName = (name) => {
31241
- return getWorkspaceDisplayName(name);
31289
+ var formatWorkspaceName = (name, lineId) => {
31290
+ return getWorkspaceDisplayName(name, lineId);
31242
31291
  };
31243
31292
  var getStoredLineState2 = (lineId) => {
31244
31293
  try {
@@ -31266,6 +31315,7 @@ var BulkConfigureModal = ({
31266
31315
  isOpen,
31267
31316
  onClose,
31268
31317
  lineWorkspaces,
31318
+ lineNames,
31269
31319
  onSave,
31270
31320
  selectedShift
31271
31321
  }) => {
@@ -31416,10 +31466,7 @@ var BulkConfigureModal = ({
31416
31466
  className: "block w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-sm\n shadow-sm focus:border-blue-500 focus:ring-blue-500 \n transition-all duration-200 hover:border-blue-400\n appearance-none bg-no-repeat bg-right pr-10\n hover:bg-blue-50/50",
31417
31467
  children: [
31418
31468
  /* @__PURE__ */ jsx("option", { value: "", children: "Select a line" }),
31419
- Object.entries(lineWorkspaces).map(([lineId, line]) => /* @__PURE__ */ jsxs("option", { value: lineId, className: "py-2", children: [
31420
- lineId,
31421
- " "
31422
- ] }, lineId))
31469
+ Object.entries(lineWorkspaces).map(([lineId, line]) => /* @__PURE__ */ jsx("option", { value: lineId, className: "py-2", children: lineNames[lineId] || lineId }, lineId))
31423
31470
  ]
31424
31471
  }
31425
31472
  )
@@ -31477,7 +31524,7 @@ var BulkConfigureModal = ({
31477
31524
  className: "rounded border-gray-300 text-blue-600 focus:ring-blue-500"
31478
31525
  }
31479
31526
  ),
31480
- /* @__PURE__ */ jsx("span", { className: `text-sm ${selectedWorkspaces.includes(workspace.id) ? "text-blue-900 font-medium" : "text-gray-900"}`, children: formatWorkspaceName(workspace.name) })
31527
+ /* @__PURE__ */ jsx("span", { className: `text-sm ${selectedWorkspaces.includes(workspace.id) ? "text-blue-900 font-medium" : "text-gray-900"}`, children: formatWorkspaceName(workspace.name, selectedLine) })
31481
31528
  ]
31482
31529
  },
31483
31530
  workspace.id
@@ -32164,7 +32211,7 @@ var TargetsViewUI = ({
32164
32211
  {
32165
32212
  className: "px-6 py-4 hover:bg-gray-50 transition-all duration-200",
32166
32213
  children: /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-12 gap-6 items-center", children: [
32167
- /* @__PURE__ */ jsx("div", { className: "col-span-2", children: /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-900", children: formatWorkspaceName(workspace.name) }) }),
32214
+ /* @__PURE__ */ jsx("div", { className: "col-span-2", children: /* @__PURE__ */ jsx("span", { className: "font-medium text-gray-900", children: formatWorkspaceName(workspace.name, lineId) }) }),
32168
32215
  /* @__PURE__ */ jsx("div", { className: "col-span-2", children: /* @__PURE__ */ jsxs(
32169
32216
  "select",
32170
32217
  {
@@ -32174,7 +32221,7 @@ var TargetsViewUI = ({
32174
32221
  onActionTypeChange(lineId, workspace.id, newActionType);
32175
32222
  },
32176
32223
  className: "w-full p-2 border border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm",
32177
- "aria-label": `Action type for ${formatWorkspaceName(workspace.name)}`,
32224
+ "aria-label": `Action type for ${formatWorkspaceName(workspace.name, lineId)}`,
32178
32225
  children: [
32179
32226
  /* @__PURE__ */ jsx("option", { value: "assembly", className: "py-2", children: "Assembly" }),
32180
32227
  /* @__PURE__ */ jsx("option", { value: "packaging", className: "py-2", children: "Packaging" })
@@ -32233,6 +32280,7 @@ var TargetsViewUI = ({
32233
32280
  isOpen: isBulkConfigureOpen,
32234
32281
  onClose: onToggleBulkConfigure,
32235
32282
  lineWorkspaces,
32283
+ lineNames,
32236
32284
  onSave: onBulkConfigure,
32237
32285
  selectedShift
32238
32286
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.0.7",
3
+ "version": "6.0.9",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",