Files
dashboard/components/mobile/MultiCoopWeightScreen.tsx
Alberto-Audrix 32a36cceff
CI / lint-and-test (push) Canceled after 0s
first commit
2026-07-28 08:55:05 +07:00

67 lines
2.4 KiB
TypeScript

import React from 'react';
import { Screen, MultiCoopWeightSummary } from '../../types.ts';
import { MobileBottomNav } from './MobileLayout.tsx';
import { BarChart, Bar, XAxis, YAxis, ResponsiveContainer, Cell } from 'recharts';
interface MultiCoopWeightScreenProps {
onNavigate: (screen: Screen) => void;
summaryData: MultiCoopWeightSummary[];
}
const MultiCoopWeightScreen: React.FC<MultiCoopWeightScreenProps> = ({
onNavigate,
summaryData,
}) => {
return (
<div className="bg-gray-50 h-full">
<div className="p-3 pt-8 h-full overflow-y-auto pb-16">
<h1 className="text-xl font-bold text-gray-800 mb-4">Perbandingan Bobot Kandang</h1>
<div className="bg-white p-3 rounded-lg shadow-sm">
<p className="text-xs font-bold text-gray-600 mb-1">Bobot Rata-rata (gram)</p>
<div className="h-40">
<ResponsiveContainer width="100%" height="100%">
<BarChart data={summaryData} margin={{ top: 5, right: 0, left: -25, bottom: 0 }}>
<XAxis dataKey="coopName" fontSize={10} tick={{ fill: '#6b7280' }} />
<YAxis fontSize={10} tick={{ fill: '#6b7280' }} />
<Bar dataKey="currentWeight">
{summaryData.map((entry) => (
<Cell key={entry.coopId} fill={entry.deviation >= 0 ? '#16a34a' : '#ef4444'} />
))}
</Bar>
</BarChart>
</ResponsiveContainer>
</div>
</div>
<div className="space-y-2 mt-4">
{summaryData.map((coop) => (
<div
key={coop.coopId}
className="bg-white p-2 rounded-lg shadow-sm grid grid-cols-3 text-center text-xs"
>
<p className="font-bold text-left col-span-1">{coop.coopName}</p>
<div>
<p className="text-gray-500">ADG</p>
<p className="font-semibold">{coop.adg}g</p>
</div>
<div>
<p className="text-gray-500">Deviasi</p>
<p
className={`font-semibold ${coop.deviation >= 0 ? 'text-green-600' : 'text-red-600'}`}
>
{coop.deviation >= 0 ? '+' : ''}
{coop.deviation}g
</p>
</div>
</div>
))}
</div>
</div>
<MobileBottomNav active="reports" onNavigate={onNavigate} />
</div>
);
};
export default MultiCoopWeightScreen;