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

+3 -3
View File
@@ -5,7 +5,7 @@ import { formatWeight, getTargetWeightForAge } from '../../utils/weight.ts';
interface DailyDetailPanelProps {
row: ChickenWeight | null;
totalDays: number;
docWeight: number;
}
const DetailCard: React.FC<{
@@ -29,7 +29,7 @@ const DetailCard: React.FC<{
</div>
);
const DailyDetailPanel: React.FC<DailyDetailPanelProps> = ({ row, totalDays }) => {
const DailyDetailPanel: React.FC<DailyDetailPanelProps> = ({ row, docWeight }) => {
if (!row) {
return (
<div className="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
@@ -44,7 +44,7 @@ const DailyDetailPanel: React.FC<DailyDetailPanelProps> = ({ row, totalDays }) =
);
}
const target = getTargetWeightForAge(row.age, totalDays);
const target = getTargetWeightForAge(row.age, docWeight);
const deviation = target != null && row.average_weight > 0 ? row.average_weight - target : null;
return (
+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;
@@ -14,7 +14,7 @@ import { formatWeight, getTargetWeightForAge } from '../../utils/weight.ts';
interface DailyWeightProgressionChartProps {
rows: ChickenWeight[];
totalDays: number;
docWeight: number;
}
type ChartPoint = {
@@ -27,7 +27,7 @@ type ChartPoint = {
const DailyWeightProgressionChart: React.FC<DailyWeightProgressionChartProps> = ({
rows,
totalDays,
docWeight,
}) => {
const chartData = useMemo<ChartPoint[]>(
() =>
@@ -35,10 +35,10 @@ const DailyWeightProgressionChart: React.FC<DailyWeightProgressionChartProps> =
day: row.age,
date: row.date,
actual: row.average_weight,
target: getTargetWeightForAge(row.age, totalDays),
target: getTargetWeightForAge(row.age, docWeight),
chickenCount: row.chicken_count,
})),
[rows, totalDays]
[rows, docWeight]
);
const hasNoData = chartData.length === 0;
+3 -3
View File
@@ -35,11 +35,11 @@ const StatItem: React.FC<{
interface WeightStatsProps {
latest: LatestAvg | null;
totalDays: number;
docWeight: number;
}
const WeightStats: React.FC<WeightStatsProps> = ({ latest, totalDays }) => {
const target = latest ? getTargetWeightForAge(latest.age, totalDays) : null;
const WeightStats: React.FC<WeightStatsProps> = ({ latest, docWeight }) => {
const target = latest ? getTargetWeightForAge(latest.age, docWeight) : null;
return (
<div className="bg-white p-6 rounded-xl shadow-sm h-full">