@optifye/dashboard-core 6.5.6 → 6.5.7

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
@@ -2281,6 +2281,7 @@ interface LineMetrics {
2281
2281
  underperforming_workspace_names: string[];
2282
2282
  underperforming_workspace_uuids: string[];
2283
2283
  output_array: number[];
2284
+ output_hourly?: Record<string, number[]>;
2284
2285
  line_threshold: number;
2285
2286
  threshold_pph: number;
2286
2287
  shift_start: string;
@@ -4325,6 +4326,7 @@ interface HourlyOutputChartProps {
4325
4326
  data: number[];
4326
4327
  pphThreshold: number;
4327
4328
  shiftStart: string;
4329
+ shiftEnd?: string;
4328
4330
  showIdleTime?: boolean;
4329
4331
  idleTimeHourly?: Record<string, string[]>;
4330
4332
  className?: string;
package/dist/index.d.ts CHANGED
@@ -2281,6 +2281,7 @@ interface LineMetrics {
2281
2281
  underperforming_workspace_names: string[];
2282
2282
  underperforming_workspace_uuids: string[];
2283
2283
  output_array: number[];
2284
+ output_hourly?: Record<string, number[]>;
2284
2285
  line_threshold: number;
2285
2286
  threshold_pph: number;
2286
2287
  shift_start: string;
@@ -4325,6 +4326,7 @@ interface HourlyOutputChartProps {
4325
4326
  data: number[];
4326
4327
  pphThreshold: number;
4327
4328
  shiftStart: string;
4329
+ shiftEnd?: string;
4328
4330
  showIdleTime?: boolean;
4329
4331
  idleTimeHourly?: Record<string, string[]>;
4330
4332
  className?: string;
package/dist/index.js CHANGED
@@ -893,15 +893,19 @@ var dashboardService = {
893
893
  const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
894
894
  const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
895
895
  const startHour = parseInt(shiftStart.split(":")[0]);
896
+ const startMinute = parseInt(shiftStart.split(":")[1] || "0");
897
+ const endHour = parseInt(shiftEnd.split(":")[0]);
898
+ const endMinute = parseInt(shiftEnd.split(":")[1] || "0");
899
+ let shiftDuration = endHour - startHour;
900
+ if (endMinute > startMinute) {
901
+ shiftDuration += 1;
902
+ }
903
+ if (shiftDuration <= 0) {
904
+ shiftDuration += 24;
905
+ }
896
906
  let expectedHours = [];
897
- if (isNightShift) {
898
- for (let i = 0; i < 9; i++) {
899
- expectedHours.push((startHour + i) % 24);
900
- }
901
- } else {
902
- for (let i = 0; i < 9; i++) {
903
- expectedHours.push((startHour + i) % 24);
904
- }
907
+ for (let i = 0; i < shiftDuration; i++) {
908
+ expectedHours.push((startHour + i) % 24);
905
909
  }
906
910
  console.log("Expected shift hours:", expectedHours);
907
911
  console.log("Available data hours:", Object.keys(outputHourly));
@@ -5702,15 +5706,19 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
5702
5706
  const shiftStart = recentData.shift_start || (isNightShift ? "22:00" : "06:00");
5703
5707
  const shiftEnd = recentData.shift_end || (isNightShift ? "06:00" : "14:00");
5704
5708
  const startHour = parseInt(shiftStart.split(":")[0]);
5709
+ const startMinute = parseInt(shiftStart.split(":")[1] || "0");
5710
+ const endHour = parseInt(shiftEnd.split(":")[0]);
5711
+ const endMinute = parseInt(shiftEnd.split(":")[1] || "0");
5712
+ let shiftDuration = endHour - startHour;
5713
+ if (endMinute > startMinute) {
5714
+ shiftDuration += 1;
5715
+ }
5716
+ if (shiftDuration <= 0) {
5717
+ shiftDuration += 24;
5718
+ }
5705
5719
  let expectedHours = [];
5706
- if (isNightShift) {
5707
- for (let i = 0; i < 9; i++) {
5708
- expectedHours.push((startHour + i) % 24);
5709
- }
5710
- } else {
5711
- for (let i = 0; i < 9; i++) {
5712
- expectedHours.push((startHour + i) % 24);
5713
- }
5720
+ for (let i = 0; i < shiftDuration; i++) {
5721
+ expectedHours.push((startHour + i) % 24);
5714
5722
  }
5715
5723
  console.log("Expected shift hours (fallback):", expectedHours);
5716
5724
  console.log("Available data hours (fallback):", Object.keys(outputHourly2));
@@ -5814,15 +5822,19 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
5814
5822
  const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
5815
5823
  const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
5816
5824
  const startHour = parseInt(shiftStart.split(":")[0]);
5825
+ const startMinute = parseInt(shiftStart.split(":")[1] || "0");
5826
+ const endHour = parseInt(shiftEnd.split(":")[0]);
5827
+ const endMinute = parseInt(shiftEnd.split(":")[1] || "0");
5828
+ let shiftDuration = endHour - startHour;
5829
+ if (endMinute > startMinute) {
5830
+ shiftDuration += 1;
5831
+ }
5832
+ if (shiftDuration <= 0) {
5833
+ shiftDuration += 24;
5834
+ }
5817
5835
  let expectedHours = [];
5818
- if (isNightShift) {
5819
- for (let i = 0; i < 9; i++) {
5820
- expectedHours.push((startHour + i) % 24);
5821
- }
5822
- } else {
5823
- for (let i = 0; i < 9; i++) {
5824
- expectedHours.push((startHour + i) % 24);
5825
- }
5836
+ for (let i = 0; i < shiftDuration; i++) {
5837
+ expectedHours.push((startHour + i) % 24);
5826
5838
  }
5827
5839
  console.log("Expected shift hours:", expectedHours);
5828
5840
  console.log("Available data hours:", Object.keys(outputHourly));
@@ -21246,6 +21258,7 @@ var HourlyOutputChartComponent = ({
21246
21258
  data,
21247
21259
  pphThreshold,
21248
21260
  shiftStart,
21261
+ shiftEnd,
21249
21262
  showIdleTime = false,
21250
21263
  idleTimeHourly,
21251
21264
  className = ""
@@ -21260,10 +21273,32 @@ var HourlyOutputChartComponent = ({
21260
21273
  return { hour, minute, decimalHour };
21261
21274
  };
21262
21275
  const shiftStartTime = getTimeFromTimeString(shiftStart);
21263
- const SHIFT_DURATION = 11;
21264
- const [animatedData, setAnimatedData] = React19__namespace.default.useState(Array(SHIFT_DURATION).fill(0));
21276
+ const calculateShiftDuration = React19__namespace.default.useMemo(() => {
21277
+ if (!shiftEnd) {
21278
+ return 11;
21279
+ }
21280
+ const endTime = getTimeFromTimeString(shiftEnd);
21281
+ let duration = endTime.decimalHour - shiftStartTime.decimalHour;
21282
+ if (duration <= 0) {
21283
+ duration += 24;
21284
+ }
21285
+ return Math.round(duration);
21286
+ }, [shiftEnd, shiftStartTime.decimalHour]);
21287
+ const SHIFT_DURATION = calculateShiftDuration;
21288
+ const [animatedData, setAnimatedData] = React19__namespace.default.useState(
21289
+ () => Array(SHIFT_DURATION).fill(0)
21290
+ );
21265
21291
  const prevDataRef = React19__namespace.default.useRef(Array(SHIFT_DURATION).fill(0));
21266
21292
  const animationFrameRef = React19__namespace.default.useRef(null);
21293
+ React19__namespace.default.useEffect(() => {
21294
+ setAnimatedData((prev) => {
21295
+ if (prev.length !== SHIFT_DURATION) {
21296
+ return Array(SHIFT_DURATION).fill(0);
21297
+ }
21298
+ return prev;
21299
+ });
21300
+ prevDataRef.current = Array(SHIFT_DURATION).fill(0);
21301
+ }, [SHIFT_DURATION]);
21267
21302
  const [idleBarState, setIdleBarState] = React19__namespace.default.useState({
21268
21303
  visible: showIdleTime,
21269
21304
  key: 0,
@@ -33817,7 +33852,8 @@ var BottomSection = React19.memo(({
33817
33852
  {
33818
33853
  data: hourlyOutputData,
33819
33854
  pphThreshold: hourlyThreshold,
33820
- shiftStart: lineInfo.metrics.shift_start || "06:00"
33855
+ shiftStart: lineInfo.metrics.shift_start || "06:00",
33856
+ shiftEnd: lineInfo.metrics.shift_end
33821
33857
  }
33822
33858
  ) })
33823
33859
  ] })
@@ -34067,14 +34103,40 @@ var KPIDetailView = ({
34067
34103
  };
34068
34104
  }, [metrics2, lineDetails, companyId]);
34069
34105
  const hourlyOutputData = React19.useMemo(() => {
34070
- if (!metrics2 || !metrics2.output_array) return [];
34071
- return metrics2.output_array.reduce((acc, val, i) => {
34072
- const hourIndex = Math.floor(i / 60);
34073
- if (!acc[hourIndex]) acc[hourIndex] = 0;
34074
- acc[hourIndex] += val;
34075
- return acc;
34076
- }, []);
34077
- }, [metrics2?.output_array]);
34106
+ if (!metrics2) return [];
34107
+ if (metrics2.output_hourly && Object.keys(metrics2.output_hourly).length > 0) {
34108
+ console.log("Using new output_hourly format in KPIDetailView");
34109
+ const isNightShift = metrics2.shift_id === 1;
34110
+ const shiftStart = metrics2.shift_start || (isNightShift ? "22:00" : "06:00");
34111
+ const shiftEnd = metrics2.shift_end || (isNightShift ? "06:00" : "14:00");
34112
+ const startHour = parseInt(shiftStart.split(":")[0]);
34113
+ const endHour = parseInt(shiftEnd.split(":")[0]);
34114
+ let shiftDuration = endHour - startHour;
34115
+ if (shiftDuration <= 0) {
34116
+ shiftDuration += 24;
34117
+ }
34118
+ let expectedHours = [];
34119
+ for (let i = 0; i < shiftDuration; i++) {
34120
+ expectedHours.push((startHour + i) % 24);
34121
+ }
34122
+ return expectedHours.map((hour) => {
34123
+ const hourData = metrics2.output_hourly[hour.toString()];
34124
+ if (hourData && Array.isArray(hourData)) {
34125
+ return hourData.reduce((sum, val) => sum + (val || 0), 0);
34126
+ }
34127
+ return 0;
34128
+ });
34129
+ }
34130
+ if (metrics2.output_array) {
34131
+ return metrics2.output_array.reduce((acc, val, i) => {
34132
+ const hourIndex = Math.floor(i / 60);
34133
+ if (!acc[hourIndex]) acc[hourIndex] = 0;
34134
+ acc[hourIndex] += val;
34135
+ return acc;
34136
+ }, []);
34137
+ }
34138
+ return [];
34139
+ }, [metrics2]);
34078
34140
  const hourlyThreshold = React19.useMemo(() => metrics2 ? metrics2.threshold_pph || 0 : 0, [metrics2]);
34079
34141
  const sortedByEfficiency = React19.useMemo(() => {
34080
34142
  if (!workspaces) return [];
@@ -38728,6 +38790,7 @@ var WorkspaceDetailView = ({
38728
38790
  data: workspace.hourly_action_counts || [],
38729
38791
  pphThreshold: workspace.pph_threshold || 0,
38730
38792
  shiftStart: workspace.shift_start || "",
38793
+ shiftEnd: workspace.shift_end,
38731
38794
  showIdleTime,
38732
38795
  idleTimeHourly: workspace.idle_time_hourly
38733
38796
  }
@@ -38846,6 +38909,7 @@ var WorkspaceDetailView = ({
38846
38909
  data: workspace.hourly_action_counts || [],
38847
38910
  pphThreshold: workspace.pph_threshold || 0,
38848
38911
  shiftStart: workspace.shift_start || "",
38912
+ shiftEnd: workspace.shift_end,
38849
38913
  showIdleTime,
38850
38914
  idleTimeHourly: workspace.idle_time_hourly
38851
38915
  }
package/dist/index.mjs CHANGED
@@ -863,15 +863,19 @@ var dashboardService = {
863
863
  const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
864
864
  const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
865
865
  const startHour = parseInt(shiftStart.split(":")[0]);
866
+ const startMinute = parseInt(shiftStart.split(":")[1] || "0");
867
+ const endHour = parseInt(shiftEnd.split(":")[0]);
868
+ const endMinute = parseInt(shiftEnd.split(":")[1] || "0");
869
+ let shiftDuration = endHour - startHour;
870
+ if (endMinute > startMinute) {
871
+ shiftDuration += 1;
872
+ }
873
+ if (shiftDuration <= 0) {
874
+ shiftDuration += 24;
875
+ }
866
876
  let expectedHours = [];
867
- if (isNightShift) {
868
- for (let i = 0; i < 9; i++) {
869
- expectedHours.push((startHour + i) % 24);
870
- }
871
- } else {
872
- for (let i = 0; i < 9; i++) {
873
- expectedHours.push((startHour + i) % 24);
874
- }
877
+ for (let i = 0; i < shiftDuration; i++) {
878
+ expectedHours.push((startHour + i) % 24);
875
879
  }
876
880
  console.log("Expected shift hours:", expectedHours);
877
881
  console.log("Available data hours:", Object.keys(outputHourly));
@@ -5672,15 +5676,19 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
5672
5676
  const shiftStart = recentData.shift_start || (isNightShift ? "22:00" : "06:00");
5673
5677
  const shiftEnd = recentData.shift_end || (isNightShift ? "06:00" : "14:00");
5674
5678
  const startHour = parseInt(shiftStart.split(":")[0]);
5679
+ const startMinute = parseInt(shiftStart.split(":")[1] || "0");
5680
+ const endHour = parseInt(shiftEnd.split(":")[0]);
5681
+ const endMinute = parseInt(shiftEnd.split(":")[1] || "0");
5682
+ let shiftDuration = endHour - startHour;
5683
+ if (endMinute > startMinute) {
5684
+ shiftDuration += 1;
5685
+ }
5686
+ if (shiftDuration <= 0) {
5687
+ shiftDuration += 24;
5688
+ }
5675
5689
  let expectedHours = [];
5676
- if (isNightShift) {
5677
- for (let i = 0; i < 9; i++) {
5678
- expectedHours.push((startHour + i) % 24);
5679
- }
5680
- } else {
5681
- for (let i = 0; i < 9; i++) {
5682
- expectedHours.push((startHour + i) % 24);
5683
- }
5690
+ for (let i = 0; i < shiftDuration; i++) {
5691
+ expectedHours.push((startHour + i) % 24);
5684
5692
  }
5685
5693
  console.log("Expected shift hours (fallback):", expectedHours);
5686
5694
  console.log("Available data hours (fallback):", Object.keys(outputHourly2));
@@ -5784,15 +5792,19 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
5784
5792
  const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
5785
5793
  const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
5786
5794
  const startHour = parseInt(shiftStart.split(":")[0]);
5795
+ const startMinute = parseInt(shiftStart.split(":")[1] || "0");
5796
+ const endHour = parseInt(shiftEnd.split(":")[0]);
5797
+ const endMinute = parseInt(shiftEnd.split(":")[1] || "0");
5798
+ let shiftDuration = endHour - startHour;
5799
+ if (endMinute > startMinute) {
5800
+ shiftDuration += 1;
5801
+ }
5802
+ if (shiftDuration <= 0) {
5803
+ shiftDuration += 24;
5804
+ }
5787
5805
  let expectedHours = [];
5788
- if (isNightShift) {
5789
- for (let i = 0; i < 9; i++) {
5790
- expectedHours.push((startHour + i) % 24);
5791
- }
5792
- } else {
5793
- for (let i = 0; i < 9; i++) {
5794
- expectedHours.push((startHour + i) % 24);
5795
- }
5806
+ for (let i = 0; i < shiftDuration; i++) {
5807
+ expectedHours.push((startHour + i) % 24);
5796
5808
  }
5797
5809
  console.log("Expected shift hours:", expectedHours);
5798
5810
  console.log("Available data hours:", Object.keys(outputHourly));
@@ -21216,6 +21228,7 @@ var HourlyOutputChartComponent = ({
21216
21228
  data,
21217
21229
  pphThreshold,
21218
21230
  shiftStart,
21231
+ shiftEnd,
21219
21232
  showIdleTime = false,
21220
21233
  idleTimeHourly,
21221
21234
  className = ""
@@ -21230,10 +21243,32 @@ var HourlyOutputChartComponent = ({
21230
21243
  return { hour, minute, decimalHour };
21231
21244
  };
21232
21245
  const shiftStartTime = getTimeFromTimeString(shiftStart);
21233
- const SHIFT_DURATION = 11;
21234
- const [animatedData, setAnimatedData] = React19__default.useState(Array(SHIFT_DURATION).fill(0));
21246
+ const calculateShiftDuration = React19__default.useMemo(() => {
21247
+ if (!shiftEnd) {
21248
+ return 11;
21249
+ }
21250
+ const endTime = getTimeFromTimeString(shiftEnd);
21251
+ let duration = endTime.decimalHour - shiftStartTime.decimalHour;
21252
+ if (duration <= 0) {
21253
+ duration += 24;
21254
+ }
21255
+ return Math.round(duration);
21256
+ }, [shiftEnd, shiftStartTime.decimalHour]);
21257
+ const SHIFT_DURATION = calculateShiftDuration;
21258
+ const [animatedData, setAnimatedData] = React19__default.useState(
21259
+ () => Array(SHIFT_DURATION).fill(0)
21260
+ );
21235
21261
  const prevDataRef = React19__default.useRef(Array(SHIFT_DURATION).fill(0));
21236
21262
  const animationFrameRef = React19__default.useRef(null);
21263
+ React19__default.useEffect(() => {
21264
+ setAnimatedData((prev) => {
21265
+ if (prev.length !== SHIFT_DURATION) {
21266
+ return Array(SHIFT_DURATION).fill(0);
21267
+ }
21268
+ return prev;
21269
+ });
21270
+ prevDataRef.current = Array(SHIFT_DURATION).fill(0);
21271
+ }, [SHIFT_DURATION]);
21237
21272
  const [idleBarState, setIdleBarState] = React19__default.useState({
21238
21273
  visible: showIdleTime,
21239
21274
  key: 0,
@@ -33787,7 +33822,8 @@ var BottomSection = memo(({
33787
33822
  {
33788
33823
  data: hourlyOutputData,
33789
33824
  pphThreshold: hourlyThreshold,
33790
- shiftStart: lineInfo.metrics.shift_start || "06:00"
33825
+ shiftStart: lineInfo.metrics.shift_start || "06:00",
33826
+ shiftEnd: lineInfo.metrics.shift_end
33791
33827
  }
33792
33828
  ) })
33793
33829
  ] })
@@ -34037,14 +34073,40 @@ var KPIDetailView = ({
34037
34073
  };
34038
34074
  }, [metrics2, lineDetails, companyId]);
34039
34075
  const hourlyOutputData = useMemo(() => {
34040
- if (!metrics2 || !metrics2.output_array) return [];
34041
- return metrics2.output_array.reduce((acc, val, i) => {
34042
- const hourIndex = Math.floor(i / 60);
34043
- if (!acc[hourIndex]) acc[hourIndex] = 0;
34044
- acc[hourIndex] += val;
34045
- return acc;
34046
- }, []);
34047
- }, [metrics2?.output_array]);
34076
+ if (!metrics2) return [];
34077
+ if (metrics2.output_hourly && Object.keys(metrics2.output_hourly).length > 0) {
34078
+ console.log("Using new output_hourly format in KPIDetailView");
34079
+ const isNightShift = metrics2.shift_id === 1;
34080
+ const shiftStart = metrics2.shift_start || (isNightShift ? "22:00" : "06:00");
34081
+ const shiftEnd = metrics2.shift_end || (isNightShift ? "06:00" : "14:00");
34082
+ const startHour = parseInt(shiftStart.split(":")[0]);
34083
+ const endHour = parseInt(shiftEnd.split(":")[0]);
34084
+ let shiftDuration = endHour - startHour;
34085
+ if (shiftDuration <= 0) {
34086
+ shiftDuration += 24;
34087
+ }
34088
+ let expectedHours = [];
34089
+ for (let i = 0; i < shiftDuration; i++) {
34090
+ expectedHours.push((startHour + i) % 24);
34091
+ }
34092
+ return expectedHours.map((hour) => {
34093
+ const hourData = metrics2.output_hourly[hour.toString()];
34094
+ if (hourData && Array.isArray(hourData)) {
34095
+ return hourData.reduce((sum, val) => sum + (val || 0), 0);
34096
+ }
34097
+ return 0;
34098
+ });
34099
+ }
34100
+ if (metrics2.output_array) {
34101
+ return metrics2.output_array.reduce((acc, val, i) => {
34102
+ const hourIndex = Math.floor(i / 60);
34103
+ if (!acc[hourIndex]) acc[hourIndex] = 0;
34104
+ acc[hourIndex] += val;
34105
+ return acc;
34106
+ }, []);
34107
+ }
34108
+ return [];
34109
+ }, [metrics2]);
34048
34110
  const hourlyThreshold = useMemo(() => metrics2 ? metrics2.threshold_pph || 0 : 0, [metrics2]);
34049
34111
  const sortedByEfficiency = useMemo(() => {
34050
34112
  if (!workspaces) return [];
@@ -38698,6 +38760,7 @@ var WorkspaceDetailView = ({
38698
38760
  data: workspace.hourly_action_counts || [],
38699
38761
  pphThreshold: workspace.pph_threshold || 0,
38700
38762
  shiftStart: workspace.shift_start || "",
38763
+ shiftEnd: workspace.shift_end,
38701
38764
  showIdleTime,
38702
38765
  idleTimeHourly: workspace.idle_time_hourly
38703
38766
  }
@@ -38816,6 +38879,7 @@ var WorkspaceDetailView = ({
38816
38879
  data: workspace.hourly_action_counts || [],
38817
38880
  pphThreshold: workspace.pph_threshold || 0,
38818
38881
  shiftStart: workspace.shift_start || "",
38882
+ shiftEnd: workspace.shift_end,
38819
38883
  showIdleTime,
38820
38884
  idleTimeHourly: workspace.idle_time_hourly
38821
38885
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optifye/dashboard-core",
3
- "version": "6.5.6",
3
+ "version": "6.5.7",
4
4
  "description": "Reusable UI & logic for Optifye dashboard",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",