@optifye/dashboard-core 6.10.26 → 6.10.27

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
@@ -39266,6 +39266,8 @@ var renderCustomizedLabel = ({ cx: cx2, cy, midAngle, innerRadius, outerRadius,
39266
39266
  }
39267
39267
  );
39268
39268
  };
39269
+ var EmptyState = ({ message }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center text-gray-400 text-sm", children: message || "No idle time data available" });
39270
+ var ErrorState = ({ error }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full flex items-center justify-center text-red-500 text-sm", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate px-2", children: error }) });
39269
39271
  var IdleTimeReasonChartComponent = ({
39270
39272
  data,
39271
39273
  isLoading = false,
@@ -39301,6 +39303,12 @@ var IdleTimeReasonChartComponent = ({
39301
39303
  if (isLoading) {
39302
39304
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full" });
39303
39305
  }
39306
+ if (error) {
39307
+ return /* @__PURE__ */ jsxRuntime.jsx(ErrorState, { error });
39308
+ }
39309
+ if (!data || data.length === 0) {
39310
+ return /* @__PURE__ */ jsxRuntime.jsx(EmptyState, { message: "No Idle Time reasons available" });
39311
+ }
39304
39312
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
39305
39313
  /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
39306
39314
  .recharts-wrapper:focus,
@@ -48377,7 +48385,7 @@ var UserUsageDetailModal = ({
48377
48385
  ] })
48378
48386
  ] })
48379
48387
  ] }),
48380
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-8 py-6", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingState2, {}) : error ? /* @__PURE__ */ jsxRuntime.jsx(ErrorState, { error }) : data ? /* @__PURE__ */ jsxRuntime.jsx(
48388
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-8 py-6", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx(LoadingState2, {}) : error ? /* @__PURE__ */ jsxRuntime.jsx(ErrorState2, { error }) : data ? /* @__PURE__ */ jsxRuntime.jsx(
48381
48389
  UsageContent,
48382
48390
  {
48383
48391
  data,
@@ -48386,21 +48394,21 @@ var UserUsageDetailModal = ({
48386
48394
  handlePrevWeek,
48387
48395
  handleNextWeek
48388
48396
  }
48389
- ) : /* @__PURE__ */ jsxRuntime.jsx(EmptyState, {}) })
48397
+ ) : /* @__PURE__ */ jsxRuntime.jsx(EmptyState2, {}) })
48390
48398
  ] }) })
48391
48399
  ] });
48392
48400
  };
48393
48401
  function LoadingState2() {
48394
48402
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center justify-center py-20", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading usage details..." }) });
48395
48403
  }
48396
- function ErrorState({ error }) {
48404
+ function ErrorState2({ error }) {
48397
48405
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-20", children: [
48398
48406
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-12 h-12 bg-red-50 rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Activity, { className: "w-6 h-6 text-red-500" }) }),
48399
48407
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-gray-900 font-medium mb-1", children: "Unable to load data" }),
48400
48408
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-red-500 text-sm", children: error })
48401
48409
  ] });
48402
48410
  }
48403
- function EmptyState() {
48411
+ function EmptyState2() {
48404
48412
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-20", children: [
48405
48413
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 bg-gray-50 rounded-2xl flex items-center justify-center mx-auto mb-4 transform rotate-12", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock, { className: "w-8 h-8 text-gray-400" }) }),
48406
48414
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-900 font-semibold text-lg", children: "No usage data" }),
@@ -51920,13 +51928,27 @@ var KPIDetailView = ({
51920
51928
  }
51921
51929
  return void 0;
51922
51930
  }, [urlShift]);
51931
+ const hasRouteDateShift = typeof window !== "undefined" ? (() => {
51932
+ const params = new URLSearchParams(window.location.search);
51933
+ return params.has("date") || params.has("shift");
51934
+ })() : false;
51935
+ const hasUrlDate = typeof urlDate === "string" && urlDate.length > 0;
51936
+ const hasUrlShift = urlShift !== void 0 && urlShift !== null;
51937
+ const historicalRouteRequested = hasUrlDate || hasUrlShift || hasRouteDateShift;
51938
+ const historicalParamsReady = !historicalRouteRequested || hasUrlDate && parsedShiftId !== void 0;
51923
51939
  const cachedSnapshot = React25.useMemo(() => {
51924
51940
  if (!lineId) return null;
51941
+ if (historicalRouteRequested) {
51942
+ if (!historicalParamsReady) {
51943
+ return null;
51944
+ }
51945
+ return lineDetailStore.getSnapshot(lineId, urlDate, parsedShiftId);
51946
+ }
51925
51947
  if (urlDate && parsedShiftId !== void 0) {
51926
51948
  return lineDetailStore.getSnapshot(lineId, urlDate, parsedShiftId);
51927
51949
  }
51928
51950
  return lineDetailStore.getLatest(lineId);
51929
- }, [lineId, urlDate, parsedShiftId]);
51951
+ }, [lineId, urlDate, parsedShiftId, historicalRouteRequested, historicalParamsReady]);
51930
51952
  const cachedLineInfo = cachedSnapshot?.lineInfo ?? null;
51931
51953
  const cachedWorkspaces = cachedSnapshot?.workspaces ?? null;
51932
51954
  const range = React25.useMemo(() => ({ startKey: rangeStart, endKey: rangeEnd }), [rangeStart, rangeEnd]);
@@ -51999,8 +52021,7 @@ var KPIDetailView = ({
51999
52021
  lineId,
52000
52022
  date: typeof urlDate === "string" ? urlDate : void 0,
52001
52023
  shiftId: parsedShiftId,
52002
- enabled: !isShiftConfigLoading
52003
- // Pass enabled flag to useRealtimeLineMetrics if supported, or we need to add it
52024
+ enabled: !isShiftConfigLoading && (!historicalRouteRequested || historicalParamsReady)
52004
52025
  });
52005
52026
  const {
52006
52027
  workspaces,
@@ -52010,12 +52031,11 @@ var KPIDetailView = ({
52010
52031
  } = useLineWorkspaceMetrics(lineId, {
52011
52032
  initialDate: typeof urlDate === "string" ? urlDate : void 0,
52012
52033
  initialShiftId: parsedShiftId,
52013
- enabled: !isShiftConfigLoading
52014
- // Pass enabled flag to useLineWorkspaceMetrics if supported, or we need to add it
52034
+ enabled: !isShiftConfigLoading && (!historicalRouteRequested || historicalParamsReady)
52015
52035
  });
52016
- const idleTimeDate = typeof urlDate === "string" ? urlDate : metrics2?.date || cachedLineInfo?.date;
52017
- const idleTimeShiftId = parsedShiftId ?? metrics2?.shift_id ?? cachedLineInfo?.shift_id;
52018
- const idleTimeEnabled = activeTab === "overview" && !!lineId && !!idleTimeDate && idleTimeShiftId !== void 0;
52036
+ const idleTimeDate = historicalRouteRequested ? historicalParamsReady ? urlDate : void 0 : typeof urlDate === "string" ? urlDate : metrics2?.date || cachedLineInfo?.date;
52037
+ const idleTimeShiftId = historicalRouteRequested ? historicalParamsReady ? parsedShiftId : void 0 : parsedShiftId ?? metrics2?.shift_id ?? cachedLineInfo?.shift_id;
52038
+ const idleTimeEnabled = activeTab === "overview" && !!lineId && !!idleTimeDate && idleTimeShiftId !== void 0 && (!historicalRouteRequested || historicalParamsReady);
52019
52039
  const {
52020
52040
  chartData: idleTimeChartData,
52021
52041
  isLoading: idleTimeLoading,
@@ -52149,11 +52169,36 @@ var KPIDetailView = ({
52149
52169
  }
52150
52170
  };
52151
52171
  }, [metrics2, lineDetails, companyId]);
52152
- const resolvedLineInfo = lineInfo || cachedLineInfo;
52153
- const resolvedWorkspaces = workspacesLoading && cachedWorkspaces ? cachedWorkspaces : workspaces;
52172
+ const lineInfoMatchesRequest = React25.useMemo(() => {
52173
+ if (!lineInfo) return false;
52174
+ if (!historicalRouteRequested) return true;
52175
+ if (!historicalParamsReady) return false;
52176
+ if (hasUrlDate && lineInfo.date !== urlDate) return false;
52177
+ if (parsedShiftId !== void 0 && lineInfo.shift_id !== parsedShiftId) return false;
52178
+ return true;
52179
+ }, [lineInfo, historicalRouteRequested, historicalParamsReady, hasUrlDate, urlDate, parsedShiftId]);
52180
+ const workspacesMatchRequest = React25.useMemo(() => {
52181
+ if (!historicalRouteRequested) return true;
52182
+ if (!historicalParamsReady) return false;
52183
+ if (!workspaces || workspaces.length === 0) return false;
52184
+ const sample = workspaces[0];
52185
+ if (hasUrlDate && sample.date !== urlDate) return false;
52186
+ if (parsedShiftId !== void 0 && sample.shift_id !== parsedShiftId) return false;
52187
+ return true;
52188
+ }, [workspaces, historicalRouteRequested, historicalParamsReady, hasUrlDate, urlDate, parsedShiftId]);
52189
+ const resolvedLineInfo = lineInfoMatchesRequest ? lineInfo : cachedLineInfo;
52190
+ const resolvedWorkspaces = historicalRouteRequested ? workspacesMatchRequest ? workspaces : cachedWorkspaces || [] : workspacesLoading && cachedWorkspaces ? cachedWorkspaces : workspaces;
52154
52191
  const hasLineSnapshot = Boolean(resolvedLineInfo);
52192
+ const metricsMatchRequest = React25.useMemo(() => {
52193
+ if (!metrics2) return false;
52194
+ if (!historicalRouteRequested) return true;
52195
+ if (!historicalParamsReady) return false;
52196
+ if (hasUrlDate && metrics2.date !== urlDate) return false;
52197
+ if (parsedShiftId !== void 0 && metrics2.shift_id !== parsedShiftId) return false;
52198
+ return true;
52199
+ }, [metrics2, historicalRouteRequested, historicalParamsReady, hasUrlDate, urlDate, parsedShiftId]);
52155
52200
  const chartMetrics = React25.useMemo(() => {
52156
- if (metrics2) {
52201
+ if (metricsMatchRequest && metrics2) {
52157
52202
  return metrics2;
52158
52203
  }
52159
52204
  if (!resolvedLineInfo) {
@@ -52164,7 +52209,9 @@ var KPIDetailView = ({
52164
52209
  shift_id: resolvedLineInfo.shift_id,
52165
52210
  date: resolvedLineInfo.date
52166
52211
  };
52167
- }, [metrics2, resolvedLineInfo]);
52212
+ }, [metrics2, metricsMatchRequest, resolvedLineInfo]);
52213
+ const isHistoricalAwaitingParams = historicalRouteRequested && !historicalParamsReady;
52214
+ const isHistoricalAwaitingData = historicalRouteRequested && historicalParamsReady && (lineMetricsLoading || workspacesLoading);
52168
52215
  React25.useEffect(() => {
52169
52216
  if (lineInfo) {
52170
52217
  trackCorePageView("KPI Detail View", {
@@ -52330,7 +52377,8 @@ var KPIDetailView = ({
52330
52377
  }, [resolvedWorkspaces]);
52331
52378
  React25.useEffect(() => {
52332
52379
  let timeoutId;
52333
- if (!lineMetricsLoading && !workspacesLoading && !resolvedLineInfo && activeTab !== "monthly_history") {
52380
+ const suppressNotFound = isHistoricalAwaitingParams || isHistoricalAwaitingData;
52381
+ if (!suppressNotFound && !lineMetricsLoading && !workspacesLoading && !resolvedLineInfo && activeTab !== "monthly_history") {
52334
52382
  timeoutId = setTimeout(() => {
52335
52383
  setShowLineDataNotFound(true);
52336
52384
  }, 2e3);
@@ -52342,7 +52390,7 @@ var KPIDetailView = ({
52342
52390
  clearTimeout(timeoutId);
52343
52391
  }
52344
52392
  };
52345
- }, [lineMetricsLoading, workspacesLoading, resolvedLineInfo, activeTab]);
52393
+ }, [lineMetricsLoading, workspacesLoading, resolvedLineInfo, activeTab, isHistoricalAwaitingParams, isHistoricalAwaitingData]);
52346
52394
  React25.useCallback(() => {
52347
52395
  trackCoreEvent("Quality Overview Viewed", {
52348
52396
  source: "line_kpi",
@@ -52438,6 +52486,9 @@ var KPIDetailView = ({
52438
52486
  setRangeEnd(nextRange.endKey);
52439
52487
  handleNavigate(buildMonthlyHistoryUrl(currentMonth, currentYear, nextRange), { shallow: true });
52440
52488
  }, [currentMonth, currentYear, handleNavigate, buildMonthlyHistoryUrl]);
52489
+ if (isHistoricalAwaitingParams || isHistoricalAwaitingData) {
52490
+ return /* @__PURE__ */ jsxRuntime.jsx(LoadingPage, { message: "Loading historical line metrics..." });
52491
+ }
52441
52492
  if ((lineMetricsLoading || workspacesLoading || isShiftConfigLoading) && !hasLineSnapshot && !metrics2) {
52442
52493
  return /* @__PURE__ */ jsxRuntime.jsx(LoadingPage, { message: "Loading line metrics..." });
52443
52494
  }
package/dist/index.mjs CHANGED
@@ -39237,6 +39237,8 @@ var renderCustomizedLabel = ({ cx: cx2, cy, midAngle, innerRadius, outerRadius,
39237
39237
  }
39238
39238
  );
39239
39239
  };
39240
+ var EmptyState = ({ message }) => /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-gray-400 text-sm", children: message || "No idle time data available" });
39241
+ var ErrorState = ({ error }) => /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-red-500 text-sm", children: /* @__PURE__ */ jsx("span", { className: "truncate px-2", children: error }) });
39240
39242
  var IdleTimeReasonChartComponent = ({
39241
39243
  data,
39242
39244
  isLoading = false,
@@ -39272,6 +39274,12 @@ var IdleTimeReasonChartComponent = ({
39272
39274
  if (isLoading) {
39273
39275
  return /* @__PURE__ */ jsx("div", { className: "w-full h-full" });
39274
39276
  }
39277
+ if (error) {
39278
+ return /* @__PURE__ */ jsx(ErrorState, { error });
39279
+ }
39280
+ if (!data || data.length === 0) {
39281
+ return /* @__PURE__ */ jsx(EmptyState, { message: "No Idle Time reasons available" });
39282
+ }
39275
39283
  return /* @__PURE__ */ jsxs(Fragment, { children: [
39276
39284
  /* @__PURE__ */ jsx("style", { children: `
39277
39285
  .recharts-wrapper:focus,
@@ -48348,7 +48356,7 @@ var UserUsageDetailModal = ({
48348
48356
  ] })
48349
48357
  ] })
48350
48358
  ] }),
48351
- /* @__PURE__ */ jsx("div", { className: "px-8 py-6", children: isLoading ? /* @__PURE__ */ jsx(LoadingState2, {}) : error ? /* @__PURE__ */ jsx(ErrorState, { error }) : data ? /* @__PURE__ */ jsx(
48359
+ /* @__PURE__ */ jsx("div", { className: "px-8 py-6", children: isLoading ? /* @__PURE__ */ jsx(LoadingState2, {}) : error ? /* @__PURE__ */ jsx(ErrorState2, { error }) : data ? /* @__PURE__ */ jsx(
48352
48360
  UsageContent,
48353
48361
  {
48354
48362
  data,
@@ -48357,21 +48365,21 @@ var UserUsageDetailModal = ({
48357
48365
  handlePrevWeek,
48358
48366
  handleNextWeek
48359
48367
  }
48360
- ) : /* @__PURE__ */ jsx(EmptyState, {}) })
48368
+ ) : /* @__PURE__ */ jsx(EmptyState2, {}) })
48361
48369
  ] }) })
48362
48370
  ] });
48363
48371
  };
48364
48372
  function LoadingState2() {
48365
48373
  return /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center py-20", children: /* @__PURE__ */ jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading usage details..." }) });
48366
48374
  }
48367
- function ErrorState({ error }) {
48375
+ function ErrorState2({ error }) {
48368
48376
  return /* @__PURE__ */ jsxs("div", { className: "text-center py-20", children: [
48369
48377
  /* @__PURE__ */ jsx("div", { className: "w-12 h-12 bg-red-50 rounded-full flex items-center justify-center mx-auto mb-4", children: /* @__PURE__ */ jsx(Activity, { className: "w-6 h-6 text-red-500" }) }),
48370
48378
  /* @__PURE__ */ jsx("h3", { className: "text-gray-900 font-medium mb-1", children: "Unable to load data" }),
48371
48379
  /* @__PURE__ */ jsx("p", { className: "text-red-500 text-sm", children: error })
48372
48380
  ] });
48373
48381
  }
48374
- function EmptyState() {
48382
+ function EmptyState2() {
48375
48383
  return /* @__PURE__ */ jsxs("div", { className: "text-center py-20", children: [
48376
48384
  /* @__PURE__ */ jsx("div", { className: "w-16 h-16 bg-gray-50 rounded-2xl flex items-center justify-center mx-auto mb-4 transform rotate-12", children: /* @__PURE__ */ jsx(Clock, { className: "w-8 h-8 text-gray-400" }) }),
48377
48385
  /* @__PURE__ */ jsx("p", { className: "text-gray-900 font-semibold text-lg", children: "No usage data" }),
@@ -51891,13 +51899,27 @@ var KPIDetailView = ({
51891
51899
  }
51892
51900
  return void 0;
51893
51901
  }, [urlShift]);
51902
+ const hasRouteDateShift = typeof window !== "undefined" ? (() => {
51903
+ const params = new URLSearchParams(window.location.search);
51904
+ return params.has("date") || params.has("shift");
51905
+ })() : false;
51906
+ const hasUrlDate = typeof urlDate === "string" && urlDate.length > 0;
51907
+ const hasUrlShift = urlShift !== void 0 && urlShift !== null;
51908
+ const historicalRouteRequested = hasUrlDate || hasUrlShift || hasRouteDateShift;
51909
+ const historicalParamsReady = !historicalRouteRequested || hasUrlDate && parsedShiftId !== void 0;
51894
51910
  const cachedSnapshot = useMemo(() => {
51895
51911
  if (!lineId) return null;
51912
+ if (historicalRouteRequested) {
51913
+ if (!historicalParamsReady) {
51914
+ return null;
51915
+ }
51916
+ return lineDetailStore.getSnapshot(lineId, urlDate, parsedShiftId);
51917
+ }
51896
51918
  if (urlDate && parsedShiftId !== void 0) {
51897
51919
  return lineDetailStore.getSnapshot(lineId, urlDate, parsedShiftId);
51898
51920
  }
51899
51921
  return lineDetailStore.getLatest(lineId);
51900
- }, [lineId, urlDate, parsedShiftId]);
51922
+ }, [lineId, urlDate, parsedShiftId, historicalRouteRequested, historicalParamsReady]);
51901
51923
  const cachedLineInfo = cachedSnapshot?.lineInfo ?? null;
51902
51924
  const cachedWorkspaces = cachedSnapshot?.workspaces ?? null;
51903
51925
  const range = useMemo(() => ({ startKey: rangeStart, endKey: rangeEnd }), [rangeStart, rangeEnd]);
@@ -51970,8 +51992,7 @@ var KPIDetailView = ({
51970
51992
  lineId,
51971
51993
  date: typeof urlDate === "string" ? urlDate : void 0,
51972
51994
  shiftId: parsedShiftId,
51973
- enabled: !isShiftConfigLoading
51974
- // Pass enabled flag to useRealtimeLineMetrics if supported, or we need to add it
51995
+ enabled: !isShiftConfigLoading && (!historicalRouteRequested || historicalParamsReady)
51975
51996
  });
51976
51997
  const {
51977
51998
  workspaces,
@@ -51981,12 +52002,11 @@ var KPIDetailView = ({
51981
52002
  } = useLineWorkspaceMetrics(lineId, {
51982
52003
  initialDate: typeof urlDate === "string" ? urlDate : void 0,
51983
52004
  initialShiftId: parsedShiftId,
51984
- enabled: !isShiftConfigLoading
51985
- // Pass enabled flag to useLineWorkspaceMetrics if supported, or we need to add it
52005
+ enabled: !isShiftConfigLoading && (!historicalRouteRequested || historicalParamsReady)
51986
52006
  });
51987
- const idleTimeDate = typeof urlDate === "string" ? urlDate : metrics2?.date || cachedLineInfo?.date;
51988
- const idleTimeShiftId = parsedShiftId ?? metrics2?.shift_id ?? cachedLineInfo?.shift_id;
51989
- const idleTimeEnabled = activeTab === "overview" && !!lineId && !!idleTimeDate && idleTimeShiftId !== void 0;
52007
+ const idleTimeDate = historicalRouteRequested ? historicalParamsReady ? urlDate : void 0 : typeof urlDate === "string" ? urlDate : metrics2?.date || cachedLineInfo?.date;
52008
+ const idleTimeShiftId = historicalRouteRequested ? historicalParamsReady ? parsedShiftId : void 0 : parsedShiftId ?? metrics2?.shift_id ?? cachedLineInfo?.shift_id;
52009
+ const idleTimeEnabled = activeTab === "overview" && !!lineId && !!idleTimeDate && idleTimeShiftId !== void 0 && (!historicalRouteRequested || historicalParamsReady);
51990
52010
  const {
51991
52011
  chartData: idleTimeChartData,
51992
52012
  isLoading: idleTimeLoading,
@@ -52120,11 +52140,36 @@ var KPIDetailView = ({
52120
52140
  }
52121
52141
  };
52122
52142
  }, [metrics2, lineDetails, companyId]);
52123
- const resolvedLineInfo = lineInfo || cachedLineInfo;
52124
- const resolvedWorkspaces = workspacesLoading && cachedWorkspaces ? cachedWorkspaces : workspaces;
52143
+ const lineInfoMatchesRequest = useMemo(() => {
52144
+ if (!lineInfo) return false;
52145
+ if (!historicalRouteRequested) return true;
52146
+ if (!historicalParamsReady) return false;
52147
+ if (hasUrlDate && lineInfo.date !== urlDate) return false;
52148
+ if (parsedShiftId !== void 0 && lineInfo.shift_id !== parsedShiftId) return false;
52149
+ return true;
52150
+ }, [lineInfo, historicalRouteRequested, historicalParamsReady, hasUrlDate, urlDate, parsedShiftId]);
52151
+ const workspacesMatchRequest = useMemo(() => {
52152
+ if (!historicalRouteRequested) return true;
52153
+ if (!historicalParamsReady) return false;
52154
+ if (!workspaces || workspaces.length === 0) return false;
52155
+ const sample = workspaces[0];
52156
+ if (hasUrlDate && sample.date !== urlDate) return false;
52157
+ if (parsedShiftId !== void 0 && sample.shift_id !== parsedShiftId) return false;
52158
+ return true;
52159
+ }, [workspaces, historicalRouteRequested, historicalParamsReady, hasUrlDate, urlDate, parsedShiftId]);
52160
+ const resolvedLineInfo = lineInfoMatchesRequest ? lineInfo : cachedLineInfo;
52161
+ const resolvedWorkspaces = historicalRouteRequested ? workspacesMatchRequest ? workspaces : cachedWorkspaces || [] : workspacesLoading && cachedWorkspaces ? cachedWorkspaces : workspaces;
52125
52162
  const hasLineSnapshot = Boolean(resolvedLineInfo);
52163
+ const metricsMatchRequest = useMemo(() => {
52164
+ if (!metrics2) return false;
52165
+ if (!historicalRouteRequested) return true;
52166
+ if (!historicalParamsReady) return false;
52167
+ if (hasUrlDate && metrics2.date !== urlDate) return false;
52168
+ if (parsedShiftId !== void 0 && metrics2.shift_id !== parsedShiftId) return false;
52169
+ return true;
52170
+ }, [metrics2, historicalRouteRequested, historicalParamsReady, hasUrlDate, urlDate, parsedShiftId]);
52126
52171
  const chartMetrics = useMemo(() => {
52127
- if (metrics2) {
52172
+ if (metricsMatchRequest && metrics2) {
52128
52173
  return metrics2;
52129
52174
  }
52130
52175
  if (!resolvedLineInfo) {
@@ -52135,7 +52180,9 @@ var KPIDetailView = ({
52135
52180
  shift_id: resolvedLineInfo.shift_id,
52136
52181
  date: resolvedLineInfo.date
52137
52182
  };
52138
- }, [metrics2, resolvedLineInfo]);
52183
+ }, [metrics2, metricsMatchRequest, resolvedLineInfo]);
52184
+ const isHistoricalAwaitingParams = historicalRouteRequested && !historicalParamsReady;
52185
+ const isHistoricalAwaitingData = historicalRouteRequested && historicalParamsReady && (lineMetricsLoading || workspacesLoading);
52139
52186
  useEffect(() => {
52140
52187
  if (lineInfo) {
52141
52188
  trackCorePageView("KPI Detail View", {
@@ -52301,7 +52348,8 @@ var KPIDetailView = ({
52301
52348
  }, [resolvedWorkspaces]);
52302
52349
  useEffect(() => {
52303
52350
  let timeoutId;
52304
- if (!lineMetricsLoading && !workspacesLoading && !resolvedLineInfo && activeTab !== "monthly_history") {
52351
+ const suppressNotFound = isHistoricalAwaitingParams || isHistoricalAwaitingData;
52352
+ if (!suppressNotFound && !lineMetricsLoading && !workspacesLoading && !resolvedLineInfo && activeTab !== "monthly_history") {
52305
52353
  timeoutId = setTimeout(() => {
52306
52354
  setShowLineDataNotFound(true);
52307
52355
  }, 2e3);
@@ -52313,7 +52361,7 @@ var KPIDetailView = ({
52313
52361
  clearTimeout(timeoutId);
52314
52362
  }
52315
52363
  };
52316
- }, [lineMetricsLoading, workspacesLoading, resolvedLineInfo, activeTab]);
52364
+ }, [lineMetricsLoading, workspacesLoading, resolvedLineInfo, activeTab, isHistoricalAwaitingParams, isHistoricalAwaitingData]);
52317
52365
  useCallback(() => {
52318
52366
  trackCoreEvent("Quality Overview Viewed", {
52319
52367
  source: "line_kpi",
@@ -52409,6 +52457,9 @@ var KPIDetailView = ({
52409
52457
  setRangeEnd(nextRange.endKey);
52410
52458
  handleNavigate(buildMonthlyHistoryUrl(currentMonth, currentYear, nextRange), { shallow: true });
52411
52459
  }, [currentMonth, currentYear, handleNavigate, buildMonthlyHistoryUrl]);
52460
+ if (isHistoricalAwaitingParams || isHistoricalAwaitingData) {
52461
+ return /* @__PURE__ */ jsx(LoadingPage, { message: "Loading historical line metrics..." });
52462
+ }
52412
52463
  if ((lineMetricsLoading || workspacesLoading || isShiftConfigLoading) && !hasLineSnapshot && !metrics2) {
52413
52464
  return /* @__PURE__ */ jsx(LoadingPage, { message: "Loading line metrics..." });
52414
52465
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.10.26",
3
+ "version": "6.10.27",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",