@optifye/dashboard-core 6.11.40 → 6.11.41

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.d.mts CHANGED
@@ -7799,6 +7799,7 @@ interface LineShiftData {
7799
7799
  }
7800
7800
  interface LineDayData$2 {
7801
7801
  date: Date | string;
7802
+ dateKey?: string;
7802
7803
  /** Shift data keyed by shift_id (0, 1, 2, ...) - multi-shift support */
7803
7804
  shifts: Record<number, LineShiftData>;
7804
7805
  }
@@ -7853,6 +7854,7 @@ interface WorkspacePerformance$1 {
7853
7854
  /** Line monthly data with multi-shift support */
7854
7855
  interface LineDayData$1 {
7855
7856
  date: Date;
7857
+ dateKey?: string;
7856
7858
  /** Shift data keyed by shift_id (0, 1, 2, ...) */
7857
7859
  shifts: Record<number, PerformanceData$1>;
7858
7860
  }
@@ -7924,6 +7926,7 @@ interface WorkspacePerformance {
7924
7926
  /** Line day data with multi-shift support */
7925
7927
  interface LineDayData {
7926
7928
  date: Date;
7929
+ dateKey?: string;
7927
7930
  /** Shift data keyed by shift_id (0, 1, 2, ...) */
7928
7931
  shifts: Record<number, PerformanceData>;
7929
7932
  }
package/dist/index.d.ts CHANGED
@@ -7799,6 +7799,7 @@ interface LineShiftData {
7799
7799
  }
7800
7800
  interface LineDayData$2 {
7801
7801
  date: Date | string;
7802
+ dateKey?: string;
7802
7803
  /** Shift data keyed by shift_id (0, 1, 2, ...) - multi-shift support */
7803
7804
  shifts: Record<number, LineShiftData>;
7804
7805
  }
@@ -7853,6 +7854,7 @@ interface WorkspacePerformance$1 {
7853
7854
  /** Line monthly data with multi-shift support */
7854
7855
  interface LineDayData$1 {
7855
7856
  date: Date;
7857
+ dateKey?: string;
7856
7858
  /** Shift data keyed by shift_id (0, 1, 2, ...) */
7857
7859
  shifts: Record<number, PerformanceData$1>;
7858
7860
  }
@@ -7924,6 +7926,7 @@ interface WorkspacePerformance {
7924
7926
  /** Line day data with multi-shift support */
7925
7927
  interface LineDayData {
7926
7928
  date: Date;
7929
+ dateKey?: string;
7927
7930
  /** Shift data keyed by shift_id (0, 1, 2, ...) */
7928
7931
  shifts: Record<number, PerformanceData>;
7929
7932
  }
package/dist/index.js CHANGED
@@ -46575,6 +46575,7 @@ var getLineShiftData = (day, shiftId) => {
46575
46575
  }
46576
46576
  return { ...DEFAULT_LINE_SHIFT_DATA };
46577
46577
  };
46578
+ var getLineDayDateKey = (day) => day.dateKey || getDateKeyFromValue(day.date);
46578
46579
  var WEEKDAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
46579
46580
  var LineHistoryCalendar = ({
46580
46581
  data,
@@ -46609,20 +46610,16 @@ var LineHistoryCalendar = ({
46609
46610
  for (let day = 1; day <= totalDays; day++) {
46610
46611
  const currentDate = dateFnsTz.toZonedTime(new Date(year, month, day), configuredTimezone);
46611
46612
  const currentDateString = `${currentDate.getFullYear()}-${String(currentDate.getMonth() + 1).padStart(2, "0")}-${String(currentDate.getDate()).padStart(2, "0")}`;
46612
- const existingData = data.find((d) => {
46613
- if (!d.date) return false;
46614
- const dDate = typeof d.date === "string" ? new Date(d.date) : d.date;
46615
- const dDateIST = dateFnsTz.toZonedTime(dDate, configuredTimezone);
46616
- const dDateString = `${dDateIST.getFullYear()}-${String(dDateIST.getMonth() + 1).padStart(2, "0")}-${String(dDateIST.getDate()).padStart(2, "0")}`;
46617
- return dDateString === currentDateString;
46618
- });
46613
+ const existingData = data.find((d) => d && getLineDayDateKey(d) === currentDateString);
46619
46614
  if (existingData) {
46620
46615
  calendar.push({
46621
46616
  ...existingData,
46617
+ dateKey: getLineDayDateKey(existingData),
46622
46618
  date: currentDate
46623
46619
  });
46624
46620
  } else {
46625
46621
  calendar.push({
46622
+ dateKey: currentDateString,
46626
46623
  date: currentDate,
46627
46624
  shifts: {}
46628
46625
  });
@@ -46694,7 +46691,7 @@ var LineHistoryCalendar = ({
46694
46691
  const isFuture = isFutureDate(day.date instanceof Date ? day.date : new Date(day.date));
46695
46692
  const hasData = hasRealData(shiftData);
46696
46693
  const dateObj = day.date instanceof Date ? day.date : new Date(day.date);
46697
- const dateKey = `${dateObj.getFullYear()}-${String(dateObj.getMonth() + 1).padStart(2, "0")}-${String(dateObj.getDate()).padStart(2, "0")}`;
46694
+ const dateKey = getLineDayDateKey(day);
46698
46695
  const showRange = rangeStart && rangeEnd ? !(rangeStart === monthBounds.startKey && rangeEnd === monthBounds.endKey) : false;
46699
46696
  const inRange = showRange ? dateKey >= rangeStart && dateKey <= rangeEnd : false;
46700
46697
  const isRangeEdge = inRange && (dateKey === rangeStart || dateKey === rangeEnd);
@@ -46705,11 +46702,7 @@ var LineHistoryCalendar = ({
46705
46702
  className: `group h-full ${isFuture || !hasData || isFilteredOut ? "cursor-not-allowed" : "cursor-pointer hover:opacity-90"}`,
46706
46703
  onClick: () => {
46707
46704
  if (!isFuture && hasData && !isFilteredOut) {
46708
- const dateObj2 = day.date instanceof Date ? day.date : new Date(day.date);
46709
- const year2 = dateObj2.getFullYear();
46710
- const month2 = String(dateObj2.getMonth() + 1).padStart(2, "0");
46711
- const dayOfMonth = String(dateObj2.getDate()).padStart(2, "0");
46712
- const date = `${year2}-${month2}-${dayOfMonth}`;
46705
+ const date = getLineDayDateKey(day);
46713
46706
  trackCoreEvent("Line Monthly History Day Clicked", {
46714
46707
  source: "line_kpi",
46715
46708
  line_id: lineId,
@@ -46721,8 +46714,8 @@ var LineHistoryCalendar = ({
46721
46714
  });
46722
46715
  const params = new URLSearchParams();
46723
46716
  params.set("tab", "monthly_history");
46724
- params.set("month", month2.toString());
46725
- params.set("year", year2.toString());
46717
+ params.set("month", month.toString());
46718
+ params.set("year", year.toString());
46726
46719
  if (rangeStart && rangeEnd && !(rangeStart === monthBounds.startKey && rangeEnd === monthBounds.endKey)) {
46727
46720
  params.set("rangeStart", rangeStart);
46728
46721
  params.set("rangeEnd", rangeEnd);
@@ -47191,6 +47184,7 @@ var getShiftData2 = (day, shiftId) => {
47191
47184
  }
47192
47185
  return { ...DEFAULT_PERFORMANCE_DATA };
47193
47186
  };
47187
+ var getLineDayDateKey2 = (day) => day.dateKey || getDateKeyFromValue(day.date);
47194
47188
  var getUptimeTotals = (shift, hasShiftData) => {
47195
47189
  if (!shift) {
47196
47190
  return { availableSeconds: 0, productiveSeconds: 0, idleSeconds: 0 };
@@ -47248,6 +47242,10 @@ var LineMonthlyHistory = ({
47248
47242
  }
47249
47243
  return filterDataByDateKeyRange(monthlyData, normalizedRange);
47250
47244
  }, [analysisData, monthlyData, normalizedRange]);
47245
+ const analysisMonthlyDataByKey = React143.useMemo(
47246
+ () => new Map((analysisMonthlyData || []).map((day) => [getLineDayDateKey2(day), day])),
47247
+ [analysisMonthlyData]
47248
+ );
47251
47249
  const startDate = normalizedRange.startKey;
47252
47250
  const endDate = normalizedRange.endKey;
47253
47251
  const {
@@ -47354,9 +47352,9 @@ var LineMonthlyHistory = ({
47354
47352
  const chartData = React143.useMemo(() => {
47355
47353
  const rangeStartDate = parseDateKeyToDate(normalizedRange.startKey);
47356
47354
  const rangeEndDate = parseDateKeyToDate(normalizedRange.endKey);
47357
- const dayNumbers = [];
47355
+ const rangeDateKeys = [];
47358
47356
  for (let d = new Date(rangeStartDate); d <= rangeEndDate; d.setDate(d.getDate() + 1)) {
47359
- dayNumbers.push(d.getDate());
47357
+ rangeDateKeys.push(buildDateKey(d.getFullYear(), d.getMonth(), d.getDate()));
47360
47358
  }
47361
47359
  if (isUptimeMode) {
47362
47360
  const dailyData2 = [];
@@ -47364,13 +47362,10 @@ var LineMonthlyHistory = ({
47364
47362
  const todayInZone = getCurrentTimeInZone(timezone);
47365
47363
  const todayDate = typeof todayInZone === "string" ? new Date(todayInZone) : todayInZone;
47366
47364
  const todayKey = `${todayDate.getFullYear()}-${String(todayDate.getMonth() + 1).padStart(2, "0")}-${String(todayDate.getDate()).padStart(2, "0")}`;
47367
- for (const day of dayNumbers) {
47368
- const dayKey = `${rangeStartDate.getFullYear()}-${String(rangeStartDate.getMonth() + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
47365
+ for (const dayKey of rangeDateKeys) {
47366
+ const day = Number(dayKey.slice(-2));
47369
47367
  const isFutureDay = dayKey > todayKey;
47370
- const dayData = analysisMonthlyData.find((d) => {
47371
- const date = new Date(d.date);
47372
- return date.getDate() === day;
47373
- });
47368
+ const dayData = analysisMonthlyDataByKey.get(dayKey);
47374
47369
  const shiftData = dayData ? getShiftData2(dayData, selectedShiftId) : null;
47375
47370
  const hasShiftData = Boolean(shiftData && hasRealData(shiftData));
47376
47371
  const efficiencyValue = hasShiftData && Number.isFinite(shiftData?.avg_efficiency) ? Number(shiftData?.avg_efficiency) : 0;
@@ -47392,12 +47387,9 @@ var LineMonthlyHistory = ({
47392
47387
  const dailyData = [];
47393
47388
  let maxOutput = 0;
47394
47389
  let lastSetTarget = 0;
47395
- for (let i = dayNumbers.length - 1; i >= 0; i--) {
47396
- const day = dayNumbers[i];
47397
- const dayData = analysisMonthlyData.find((d) => {
47398
- const date = new Date(d.date);
47399
- return date.getDate() === day;
47400
- });
47390
+ for (let i = rangeDateKeys.length - 1; i >= 0; i--) {
47391
+ const dayKey = rangeDateKeys[i];
47392
+ const dayData = analysisMonthlyDataByKey.get(dayKey);
47401
47393
  const shiftData = dayData ? getShiftData2(dayData, selectedShiftId) : null;
47402
47394
  const idealOutput = shiftData ? shiftData.idealOutput || 0 : 0;
47403
47395
  if (idealOutput > 0) {
@@ -47405,11 +47397,9 @@ var LineMonthlyHistory = ({
47405
47397
  break;
47406
47398
  }
47407
47399
  }
47408
- for (const day of dayNumbers) {
47409
- const dayData = analysisMonthlyData.find((d) => {
47410
- const date = new Date(d.date);
47411
- return date.getDate() === day;
47412
- });
47400
+ for (const dayKey of rangeDateKeys) {
47401
+ const day = Number(dayKey.slice(-2));
47402
+ const dayData = analysisMonthlyDataByKey.get(dayKey);
47413
47403
  const shiftData = dayData ? getShiftData2(dayData, selectedShiftId) : null;
47414
47404
  const output = shiftData && hasRealData(shiftData) ? shiftData.output || 0 : 0;
47415
47405
  const idealOutput = shiftData ? shiftData.idealOutput || 0 : 0;
@@ -47429,7 +47419,7 @@ var LineMonthlyHistory = ({
47429
47419
  const calculatedMax = Math.max(maxOutput, lastSetTarget);
47430
47420
  const yAxisMax = calculatedMax > 0 ? calculatedMax * 1.1 : 100;
47431
47421
  return { data: dailyData, maxOutput, lastSetTarget, yAxisMax };
47432
- }, [analysisMonthlyData, normalizedRange.startKey, normalizedRange.endKey, selectedShiftId, isUptimeMode, timezone]);
47422
+ }, [analysisMonthlyDataByKey, normalizedRange.endKey, normalizedRange.startKey, selectedShiftId, isUptimeMode, timezone]);
47433
47423
  const yAxisTicks = React143.useMemo(() => {
47434
47424
  const max = chartData.yAxisMax;
47435
47425
  const target = chartData.lastSetTarget;
@@ -47917,6 +47907,7 @@ var getShiftDisplayName = (shiftId, availableShifts) => {
47917
47907
  if (shiftId === 1) return "Night Shift";
47918
47908
  return `Shift ${shiftId}`;
47919
47909
  };
47910
+ var getLineDayDateKey3 = (day) => day.dateKey || getDateKeyFromValue(day.date);
47920
47911
  var LineMonthlyPdfGenerator = ({
47921
47912
  lineId,
47922
47913
  lineName,
@@ -47946,13 +47937,20 @@ var LineMonthlyPdfGenerator = ({
47946
47937
  startKey: rangeStart || monthBounds.startKey,
47947
47938
  endKey: rangeEnd || monthBounds.endKey
47948
47939
  };
47940
+ const boundsSourceKey = rangeStart || rangeEnd || monthBounds.startKey;
47941
+ const boundsSourceDate = parseDateKeyToDate(boundsSourceKey);
47942
+ const effectiveBounds = getMonthKeyBounds(boundsSourceDate.getFullYear(), boundsSourceDate.getMonth());
47949
47943
  const normalizedRange = normalizeDateKeyRange(
47950
47944
  requestedRange.startKey,
47951
47945
  requestedRange.endKey,
47952
- monthBounds.startKey,
47953
- monthBounds.endKey
47946
+ effectiveBounds.startKey,
47947
+ effectiveBounds.endKey
47948
+ );
47949
+ const fullRange = isFullMonthRange(
47950
+ normalizedRange,
47951
+ boundsSourceDate.getFullYear(),
47952
+ boundsSourceDate.getMonth()
47954
47953
  );
47955
- const fullRange = isFullMonthRange(normalizedRange, selectedYear, selectedMonth);
47956
47954
  const reportStartDate = parseDateKeyToDate(normalizedRange.startKey);
47957
47955
  const reportEndDate = parseDateKeyToDate(normalizedRange.endKey);
47958
47956
  const reportStartStr = reportStartDate.toLocaleDateString("en-IN", {
@@ -47970,8 +47968,8 @@ var LineMonthlyPdfGenerator = ({
47970
47968
  trackCoreEvent("Line Monthly PDF Export Clicked", {
47971
47969
  line_id: lineId,
47972
47970
  line_name: lineName,
47973
- month: selectedMonth,
47974
- year: selectedYear,
47971
+ month: reportStartDate.getMonth(),
47972
+ year: reportStartDate.getFullYear(),
47975
47973
  shift_id: selectedShiftId,
47976
47974
  range_start: normalizedRange.startKey,
47977
47975
  range_end: normalizedRange.endKey,
@@ -47983,6 +47981,11 @@ var LineMonthlyPdfGenerator = ({
47983
47981
  const maxContentY = footerY - 10;
47984
47982
  const generatedText = `Generated on ${(/* @__PURE__ */ new Date()).toLocaleString("en-IN", { timeZone: "Asia/Kolkata" })}`;
47985
47983
  const dailySectionTitle = isUptimeMode ? "Daily Utilization Summary" : "Daily Performance Summary";
47984
+ const monthName = reportStartDate.toLocaleDateString("en-IN", {
47985
+ month: "long",
47986
+ year: "numeric",
47987
+ timeZone: "Asia/Kolkata"
47988
+ });
47986
47989
  const drawPageChrome = () => {
47987
47990
  doc.setFontSize(14);
47988
47991
  doc.setFont("helvetica", "bold");
@@ -48014,11 +48017,6 @@ var LineMonthlyPdfGenerator = ({
48014
48017
  doc.setFontSize(13);
48015
48018
  doc.setFont("helvetica", "normal");
48016
48019
  doc.setTextColor(60, 60, 60);
48017
- const monthName = new Date(selectedYear, selectedMonth).toLocaleDateString("en-IN", {
48018
- month: "long",
48019
- year: "numeric",
48020
- timeZone: "Asia/Kolkata"
48021
- });
48022
48020
  const shiftType = getShiftDisplayName(selectedShiftId, availableShifts);
48023
48021
  doc.text(`${monthName}`, 20, 55);
48024
48022
  doc.text(`${shiftType}`, 20, 63);
@@ -48031,10 +48029,7 @@ var LineMonthlyPdfGenerator = ({
48031
48029
  const mainSeparatorY = isUptimeMode ? 90 : 85;
48032
48030
  doc.line(20, mainSeparatorY, 190, mainSeparatorY);
48033
48031
  const reportData = analysisData ? analysisData : filterDataByDateKeyRange(monthlyData, normalizedRange);
48034
- const validDays = reportData.filter((day) => {
48035
- const date = new Date(day.date);
48036
- return date.getMonth() === selectedMonth && date.getFullYear() === selectedYear;
48037
- });
48032
+ const validDays = reportData;
48038
48033
  const hasShiftData = (shift) => {
48039
48034
  if (shift.hasData !== void 0) return shift.hasData;
48040
48035
  return shift.total_workspaces > 0 || shift.avg_efficiency > 0 || shift.underperforming_workspaces > 0 || (shift.available_time_seconds ?? 0) > 0 || (shift.idle_time_seconds ?? 0) > 0 || (shift.output ?? 0) > 0;
@@ -48042,7 +48037,7 @@ var LineMonthlyPdfGenerator = ({
48042
48037
  const dailyEntries = validDays.map((dayData) => {
48043
48038
  const shift = getLineShiftData2(dayData, selectedShiftId);
48044
48039
  return { dayData, shift };
48045
- }).filter(({ shift }) => hasShiftData(shift)).sort((left, right) => new Date(right.dayData.date).getTime() - new Date(left.dayData.date).getTime());
48040
+ }).filter(({ shift }) => hasShiftData(shift)).sort((left, right) => getLineDayDateKey3(right.dayData).localeCompare(getLineDayDateKey3(left.dayData)));
48046
48041
  const getUptimeTotals2 = (shift, hasData) => {
48047
48042
  if (!hasData || !shift) {
48048
48043
  return { availableSeconds: 0, productiveSeconds: 0, idleSeconds: 0 };
@@ -63655,6 +63650,7 @@ var KPIDetailView = ({
63655
63650
  const monthBounds = React143.useMemo(() => getMonthKeyBounds(currentYear, currentMonth), [currentYear, currentMonth]);
63656
63651
  const [rangeStart, setRangeStart] = React143.useState(monthBounds.startKey);
63657
63652
  const [rangeEnd, setRangeEnd] = React143.useState(monthBounds.endKey);
63653
+ const appliedExternalRangeKeyRef = React143.useRef(null);
63658
63654
  const [monthlyData, setMonthlyData] = React143.useState([]);
63659
63655
  const [underperformingWorkspaces, setUnderperformingWorkspaces] = React143.useState({});
63660
63656
  const [selectedShiftId, setSelectedShiftId] = React143.useState(0);
@@ -63697,12 +63693,29 @@ var KPIDetailView = ({
63697
63693
  const range = React143.useMemo(() => ({ startKey: rangeStart, endKey: rangeEnd }), [rangeStart, rangeEnd]);
63698
63694
  const isFullRange = React143.useMemo(() => isFullMonthRange(range, currentYear, currentMonth), [range, currentYear, currentMonth]);
63699
63695
  React143.useEffect(() => {
63696
+ const hasExternalRange = typeof urlRangeStart === "string" || typeof urlRangeEnd === "string";
63697
+ if (!hasExternalRange) {
63698
+ appliedExternalRangeKeyRef.current = null;
63699
+ return;
63700
+ }
63701
+ const externalRangeKey = `${urlRangeStart ?? ""}|${urlRangeEnd ?? ""}`;
63702
+ if (appliedExternalRangeKeyRef.current === externalRangeKey) {
63703
+ return;
63704
+ }
63705
+ appliedExternalRangeKeyRef.current = externalRangeKey;
63706
+ const targetStartKey = typeof urlRangeStart === "string" ? urlRangeStart : typeof urlRangeEnd === "string" ? urlRangeEnd : monthBounds.startKey;
63707
+ const targetStartDate = parseDateKeyToDate(targetStartKey);
63708
+ const targetMonth = targetStartDate.getMonth();
63709
+ const targetYear = targetStartDate.getFullYear();
63710
+ const targetBounds = getMonthKeyBounds(targetYear, targetMonth);
63700
63711
  const normalized = normalizeDateKeyRange(
63701
- typeof urlRangeStart === "string" ? urlRangeStart : monthBounds.startKey,
63702
- typeof urlRangeEnd === "string" ? urlRangeEnd : monthBounds.endKey,
63703
- monthBounds.startKey,
63704
- monthBounds.endKey
63712
+ typeof urlRangeStart === "string" ? urlRangeStart : targetBounds.startKey,
63713
+ typeof urlRangeEnd === "string" ? urlRangeEnd : targetBounds.endKey,
63714
+ targetBounds.startKey,
63715
+ targetBounds.endKey
63705
63716
  );
63717
+ setCurrentMonth(targetMonth);
63718
+ setCurrentYear(targetYear);
63706
63719
  setRangeStart(normalized.startKey);
63707
63720
  setRangeEnd(normalized.endKey);
63708
63721
  }, [urlRangeStart, urlRangeEnd, monthBounds.startKey, monthBounds.endKey]);
@@ -63870,12 +63883,13 @@ var KPIDetailView = ({
63870
63883
  const dayDataMap = /* @__PURE__ */ new Map();
63871
63884
  const resolveMonthlyShiftTimes = (metricShiftId) => resolveShiftTimes(metricShiftId);
63872
63885
  monthlyMetrics.forEach((metric) => {
63873
- const date = new Date(metric.date);
63874
- const dateKey = date.toISOString().split("T")[0];
63886
+ const dateKey = getDateKeyFromValue(metric.date);
63887
+ const date = parseDateKeyToDate(dateKey);
63875
63888
  let dayData = dayDataMap.get(dateKey);
63876
63889
  if (!dayData) {
63877
63890
  dayData = {
63878
63891
  date,
63892
+ dateKey,
63879
63893
  shifts: {}
63880
63894
  // Multi-shift structure: Record<number, ShiftData>
63881
63895
  };
@@ -63922,7 +63936,11 @@ var KPIDetailView = ({
63922
63936
  };
63923
63937
  dayData.shifts[metric.shift_id] = shiftData;
63924
63938
  });
63925
- const transformedMonthlyData = Array.from(dayDataMap.values());
63939
+ const transformedMonthlyData = Array.from(dayDataMap.values()).map((dayData) => ({
63940
+ date: dayData.date,
63941
+ dateKey: dayData.dateKey,
63942
+ shifts: dayData.shifts
63943
+ }));
63926
63944
  console.log("Transformed monthly data for calendar:", transformedMonthlyData);
63927
63945
  setMonthlyData(transformedMonthlyData);
63928
63946
  const mapWorkspaces = (workspaces2) => (workspaces2 || []).map((ws) => ({
@@ -71163,6 +71181,7 @@ var WorkspaceDetailView = ({
71163
71181
  const monthBounds = React143.useMemo(() => getMonthKeyBounds(selectedYear, selectedMonth), [selectedYear, selectedMonth]);
71164
71182
  const [rangeStart, setRangeStart] = React143.useState(monthBounds.startKey);
71165
71183
  const [rangeEnd, setRangeEnd] = React143.useState(monthBounds.endKey);
71184
+ const appliedExternalRangeKeyRef = React143.useRef(null);
71166
71185
  const [selectedShift, setSelectedShift] = React143.useState(0);
71167
71186
  React143.useEffect(() => {
71168
71187
  if (parsedShiftId !== void 0) {
@@ -71174,8 +71193,14 @@ var WorkspaceDetailView = ({
71174
71193
  React143.useEffect(() => {
71175
71194
  const hasExternalRange = typeof urlRangeStart === "string" || typeof urlRangeEnd === "string";
71176
71195
  if (!hasExternalRange) {
71196
+ appliedExternalRangeKeyRef.current = null;
71197
+ return;
71198
+ }
71199
+ const externalRangeKey = `${urlRangeStart ?? ""}|${urlRangeEnd ?? ""}`;
71200
+ if (appliedExternalRangeKeyRef.current === externalRangeKey) {
71177
71201
  return;
71178
71202
  }
71203
+ appliedExternalRangeKeyRef.current = externalRangeKey;
71179
71204
  const targetStartKey = typeof urlRangeStart === "string" ? urlRangeStart : typeof urlRangeEnd === "string" ? urlRangeEnd : monthBounds.startKey;
71180
71205
  const targetStartDate = parseDateKeyToDate(targetStartKey);
71181
71206
  const targetMonth = targetStartDate.getMonth();
@@ -71797,7 +71822,7 @@ var WorkspaceDetailView = ({
71797
71822
  const analysisMonthlyData = React143.useMemo(() => {
71798
71823
  return filterDataByDateKeyRange(monthlyData, range);
71799
71824
  }, [monthlyData, range]);
71800
- const formattedWorkspaceName = displayName || workspace?.workspace_display_name || formatWorkspaceName3(workspace?.workspace_name || "", resolvedLineId);
71825
+ const formattedWorkspaceName = workspace?.workspace_display_name || displayName || formatWorkspaceName3(workspace?.workspace_name || "", resolvedLineId);
71801
71826
  const resolvedLineName = React143.useMemo(() => {
71802
71827
  const workspaceLineName = workspace?.line_name?.trim();
71803
71828
  if (workspaceLineName) {
@@ -72343,6 +72368,9 @@ var WorkspaceDetailView = ({
72343
72368
  onMonthNavigate: (newMonth, newYear) => {
72344
72369
  setSelectedMonth(newMonth);
72345
72370
  setSelectedYear(newYear);
72371
+ const nextBounds = getMonthKeyBounds(newYear, newMonth);
72372
+ setRangeStart(nextBounds.startKey);
72373
+ setRangeEnd(nextBounds.endKey);
72346
72374
  },
72347
72375
  showLabel: false
72348
72376
  }
package/dist/index.mjs CHANGED
@@ -46546,6 +46546,7 @@ var getLineShiftData = (day, shiftId) => {
46546
46546
  }
46547
46547
  return { ...DEFAULT_LINE_SHIFT_DATA };
46548
46548
  };
46549
+ var getLineDayDateKey = (day) => day.dateKey || getDateKeyFromValue(day.date);
46549
46550
  var WEEKDAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
46550
46551
  var LineHistoryCalendar = ({
46551
46552
  data,
@@ -46580,20 +46581,16 @@ var LineHistoryCalendar = ({
46580
46581
  for (let day = 1; day <= totalDays; day++) {
46581
46582
  const currentDate = toZonedTime(new Date(year, month, day), configuredTimezone);
46582
46583
  const currentDateString = `${currentDate.getFullYear()}-${String(currentDate.getMonth() + 1).padStart(2, "0")}-${String(currentDate.getDate()).padStart(2, "0")}`;
46583
- const existingData = data.find((d) => {
46584
- if (!d.date) return false;
46585
- const dDate = typeof d.date === "string" ? new Date(d.date) : d.date;
46586
- const dDateIST = toZonedTime(dDate, configuredTimezone);
46587
- const dDateString = `${dDateIST.getFullYear()}-${String(dDateIST.getMonth() + 1).padStart(2, "0")}-${String(dDateIST.getDate()).padStart(2, "0")}`;
46588
- return dDateString === currentDateString;
46589
- });
46584
+ const existingData = data.find((d) => d && getLineDayDateKey(d) === currentDateString);
46590
46585
  if (existingData) {
46591
46586
  calendar.push({
46592
46587
  ...existingData,
46588
+ dateKey: getLineDayDateKey(existingData),
46593
46589
  date: currentDate
46594
46590
  });
46595
46591
  } else {
46596
46592
  calendar.push({
46593
+ dateKey: currentDateString,
46597
46594
  date: currentDate,
46598
46595
  shifts: {}
46599
46596
  });
@@ -46665,7 +46662,7 @@ var LineHistoryCalendar = ({
46665
46662
  const isFuture = isFutureDate(day.date instanceof Date ? day.date : new Date(day.date));
46666
46663
  const hasData = hasRealData(shiftData);
46667
46664
  const dateObj = day.date instanceof Date ? day.date : new Date(day.date);
46668
- const dateKey = `${dateObj.getFullYear()}-${String(dateObj.getMonth() + 1).padStart(2, "0")}-${String(dateObj.getDate()).padStart(2, "0")}`;
46665
+ const dateKey = getLineDayDateKey(day);
46669
46666
  const showRange = rangeStart && rangeEnd ? !(rangeStart === monthBounds.startKey && rangeEnd === monthBounds.endKey) : false;
46670
46667
  const inRange = showRange ? dateKey >= rangeStart && dateKey <= rangeEnd : false;
46671
46668
  const isRangeEdge = inRange && (dateKey === rangeStart || dateKey === rangeEnd);
@@ -46676,11 +46673,7 @@ var LineHistoryCalendar = ({
46676
46673
  className: `group h-full ${isFuture || !hasData || isFilteredOut ? "cursor-not-allowed" : "cursor-pointer hover:opacity-90"}`,
46677
46674
  onClick: () => {
46678
46675
  if (!isFuture && hasData && !isFilteredOut) {
46679
- const dateObj2 = day.date instanceof Date ? day.date : new Date(day.date);
46680
- const year2 = dateObj2.getFullYear();
46681
- const month2 = String(dateObj2.getMonth() + 1).padStart(2, "0");
46682
- const dayOfMonth = String(dateObj2.getDate()).padStart(2, "0");
46683
- const date = `${year2}-${month2}-${dayOfMonth}`;
46676
+ const date = getLineDayDateKey(day);
46684
46677
  trackCoreEvent("Line Monthly History Day Clicked", {
46685
46678
  source: "line_kpi",
46686
46679
  line_id: lineId,
@@ -46692,8 +46685,8 @@ var LineHistoryCalendar = ({
46692
46685
  });
46693
46686
  const params = new URLSearchParams();
46694
46687
  params.set("tab", "monthly_history");
46695
- params.set("month", month2.toString());
46696
- params.set("year", year2.toString());
46688
+ params.set("month", month.toString());
46689
+ params.set("year", year.toString());
46697
46690
  if (rangeStart && rangeEnd && !(rangeStart === monthBounds.startKey && rangeEnd === monthBounds.endKey)) {
46698
46691
  params.set("rangeStart", rangeStart);
46699
46692
  params.set("rangeEnd", rangeEnd);
@@ -47162,6 +47155,7 @@ var getShiftData2 = (day, shiftId) => {
47162
47155
  }
47163
47156
  return { ...DEFAULT_PERFORMANCE_DATA };
47164
47157
  };
47158
+ var getLineDayDateKey2 = (day) => day.dateKey || getDateKeyFromValue(day.date);
47165
47159
  var getUptimeTotals = (shift, hasShiftData) => {
47166
47160
  if (!shift) {
47167
47161
  return { availableSeconds: 0, productiveSeconds: 0, idleSeconds: 0 };
@@ -47219,6 +47213,10 @@ var LineMonthlyHistory = ({
47219
47213
  }
47220
47214
  return filterDataByDateKeyRange(monthlyData, normalizedRange);
47221
47215
  }, [analysisData, monthlyData, normalizedRange]);
47216
+ const analysisMonthlyDataByKey = useMemo(
47217
+ () => new Map((analysisMonthlyData || []).map((day) => [getLineDayDateKey2(day), day])),
47218
+ [analysisMonthlyData]
47219
+ );
47222
47220
  const startDate = normalizedRange.startKey;
47223
47221
  const endDate = normalizedRange.endKey;
47224
47222
  const {
@@ -47325,9 +47323,9 @@ var LineMonthlyHistory = ({
47325
47323
  const chartData = useMemo(() => {
47326
47324
  const rangeStartDate = parseDateKeyToDate(normalizedRange.startKey);
47327
47325
  const rangeEndDate = parseDateKeyToDate(normalizedRange.endKey);
47328
- const dayNumbers = [];
47326
+ const rangeDateKeys = [];
47329
47327
  for (let d = new Date(rangeStartDate); d <= rangeEndDate; d.setDate(d.getDate() + 1)) {
47330
- dayNumbers.push(d.getDate());
47328
+ rangeDateKeys.push(buildDateKey(d.getFullYear(), d.getMonth(), d.getDate()));
47331
47329
  }
47332
47330
  if (isUptimeMode) {
47333
47331
  const dailyData2 = [];
@@ -47335,13 +47333,10 @@ var LineMonthlyHistory = ({
47335
47333
  const todayInZone = getCurrentTimeInZone(timezone);
47336
47334
  const todayDate = typeof todayInZone === "string" ? new Date(todayInZone) : todayInZone;
47337
47335
  const todayKey = `${todayDate.getFullYear()}-${String(todayDate.getMonth() + 1).padStart(2, "0")}-${String(todayDate.getDate()).padStart(2, "0")}`;
47338
- for (const day of dayNumbers) {
47339
- const dayKey = `${rangeStartDate.getFullYear()}-${String(rangeStartDate.getMonth() + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
47336
+ for (const dayKey of rangeDateKeys) {
47337
+ const day = Number(dayKey.slice(-2));
47340
47338
  const isFutureDay = dayKey > todayKey;
47341
- const dayData = analysisMonthlyData.find((d) => {
47342
- const date = new Date(d.date);
47343
- return date.getDate() === day;
47344
- });
47339
+ const dayData = analysisMonthlyDataByKey.get(dayKey);
47345
47340
  const shiftData = dayData ? getShiftData2(dayData, selectedShiftId) : null;
47346
47341
  const hasShiftData = Boolean(shiftData && hasRealData(shiftData));
47347
47342
  const efficiencyValue = hasShiftData && Number.isFinite(shiftData?.avg_efficiency) ? Number(shiftData?.avg_efficiency) : 0;
@@ -47363,12 +47358,9 @@ var LineMonthlyHistory = ({
47363
47358
  const dailyData = [];
47364
47359
  let maxOutput = 0;
47365
47360
  let lastSetTarget = 0;
47366
- for (let i = dayNumbers.length - 1; i >= 0; i--) {
47367
- const day = dayNumbers[i];
47368
- const dayData = analysisMonthlyData.find((d) => {
47369
- const date = new Date(d.date);
47370
- return date.getDate() === day;
47371
- });
47361
+ for (let i = rangeDateKeys.length - 1; i >= 0; i--) {
47362
+ const dayKey = rangeDateKeys[i];
47363
+ const dayData = analysisMonthlyDataByKey.get(dayKey);
47372
47364
  const shiftData = dayData ? getShiftData2(dayData, selectedShiftId) : null;
47373
47365
  const idealOutput = shiftData ? shiftData.idealOutput || 0 : 0;
47374
47366
  if (idealOutput > 0) {
@@ -47376,11 +47368,9 @@ var LineMonthlyHistory = ({
47376
47368
  break;
47377
47369
  }
47378
47370
  }
47379
- for (const day of dayNumbers) {
47380
- const dayData = analysisMonthlyData.find((d) => {
47381
- const date = new Date(d.date);
47382
- return date.getDate() === day;
47383
- });
47371
+ for (const dayKey of rangeDateKeys) {
47372
+ const day = Number(dayKey.slice(-2));
47373
+ const dayData = analysisMonthlyDataByKey.get(dayKey);
47384
47374
  const shiftData = dayData ? getShiftData2(dayData, selectedShiftId) : null;
47385
47375
  const output = shiftData && hasRealData(shiftData) ? shiftData.output || 0 : 0;
47386
47376
  const idealOutput = shiftData ? shiftData.idealOutput || 0 : 0;
@@ -47400,7 +47390,7 @@ var LineMonthlyHistory = ({
47400
47390
  const calculatedMax = Math.max(maxOutput, lastSetTarget);
47401
47391
  const yAxisMax = calculatedMax > 0 ? calculatedMax * 1.1 : 100;
47402
47392
  return { data: dailyData, maxOutput, lastSetTarget, yAxisMax };
47403
- }, [analysisMonthlyData, normalizedRange.startKey, normalizedRange.endKey, selectedShiftId, isUptimeMode, timezone]);
47393
+ }, [analysisMonthlyDataByKey, normalizedRange.endKey, normalizedRange.startKey, selectedShiftId, isUptimeMode, timezone]);
47404
47394
  const yAxisTicks = useMemo(() => {
47405
47395
  const max = chartData.yAxisMax;
47406
47396
  const target = chartData.lastSetTarget;
@@ -47888,6 +47878,7 @@ var getShiftDisplayName = (shiftId, availableShifts) => {
47888
47878
  if (shiftId === 1) return "Night Shift";
47889
47879
  return `Shift ${shiftId}`;
47890
47880
  };
47881
+ var getLineDayDateKey3 = (day) => day.dateKey || getDateKeyFromValue(day.date);
47891
47882
  var LineMonthlyPdfGenerator = ({
47892
47883
  lineId,
47893
47884
  lineName,
@@ -47917,13 +47908,20 @@ var LineMonthlyPdfGenerator = ({
47917
47908
  startKey: rangeStart || monthBounds.startKey,
47918
47909
  endKey: rangeEnd || monthBounds.endKey
47919
47910
  };
47911
+ const boundsSourceKey = rangeStart || rangeEnd || monthBounds.startKey;
47912
+ const boundsSourceDate = parseDateKeyToDate(boundsSourceKey);
47913
+ const effectiveBounds = getMonthKeyBounds(boundsSourceDate.getFullYear(), boundsSourceDate.getMonth());
47920
47914
  const normalizedRange = normalizeDateKeyRange(
47921
47915
  requestedRange.startKey,
47922
47916
  requestedRange.endKey,
47923
- monthBounds.startKey,
47924
- monthBounds.endKey
47917
+ effectiveBounds.startKey,
47918
+ effectiveBounds.endKey
47919
+ );
47920
+ const fullRange = isFullMonthRange(
47921
+ normalizedRange,
47922
+ boundsSourceDate.getFullYear(),
47923
+ boundsSourceDate.getMonth()
47925
47924
  );
47926
- const fullRange = isFullMonthRange(normalizedRange, selectedYear, selectedMonth);
47927
47925
  const reportStartDate = parseDateKeyToDate(normalizedRange.startKey);
47928
47926
  const reportEndDate = parseDateKeyToDate(normalizedRange.endKey);
47929
47927
  const reportStartStr = reportStartDate.toLocaleDateString("en-IN", {
@@ -47941,8 +47939,8 @@ var LineMonthlyPdfGenerator = ({
47941
47939
  trackCoreEvent("Line Monthly PDF Export Clicked", {
47942
47940
  line_id: lineId,
47943
47941
  line_name: lineName,
47944
- month: selectedMonth,
47945
- year: selectedYear,
47942
+ month: reportStartDate.getMonth(),
47943
+ year: reportStartDate.getFullYear(),
47946
47944
  shift_id: selectedShiftId,
47947
47945
  range_start: normalizedRange.startKey,
47948
47946
  range_end: normalizedRange.endKey,
@@ -47954,6 +47952,11 @@ var LineMonthlyPdfGenerator = ({
47954
47952
  const maxContentY = footerY - 10;
47955
47953
  const generatedText = `Generated on ${(/* @__PURE__ */ new Date()).toLocaleString("en-IN", { timeZone: "Asia/Kolkata" })}`;
47956
47954
  const dailySectionTitle = isUptimeMode ? "Daily Utilization Summary" : "Daily Performance Summary";
47955
+ const monthName = reportStartDate.toLocaleDateString("en-IN", {
47956
+ month: "long",
47957
+ year: "numeric",
47958
+ timeZone: "Asia/Kolkata"
47959
+ });
47957
47960
  const drawPageChrome = () => {
47958
47961
  doc.setFontSize(14);
47959
47962
  doc.setFont("helvetica", "bold");
@@ -47985,11 +47988,6 @@ var LineMonthlyPdfGenerator = ({
47985
47988
  doc.setFontSize(13);
47986
47989
  doc.setFont("helvetica", "normal");
47987
47990
  doc.setTextColor(60, 60, 60);
47988
- const monthName = new Date(selectedYear, selectedMonth).toLocaleDateString("en-IN", {
47989
- month: "long",
47990
- year: "numeric",
47991
- timeZone: "Asia/Kolkata"
47992
- });
47993
47991
  const shiftType = getShiftDisplayName(selectedShiftId, availableShifts);
47994
47992
  doc.text(`${monthName}`, 20, 55);
47995
47993
  doc.text(`${shiftType}`, 20, 63);
@@ -48002,10 +48000,7 @@ var LineMonthlyPdfGenerator = ({
48002
48000
  const mainSeparatorY = isUptimeMode ? 90 : 85;
48003
48001
  doc.line(20, mainSeparatorY, 190, mainSeparatorY);
48004
48002
  const reportData = analysisData ? analysisData : filterDataByDateKeyRange(monthlyData, normalizedRange);
48005
- const validDays = reportData.filter((day) => {
48006
- const date = new Date(day.date);
48007
- return date.getMonth() === selectedMonth && date.getFullYear() === selectedYear;
48008
- });
48003
+ const validDays = reportData;
48009
48004
  const hasShiftData = (shift) => {
48010
48005
  if (shift.hasData !== void 0) return shift.hasData;
48011
48006
  return shift.total_workspaces > 0 || shift.avg_efficiency > 0 || shift.underperforming_workspaces > 0 || (shift.available_time_seconds ?? 0) > 0 || (shift.idle_time_seconds ?? 0) > 0 || (shift.output ?? 0) > 0;
@@ -48013,7 +48008,7 @@ var LineMonthlyPdfGenerator = ({
48013
48008
  const dailyEntries = validDays.map((dayData) => {
48014
48009
  const shift = getLineShiftData2(dayData, selectedShiftId);
48015
48010
  return { dayData, shift };
48016
- }).filter(({ shift }) => hasShiftData(shift)).sort((left, right) => new Date(right.dayData.date).getTime() - new Date(left.dayData.date).getTime());
48011
+ }).filter(({ shift }) => hasShiftData(shift)).sort((left, right) => getLineDayDateKey3(right.dayData).localeCompare(getLineDayDateKey3(left.dayData)));
48017
48012
  const getUptimeTotals2 = (shift, hasData) => {
48018
48013
  if (!hasData || !shift) {
48019
48014
  return { availableSeconds: 0, productiveSeconds: 0, idleSeconds: 0 };
@@ -63626,6 +63621,7 @@ var KPIDetailView = ({
63626
63621
  const monthBounds = useMemo(() => getMonthKeyBounds(currentYear, currentMonth), [currentYear, currentMonth]);
63627
63622
  const [rangeStart, setRangeStart] = useState(monthBounds.startKey);
63628
63623
  const [rangeEnd, setRangeEnd] = useState(monthBounds.endKey);
63624
+ const appliedExternalRangeKeyRef = useRef(null);
63629
63625
  const [monthlyData, setMonthlyData] = useState([]);
63630
63626
  const [underperformingWorkspaces, setUnderperformingWorkspaces] = useState({});
63631
63627
  const [selectedShiftId, setSelectedShiftId] = useState(0);
@@ -63668,12 +63664,29 @@ var KPIDetailView = ({
63668
63664
  const range = useMemo(() => ({ startKey: rangeStart, endKey: rangeEnd }), [rangeStart, rangeEnd]);
63669
63665
  const isFullRange = useMemo(() => isFullMonthRange(range, currentYear, currentMonth), [range, currentYear, currentMonth]);
63670
63666
  useEffect(() => {
63667
+ const hasExternalRange = typeof urlRangeStart === "string" || typeof urlRangeEnd === "string";
63668
+ if (!hasExternalRange) {
63669
+ appliedExternalRangeKeyRef.current = null;
63670
+ return;
63671
+ }
63672
+ const externalRangeKey = `${urlRangeStart ?? ""}|${urlRangeEnd ?? ""}`;
63673
+ if (appliedExternalRangeKeyRef.current === externalRangeKey) {
63674
+ return;
63675
+ }
63676
+ appliedExternalRangeKeyRef.current = externalRangeKey;
63677
+ const targetStartKey = typeof urlRangeStart === "string" ? urlRangeStart : typeof urlRangeEnd === "string" ? urlRangeEnd : monthBounds.startKey;
63678
+ const targetStartDate = parseDateKeyToDate(targetStartKey);
63679
+ const targetMonth = targetStartDate.getMonth();
63680
+ const targetYear = targetStartDate.getFullYear();
63681
+ const targetBounds = getMonthKeyBounds(targetYear, targetMonth);
63671
63682
  const normalized = normalizeDateKeyRange(
63672
- typeof urlRangeStart === "string" ? urlRangeStart : monthBounds.startKey,
63673
- typeof urlRangeEnd === "string" ? urlRangeEnd : monthBounds.endKey,
63674
- monthBounds.startKey,
63675
- monthBounds.endKey
63683
+ typeof urlRangeStart === "string" ? urlRangeStart : targetBounds.startKey,
63684
+ typeof urlRangeEnd === "string" ? urlRangeEnd : targetBounds.endKey,
63685
+ targetBounds.startKey,
63686
+ targetBounds.endKey
63676
63687
  );
63688
+ setCurrentMonth(targetMonth);
63689
+ setCurrentYear(targetYear);
63677
63690
  setRangeStart(normalized.startKey);
63678
63691
  setRangeEnd(normalized.endKey);
63679
63692
  }, [urlRangeStart, urlRangeEnd, monthBounds.startKey, monthBounds.endKey]);
@@ -63841,12 +63854,13 @@ var KPIDetailView = ({
63841
63854
  const dayDataMap = /* @__PURE__ */ new Map();
63842
63855
  const resolveMonthlyShiftTimes = (metricShiftId) => resolveShiftTimes(metricShiftId);
63843
63856
  monthlyMetrics.forEach((metric) => {
63844
- const date = new Date(metric.date);
63845
- const dateKey = date.toISOString().split("T")[0];
63857
+ const dateKey = getDateKeyFromValue(metric.date);
63858
+ const date = parseDateKeyToDate(dateKey);
63846
63859
  let dayData = dayDataMap.get(dateKey);
63847
63860
  if (!dayData) {
63848
63861
  dayData = {
63849
63862
  date,
63863
+ dateKey,
63850
63864
  shifts: {}
63851
63865
  // Multi-shift structure: Record<number, ShiftData>
63852
63866
  };
@@ -63893,7 +63907,11 @@ var KPIDetailView = ({
63893
63907
  };
63894
63908
  dayData.shifts[metric.shift_id] = shiftData;
63895
63909
  });
63896
- const transformedMonthlyData = Array.from(dayDataMap.values());
63910
+ const transformedMonthlyData = Array.from(dayDataMap.values()).map((dayData) => ({
63911
+ date: dayData.date,
63912
+ dateKey: dayData.dateKey,
63913
+ shifts: dayData.shifts
63914
+ }));
63897
63915
  console.log("Transformed monthly data for calendar:", transformedMonthlyData);
63898
63916
  setMonthlyData(transformedMonthlyData);
63899
63917
  const mapWorkspaces = (workspaces2) => (workspaces2 || []).map((ws) => ({
@@ -71134,6 +71152,7 @@ var WorkspaceDetailView = ({
71134
71152
  const monthBounds = useMemo(() => getMonthKeyBounds(selectedYear, selectedMonth), [selectedYear, selectedMonth]);
71135
71153
  const [rangeStart, setRangeStart] = useState(monthBounds.startKey);
71136
71154
  const [rangeEnd, setRangeEnd] = useState(monthBounds.endKey);
71155
+ const appliedExternalRangeKeyRef = useRef(null);
71137
71156
  const [selectedShift, setSelectedShift] = useState(0);
71138
71157
  useEffect(() => {
71139
71158
  if (parsedShiftId !== void 0) {
@@ -71145,8 +71164,14 @@ var WorkspaceDetailView = ({
71145
71164
  useEffect(() => {
71146
71165
  const hasExternalRange = typeof urlRangeStart === "string" || typeof urlRangeEnd === "string";
71147
71166
  if (!hasExternalRange) {
71167
+ appliedExternalRangeKeyRef.current = null;
71168
+ return;
71169
+ }
71170
+ const externalRangeKey = `${urlRangeStart ?? ""}|${urlRangeEnd ?? ""}`;
71171
+ if (appliedExternalRangeKeyRef.current === externalRangeKey) {
71148
71172
  return;
71149
71173
  }
71174
+ appliedExternalRangeKeyRef.current = externalRangeKey;
71150
71175
  const targetStartKey = typeof urlRangeStart === "string" ? urlRangeStart : typeof urlRangeEnd === "string" ? urlRangeEnd : monthBounds.startKey;
71151
71176
  const targetStartDate = parseDateKeyToDate(targetStartKey);
71152
71177
  const targetMonth = targetStartDate.getMonth();
@@ -71768,7 +71793,7 @@ var WorkspaceDetailView = ({
71768
71793
  const analysisMonthlyData = useMemo(() => {
71769
71794
  return filterDataByDateKeyRange(monthlyData, range);
71770
71795
  }, [monthlyData, range]);
71771
- const formattedWorkspaceName = displayName || workspace?.workspace_display_name || formatWorkspaceName3(workspace?.workspace_name || "", resolvedLineId);
71796
+ const formattedWorkspaceName = workspace?.workspace_display_name || displayName || formatWorkspaceName3(workspace?.workspace_name || "", resolvedLineId);
71772
71797
  const resolvedLineName = useMemo(() => {
71773
71798
  const workspaceLineName = workspace?.line_name?.trim();
71774
71799
  if (workspaceLineName) {
@@ -72314,6 +72339,9 @@ var WorkspaceDetailView = ({
72314
72339
  onMonthNavigate: (newMonth, newYear) => {
72315
72340
  setSelectedMonth(newMonth);
72316
72341
  setSelectedYear(newYear);
72342
+ const nextBounds = getMonthKeyBounds(newYear, newMonth);
72343
+ setRangeStart(nextBounds.startKey);
72344
+ setRangeEnd(nextBounds.endKey);
72317
72345
  },
72318
72346
  showLabel: false
72319
72347
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.11.40",
3
+ "version": "6.11.41",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",