fix doc weight to show real doc instead of forcing 35-51 range and also fixed bug target weight using total days as reference for target weight instead of doc weight

This commit is contained in:
Alberto-Audrix committed 2026-09-07 10:43:54 +07:00
1 parent 4439e3b7b1
commit 75eb218558
8 files changed
+76 -34

No files matched your search

+4 -4
View File
@@ -17,7 +17,7 @@ import { formatWeight, getTargetGainForAge } from '../../utils/weight.ts';
interface DailyWeightGainChartProps {
rows: ChickenWeight[];
totalDays: number;
docWeight: number;
}
type GainStatus = 'above' | 'near' | 'below' | 'none';
@@ -30,11 +30,11 @@ type ChartPoint = {
status: GainStatus;
};
const DailyWeightGainChart: React.FC<DailyWeightGainChartProps> = ({ rows, totalDays }) => {
const DailyWeightGainChart: React.FC<DailyWeightGainChartProps> = ({ rows, docWeight }) => {
const chartData = useMemo<ChartPoint[]>(
() =>
[...rows].reverse().map((row) => {
const targetGain = getTargetGainForAge(row.age, totalDays);
const targetGain = getTargetGainForAge(row.age, docWeight);
const gain = row.average_daily_gain;
let status: GainStatus = 'none';
if (gain != null && targetGain != null) {
@@ -45,7 +45,7 @@ const DailyWeightGainChart: React.FC<DailyWeightGainChartProps> = ({ rows, total
}
return { day: row.age, date: row.date, gain, targetGain, status };
}),
[rows, totalDays]
[rows, docWeight]
);
const hasNoData = chartData.length === 0;