@optifye/dashboard-core 6.9.15 → 6.9.17

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.js CHANGED
@@ -7909,17 +7909,56 @@ var useHistoricWorkspaceMetrics = (workspaceId, date, shiftId, options) => {
7909
7909
  }
7910
7910
  const data = await response.json();
7911
7911
  const fetchedMetrics = data.metrics;
7912
- if (fetchedMetrics && options?.shiftConfig) {
7912
+ if (!fetchedMetrics) {
7913
+ setMetrics(null);
7914
+ return;
7915
+ }
7916
+ const shiftConfig = options?.shiftConfig;
7917
+ const transformedMetrics = {
7918
+ workspace_id: fetchedMetrics.workspace_id,
7919
+ workspace_name: fetchedMetrics.workspace_name,
7920
+ line_id: fetchedMetrics.line_id,
7921
+ line_name: fetchedMetrics.line_name || "Line 1",
7922
+ company_id: fetchedMetrics.company_id || entityConfig.companyId || "",
7923
+ company_name: fetchedMetrics.company_name || "Nahar Group",
7924
+ date: fetchedMetrics.date,
7925
+ shift_id: fetchedMetrics.shift_id,
7926
+ action_name: fetchedMetrics.action_name || "",
7927
+ shift_start: fetchedMetrics.shift_start || (fetchedMetrics.shift_id === 1 ? shiftConfig?.nightShift?.startTime || "22:00" : shiftConfig?.dayShift?.startTime || "06:00"),
7928
+ shift_end: fetchedMetrics.shift_end || (fetchedMetrics.shift_id === 1 ? shiftConfig?.nightShift?.endTime || "06:00" : shiftConfig?.dayShift?.endTime || "14:00"),
7929
+ shift_type: fetchedMetrics.shift_type || (fetchedMetrics.shift_id === 0 ? "Day" : "Night"),
7930
+ pph_threshold: fetchedMetrics.pph_threshold || 0,
7931
+ // CRITICAL FIX: Map target_output properly - backend may return total_day_output instead
7932
+ target_output: fetchedMetrics.target_output || fetchedMetrics.total_day_output || 0,
7933
+ avg_pph: fetchedMetrics.avg_pph || 0,
7934
+ avg_cycle_time: fetchedMetrics.avg_cycle_time || 0,
7935
+ ideal_cycle_time: fetchedMetrics.ideal_cycle_time || 0,
7936
+ avg_efficiency: fetchedMetrics.avg_efficiency || fetchedMetrics.efficiency || 0,
7937
+ // CRITICAL FIX: Map total_actions properly - backend may return total_output instead
7938
+ total_actions: fetchedMetrics.total_actions || fetchedMetrics.total_output || 0,
7939
+ total_output: fetchedMetrics.total_output || 0,
7940
+ efficiency: fetchedMetrics.efficiency || fetchedMetrics.avg_efficiency || 0,
7941
+ hourly_action_counts: fetchedMetrics.hourly_action_counts || fetchedMetrics.output_hourly || [],
7942
+ workspace_rank: fetchedMetrics.workspace_rank || 0,
7943
+ total_workspaces: fetchedMetrics.total_workspaces || 42,
7944
+ ideal_output_until_now: fetchedMetrics.ideal_output || 0,
7945
+ output_difference: (fetchedMetrics.total_output || 0) - (fetchedMetrics.ideal_output || 0),
7946
+ idle_time: fetchedMetrics.idle_time || 0,
7947
+ idle_time_hourly: fetchedMetrics.idle_time_hourly || void 0,
7948
+ ...fetchedMetrics.compliance_efficiency !== void 0 && { compliance_efficiency: fetchedMetrics.compliance_efficiency },
7949
+ ...fetchedMetrics.sop_check !== void 0 && { sop_check: fetchedMetrics.sop_check },
7950
+ ...fetchedMetrics.performance_score !== void 0 && { performance_score: fetchedMetrics.performance_score }
7951
+ };
7952
+ if (shiftConfig) {
7913
7953
  const dynamicShiftName = getShiftNameById(
7914
- fetchedMetrics.shift_id,
7954
+ transformedMetrics.shift_id,
7915
7955
  timezone || "Asia/Kolkata",
7916
- // Fallback timezone
7917
- options.shiftConfig
7956
+ shiftConfig
7918
7957
  );
7919
- fetchedMetrics.shift_type = dynamicShiftName;
7920
- console.log(`[useHistoricWorkspaceMetrics] Overriding shift name for ID ${fetchedMetrics.shift_id}: ${dynamicShiftName}`);
7958
+ transformedMetrics.shift_type = dynamicShiftName;
7959
+ console.log(`[useHistoricWorkspaceMetrics] Overriding shift name for ID ${transformedMetrics.shift_id}: ${dynamicShiftName}`);
7921
7960
  }
7922
- setMetrics(fetchedMetrics || null);
7961
+ setMetrics(transformedMetrics);
7923
7962
  } catch (err) {
7924
7963
  console.error("[useHistoricWorkspaceMetrics] Error fetching historic metrics:", err);
7925
7964
  setError({ message: err.message, code: err.code || "FETCH_ERROR" });
@@ -47972,10 +48011,11 @@ var TargetsView = ({
47972
48011
  }
47973
48012
  let actionType = "assembly";
47974
48013
  let actionId = actionIdsData.assembly;
47975
- if (ws.action_id === packagingAction.id || ws.action_type === "packaging") {
48014
+ const effectiveActionId = threshold?.action_id ?? ws.action_id;
48015
+ if (effectiveActionId === packagingAction.id || !effectiveActionId && ws.action_type === "packaging") {
47976
48016
  actionType = "packaging";
47977
48017
  actionId = packagingAction.id;
47978
- } else if (ws.action_id === assemblyAction.id || ws.action_type === "assembly") {
48018
+ } else if (effectiveActionId === assemblyAction.id || !effectiveActionId && ws.action_type === "assembly") {
47979
48019
  actionType = "assembly";
47980
48020
  actionId = assemblyAction.id;
47981
48021
  }
@@ -49005,7 +49045,7 @@ var WorkspaceDetailView = ({
49005
49045
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col justify-center space-y-8", children: [
49006
49046
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center space-y-1", children: [
49007
49047
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
49008
- (workspace.total_actions / workspace.target_output * 100).toFixed(1),
49048
+ workspace.target_output > 0 ? (workspace.total_actions / workspace.target_output * 100).toFixed(1) : "0.0",
49009
49049
  "%"
49010
49050
  ] }),
49011
49051
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center gap-2 text-gray-500", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-medium", children: "of today's target" }) })
@@ -49024,7 +49064,7 @@ var WorkspaceDetailView = ({
49024
49064
  {
49025
49065
  initial: { width: 0 },
49026
49066
  animate: {
49027
- width: `${Math.min(100, workspace.total_actions / workspace.target_output * 100)}%`
49067
+ width: `${workspace.target_output > 0 ? Math.min(100, workspace.total_actions / workspace.target_output * 100) : 0}%`
49028
49068
  },
49029
49069
  transition: {
49030
49070
  duration: 1,
@@ -49124,7 +49164,7 @@ var WorkspaceDetailView = ({
49124
49164
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-[calc(100%-6rem)] justify-center space-y-8", children: [
49125
49165
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center space-y-1", children: [
49126
49166
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
49127
- (workspace.total_actions / workspace.target_output * 100).toFixed(1),
49167
+ workspace.target_output > 0 ? (workspace.total_actions / workspace.target_output * 100).toFixed(1) : "0.0",
49128
49168
  "%"
49129
49169
  ] }),
49130
49170
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center gap-2 text-gray-500", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-medium", children: "of today's target" }) })
@@ -49143,7 +49183,7 @@ var WorkspaceDetailView = ({
49143
49183
  {
49144
49184
  initial: { width: 0 },
49145
49185
  animate: {
49146
- width: `${Math.min(100, workspace.total_actions / workspace.target_output * 100)}%`
49186
+ width: `${workspace.target_output > 0 ? Math.min(100, workspace.total_actions / workspace.target_output * 100) : 0}%`
49147
49187
  },
49148
49188
  transition: {
49149
49189
  duration: 1,
package/dist/index.mjs CHANGED
@@ -7880,17 +7880,56 @@ var useHistoricWorkspaceMetrics = (workspaceId, date, shiftId, options) => {
7880
7880
  }
7881
7881
  const data = await response.json();
7882
7882
  const fetchedMetrics = data.metrics;
7883
- if (fetchedMetrics && options?.shiftConfig) {
7883
+ if (!fetchedMetrics) {
7884
+ setMetrics(null);
7885
+ return;
7886
+ }
7887
+ const shiftConfig = options?.shiftConfig;
7888
+ const transformedMetrics = {
7889
+ workspace_id: fetchedMetrics.workspace_id,
7890
+ workspace_name: fetchedMetrics.workspace_name,
7891
+ line_id: fetchedMetrics.line_id,
7892
+ line_name: fetchedMetrics.line_name || "Line 1",
7893
+ company_id: fetchedMetrics.company_id || entityConfig.companyId || "",
7894
+ company_name: fetchedMetrics.company_name || "Nahar Group",
7895
+ date: fetchedMetrics.date,
7896
+ shift_id: fetchedMetrics.shift_id,
7897
+ action_name: fetchedMetrics.action_name || "",
7898
+ shift_start: fetchedMetrics.shift_start || (fetchedMetrics.shift_id === 1 ? shiftConfig?.nightShift?.startTime || "22:00" : shiftConfig?.dayShift?.startTime || "06:00"),
7899
+ shift_end: fetchedMetrics.shift_end || (fetchedMetrics.shift_id === 1 ? shiftConfig?.nightShift?.endTime || "06:00" : shiftConfig?.dayShift?.endTime || "14:00"),
7900
+ shift_type: fetchedMetrics.shift_type || (fetchedMetrics.shift_id === 0 ? "Day" : "Night"),
7901
+ pph_threshold: fetchedMetrics.pph_threshold || 0,
7902
+ // CRITICAL FIX: Map target_output properly - backend may return total_day_output instead
7903
+ target_output: fetchedMetrics.target_output || fetchedMetrics.total_day_output || 0,
7904
+ avg_pph: fetchedMetrics.avg_pph || 0,
7905
+ avg_cycle_time: fetchedMetrics.avg_cycle_time || 0,
7906
+ ideal_cycle_time: fetchedMetrics.ideal_cycle_time || 0,
7907
+ avg_efficiency: fetchedMetrics.avg_efficiency || fetchedMetrics.efficiency || 0,
7908
+ // CRITICAL FIX: Map total_actions properly - backend may return total_output instead
7909
+ total_actions: fetchedMetrics.total_actions || fetchedMetrics.total_output || 0,
7910
+ total_output: fetchedMetrics.total_output || 0,
7911
+ efficiency: fetchedMetrics.efficiency || fetchedMetrics.avg_efficiency || 0,
7912
+ hourly_action_counts: fetchedMetrics.hourly_action_counts || fetchedMetrics.output_hourly || [],
7913
+ workspace_rank: fetchedMetrics.workspace_rank || 0,
7914
+ total_workspaces: fetchedMetrics.total_workspaces || 42,
7915
+ ideal_output_until_now: fetchedMetrics.ideal_output || 0,
7916
+ output_difference: (fetchedMetrics.total_output || 0) - (fetchedMetrics.ideal_output || 0),
7917
+ idle_time: fetchedMetrics.idle_time || 0,
7918
+ idle_time_hourly: fetchedMetrics.idle_time_hourly || void 0,
7919
+ ...fetchedMetrics.compliance_efficiency !== void 0 && { compliance_efficiency: fetchedMetrics.compliance_efficiency },
7920
+ ...fetchedMetrics.sop_check !== void 0 && { sop_check: fetchedMetrics.sop_check },
7921
+ ...fetchedMetrics.performance_score !== void 0 && { performance_score: fetchedMetrics.performance_score }
7922
+ };
7923
+ if (shiftConfig) {
7884
7924
  const dynamicShiftName = getShiftNameById(
7885
- fetchedMetrics.shift_id,
7925
+ transformedMetrics.shift_id,
7886
7926
  timezone || "Asia/Kolkata",
7887
- // Fallback timezone
7888
- options.shiftConfig
7927
+ shiftConfig
7889
7928
  );
7890
- fetchedMetrics.shift_type = dynamicShiftName;
7891
- console.log(`[useHistoricWorkspaceMetrics] Overriding shift name for ID ${fetchedMetrics.shift_id}: ${dynamicShiftName}`);
7929
+ transformedMetrics.shift_type = dynamicShiftName;
7930
+ console.log(`[useHistoricWorkspaceMetrics] Overriding shift name for ID ${transformedMetrics.shift_id}: ${dynamicShiftName}`);
7892
7931
  }
7893
- setMetrics(fetchedMetrics || null);
7932
+ setMetrics(transformedMetrics);
7894
7933
  } catch (err) {
7895
7934
  console.error("[useHistoricWorkspaceMetrics] Error fetching historic metrics:", err);
7896
7935
  setError({ message: err.message, code: err.code || "FETCH_ERROR" });
@@ -47943,10 +47982,11 @@ var TargetsView = ({
47943
47982
  }
47944
47983
  let actionType = "assembly";
47945
47984
  let actionId = actionIdsData.assembly;
47946
- if (ws.action_id === packagingAction.id || ws.action_type === "packaging") {
47985
+ const effectiveActionId = threshold?.action_id ?? ws.action_id;
47986
+ if (effectiveActionId === packagingAction.id || !effectiveActionId && ws.action_type === "packaging") {
47947
47987
  actionType = "packaging";
47948
47988
  actionId = packagingAction.id;
47949
- } else if (ws.action_id === assemblyAction.id || ws.action_type === "assembly") {
47989
+ } else if (effectiveActionId === assemblyAction.id || !effectiveActionId && ws.action_type === "assembly") {
47950
47990
  actionType = "assembly";
47951
47991
  actionId = assemblyAction.id;
47952
47992
  }
@@ -48976,7 +49016,7 @@ var WorkspaceDetailView = ({
48976
49016
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-center space-y-8", children: [
48977
49017
  /* @__PURE__ */ jsxs("div", { className: "text-center space-y-1", children: [
48978
49018
  /* @__PURE__ */ jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
48979
- (workspace.total_actions / workspace.target_output * 100).toFixed(1),
49019
+ workspace.target_output > 0 ? (workspace.total_actions / workspace.target_output * 100).toFixed(1) : "0.0",
48980
49020
  "%"
48981
49021
  ] }),
48982
49022
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-2 text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-base font-medium", children: "of today's target" }) })
@@ -48995,7 +49035,7 @@ var WorkspaceDetailView = ({
48995
49035
  {
48996
49036
  initial: { width: 0 },
48997
49037
  animate: {
48998
- width: `${Math.min(100, workspace.total_actions / workspace.target_output * 100)}%`
49038
+ width: `${workspace.target_output > 0 ? Math.min(100, workspace.total_actions / workspace.target_output * 100) : 0}%`
48999
49039
  },
49000
49040
  transition: {
49001
49041
  duration: 1,
@@ -49095,7 +49135,7 @@ var WorkspaceDetailView = ({
49095
49135
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-[calc(100%-6rem)] justify-center space-y-8", children: [
49096
49136
  /* @__PURE__ */ jsxs("div", { className: "text-center space-y-1", children: [
49097
49137
  /* @__PURE__ */ jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
49098
- (workspace.total_actions / workspace.target_output * 100).toFixed(1),
49138
+ workspace.target_output > 0 ? (workspace.total_actions / workspace.target_output * 100).toFixed(1) : "0.0",
49099
49139
  "%"
49100
49140
  ] }),
49101
49141
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center gap-2 text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-base font-medium", children: "of today's target" }) })
@@ -49114,7 +49154,7 @@ var WorkspaceDetailView = ({
49114
49154
  {
49115
49155
  initial: { width: 0 },
49116
49156
  animate: {
49117
- width: `${Math.min(100, workspace.total_actions / workspace.target_output * 100)}%`
49157
+ width: `${workspace.target_output > 0 ? Math.min(100, workspace.total_actions / workspace.target_output * 100) : 0}%`
49118
49158
  },
49119
49159
  transition: {
49120
49160
  duration: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.9.15",
3
+ "version": "6.9.17",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",