52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
import React from 'react';
|
|
import type { Cycle } from '../../types/api.ts';
|
|
import InitialBalanceComparison from './InitialBalanceComparison.tsx';
|
|
|
|
interface InitialBalanceCardProps {
|
|
cycle: Cycle;
|
|
}
|
|
|
|
const InitialBalanceCard: React.FC<InitialBalanceCardProps> = ({ cycle }) => {
|
|
const hasBalance =
|
|
cycle.feed_initial_balance > 0 || Boolean(cycle.feed_initial_balance_date);
|
|
const balanceDate = cycle.feed_initial_balance_date ?? cycle.start_date;
|
|
|
|
return (
|
|
<div className="bg-gradient-to-br from-blue-50 to-indigo-50 p-6 rounded-xl shadow-sm border-2 border-blue-200">
|
|
<div className="flex items-center gap-3 mb-4">
|
|
<div className="bg-blue-500 text-white p-3 rounded-lg">
|
|
<i className="fa-solid fa-boxes-packing text-2xl"></i>
|
|
</div>
|
|
<div>
|
|
<h2 className="text-xl font-bold text-gray-800">Saldo Awal</h2>
|
|
<p className="text-sm text-gray-600">
|
|
Saldo awal karung pakan dari site dashboard (mirror sync).
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="bg-white rounded-lg p-6 border border-blue-200">
|
|
{!hasBalance ? (
|
|
<p className="text-sm text-gray-600">Belum ada saldo awal tersimpan untuk siklus ini.</p>
|
|
) : (
|
|
<>
|
|
<p className="text-sm text-gray-600 mb-1">
|
|
Tanggal:{' '}
|
|
<strong className="text-gray-800">{balanceDate}</strong>
|
|
</p>
|
|
<InitialBalanceComparison
|
|
date={balanceDate}
|
|
manual={cycle.feed_initial_balance}
|
|
iot={cycle.feed_initial_balance_iot ?? null}
|
|
accuracy={cycle.feed_initial_balance_accuracy ?? null}
|
|
syncError={cycle.feed_initial_balance_sync_error ?? null}
|
|
/>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default InitialBalanceCard;
|