@optifye/dashboard-core 6.9.16 → 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" });
@@ -49006,7 +49045,7 @@ var WorkspaceDetailView = ({
49006
49045
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col justify-center space-y-8", children: [
49007
49046
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center space-y-1", children: [
49008
49047
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
49009
- (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",
49010
49049
  "%"
49011
49050
  ] }),
49012
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" }) })
@@ -49025,7 +49064,7 @@ var WorkspaceDetailView = ({
49025
49064
  {
49026
49065
  initial: { width: 0 },
49027
49066
  animate: {
49028
- 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}%`
49029
49068
  },
49030
49069
  transition: {
49031
49070
  duration: 1,
@@ -49125,7 +49164,7 @@ var WorkspaceDetailView = ({
49125
49164
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-[calc(100%-6rem)] justify-center space-y-8", children: [
49126
49165
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center space-y-1", children: [
49127
49166
  /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
49128
- (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",
49129
49168
  "%"
49130
49169
  ] }),
49131
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" }) })
@@ -49144,7 +49183,7 @@ var WorkspaceDetailView = ({
49144
49183
  {
49145
49184
  initial: { width: 0 },
49146
49185
  animate: {
49147
- 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}%`
49148
49187
  },
49149
49188
  transition: {
49150
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" });
@@ -48977,7 +49016,7 @@ var WorkspaceDetailView = ({
48977
49016
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col justify-center space-y-8", children: [
48978
49017
  /* @__PURE__ */ jsxs("div", { className: "text-center space-y-1", children: [
48979
49018
  /* @__PURE__ */ jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
48980
- (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",
48981
49020
  "%"
48982
49021
  ] }),
48983
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" }) })
@@ -48996,7 +49035,7 @@ var WorkspaceDetailView = ({
48996
49035
  {
48997
49036
  initial: { width: 0 },
48998
49037
  animate: {
48999
- 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}%`
49000
49039
  },
49001
49040
  transition: {
49002
49041
  duration: 1,
@@ -49096,7 +49135,7 @@ var WorkspaceDetailView = ({
49096
49135
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-[calc(100%-6rem)] justify-center space-y-8", children: [
49097
49136
  /* @__PURE__ */ jsxs("div", { className: "text-center space-y-1", children: [
49098
49137
  /* @__PURE__ */ jsxs("p", { className: "text-7xl font-bold tracking-tight", children: [
49099
- (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",
49100
49139
  "%"
49101
49140
  ] }),
49102
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" }) })
@@ -49115,7 +49154,7 @@ var WorkspaceDetailView = ({
49115
49154
  {
49116
49155
  initial: { width: 0 },
49117
49156
  animate: {
49118
- 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}%`
49119
49158
  },
49120
49159
  transition: {
49121
49160
  duration: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.9.16",
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",