add feed out to manual input form
This commit is contained in:
1 parent
c45b6656ae
commit
41905078df
5 files changed
+26
-1
No files matched your search
@@ -19,6 +19,7 @@ type FormState = {
|
||||
mortality_manual: number;
|
||||
feed_in_manual: number;
|
||||
feed_use_manual: number;
|
||||
feed_out_manual: number;
|
||||
harvest_manual: number;
|
||||
harvest_weight_manual: number;
|
||||
manual_weight: number;
|
||||
@@ -30,6 +31,7 @@ const emptyForm = (currentDay: number): FormState => ({
|
||||
mortality_manual: 0,
|
||||
feed_in_manual: 0,
|
||||
feed_use_manual: 0,
|
||||
feed_out_manual: 0,
|
||||
harvest_manual: 0,
|
||||
harvest_weight_manual: 0,
|
||||
manual_weight: 0,
|
||||
@@ -42,6 +44,7 @@ function toForm(row: ManualInput): FormState {
|
||||
mortality_manual: row.mortality_manual,
|
||||
feed_in_manual: row.feed_in_manual,
|
||||
feed_use_manual: row.feed_use_manual,
|
||||
feed_out_manual: row.feed_out_manual,
|
||||
harvest_manual: row.harvest_manual,
|
||||
// Database dalam gram, form selalu dalam kg.
|
||||
harvest_weight_manual: row.harvest_weight_manual / 1000,
|
||||
@@ -121,6 +124,7 @@ const DashboardManualInputForm: React.FC<Props> = ({ cycleId, currentDay, readOn
|
||||
mortality_manual: form.mortality_manual,
|
||||
feed_in_manual: form.feed_in_manual,
|
||||
feed_use_manual: form.feed_use_manual,
|
||||
feed_out_manual: form.feed_out_manual,
|
||||
harvest_manual: form.harvest_manual,
|
||||
// Form dalam kg, disimpan ke database dalam gram.
|
||||
harvest_weight_manual: form.harvest_weight_manual * 1000,
|
||||
@@ -201,6 +205,16 @@ const DashboardManualInputForm: React.FC<Props> = ({ cycleId, currentDay, readOn
|
||||
onChange={(e) => setForm((f) => ({ ...f, feed_use_manual: Number(e.target.value) }))}
|
||||
/>
|
||||
</label>
|
||||
<label className="block text-sm">
|
||||
Karung keluar
|
||||
<input
|
||||
type="number"
|
||||
className={`${inputClass} mt-1`}
|
||||
value={form.feed_out_manual}
|
||||
disabled={readOnly}
|
||||
onChange={(e) => setForm((f) => ({ ...f, feed_out_manual: Number(e.target.value) }))}
|
||||
/>
|
||||
</label>
|
||||
<label className="block text-sm">
|
||||
Panen (ekor)
|
||||
<input
|
||||
@@ -240,7 +254,8 @@ const DashboardManualInputForm: React.FC<Props> = ({ cycleId, currentDay, readOn
|
||||
<p className="text-xs text-gray-500">
|
||||
Total mortalitas {formatNumber(saved.mortality_manual_total, 0)} · karung masuk{' '}
|
||||
{formatNumber(saved.feed_in_manual_total, 0)} · karung tuang{' '}
|
||||
{formatNumber(saved.feed_use_manual_total, 0)} · panen{' '}
|
||||
{formatNumber(saved.feed_use_manual_total, 0)} · karung keluar{' '}
|
||||
{formatNumber(saved.feed_out_manual_total, 0)} · panen{' '}
|
||||
{formatNumber(saved.harvest_manual_total, 0)} · berat panen{' '}
|
||||
{formatNumber(saved.harvest_weight_manual_total / 1000, 2)} kg
|
||||
</p>
|
||||
|
||||
@@ -38,8 +38,10 @@ describe('DashboardManualInputForm', () => {
|
||||
mortality_manual_total: 5,
|
||||
feed_in_manual: 8,
|
||||
feed_use_manual: 12,
|
||||
feed_out_manual: 3,
|
||||
feed_in_manual_total: 8,
|
||||
feed_use_manual_total: 12,
|
||||
feed_out_manual_total: 3,
|
||||
harvest_manual: 0,
|
||||
harvest_manual_total: 0,
|
||||
harvest_weight_manual: 0,
|
||||
@@ -60,6 +62,7 @@ describe('DashboardManualInputForm', () => {
|
||||
fireEvent.change(screen.getByLabelText(/Mortalitas/i), { target: { value: '5' } });
|
||||
fireEvent.change(screen.getByLabelText(/Karung masuk/i), { target: { value: '8' } });
|
||||
fireEvent.change(screen.getByLabelText(/Karung tuang/i), { target: { value: '12' } });
|
||||
fireEvent.change(screen.getByLabelText(/Karung keluar/i), { target: { value: '3' } });
|
||||
fireEvent.change(screen.getByLabelText(/Berat panen/i), { target: { value: '8.5' } });
|
||||
expect(screen.getByLabelText(/Berat panen/i)).toHaveAttribute('step', '0.01');
|
||||
fireEvent.click(screen.getByRole('button', { name: /Simpan/i }));
|
||||
@@ -72,6 +75,7 @@ describe('DashboardManualInputForm', () => {
|
||||
mortality_manual: 5,
|
||||
feed_in_manual: 8,
|
||||
feed_use_manual: 12,
|
||||
feed_out_manual: 3,
|
||||
harvest_weight_manual: 8500,
|
||||
});
|
||||
expect(body).not.toHaveProperty('mortality_manual_total');
|
||||
|
||||
Reference in new issue
Block a user