mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-316): Use population instead of available_quantity
This commit is contained in:
@@ -4,11 +4,11 @@ import * as XLSX from 'xlsx';
|
||||
import { ProjectFlockKandangLookup } from '@/types/api/production/project-flock';
|
||||
|
||||
export const generateUniformityTemplate = (
|
||||
availableQuantity: number,
|
||||
population: number,
|
||||
projectFlockKandangLookup: ProjectFlockKandangLookup
|
||||
) => {
|
||||
try {
|
||||
const sampleSize = Math.round(availableQuantity * 0.02);
|
||||
const sampleSize = Math.round(population * 0.02);
|
||||
const kandangName = projectFlockKandangLookup.kandang?.name || 'Kandang';
|
||||
const flockName = projectFlockKandangLookup.project_flock?.flock_name || '';
|
||||
const flockPeriod = projectFlockKandangLookup.project_flock?.period || 1;
|
||||
@@ -23,7 +23,7 @@ export const generateUniformityTemplate = (
|
||||
['Nama Flock', flockName],
|
||||
['Periode', flockPeriod],
|
||||
['Kandang', kandangName],
|
||||
['Total Populasi', formatNumber(availableQuantity)],
|
||||
['Total Populasi', formatNumber(population)],
|
||||
['Jumlah Sampel (2%)', formatNumber(sampleSize)],
|
||||
[''],
|
||||
['CARA PENGISIAN:'],
|
||||
@@ -95,7 +95,7 @@ export const generateUniformityTemplate = (
|
||||
XLSX.writeFile(workbook, filename);
|
||||
|
||||
toast.success(
|
||||
`Template berhasil dibuat dengan ${formatNumber(sampleSize)} baris data (2% dari ${formatNumber(availableQuantity)} populasi).`
|
||||
`Template berhasil dibuat dengan ${formatNumber(sampleSize)} baris data (2% dari ${formatNumber(population)} populasi).`
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Error generating uniformity template:', error);
|
||||
|
||||
@@ -370,14 +370,14 @@ const UniformityForm = ({
|
||||
}, [formik]);
|
||||
|
||||
const handleDownloadTemplate = useCallback(() => {
|
||||
const availableQuantity = projectFlockKandangLookup?.available_quantity;
|
||||
const population = projectFlockKandangLookup?.population;
|
||||
|
||||
if (!availableQuantity || !projectFlockKandangLookup) {
|
||||
if (!population || !projectFlockKandangLookup) {
|
||||
toast.error('Silakan pilih Project Flock dan Kandang terlebih dahulu.');
|
||||
return;
|
||||
}
|
||||
|
||||
generateUniformityTemplate(availableQuantity, projectFlockKandangLookup);
|
||||
generateUniformityTemplate(population, projectFlockKandangLookup);
|
||||
}, [projectFlockKandangLookup]);
|
||||
|
||||
// ===== SIDE EFFECTS =====
|
||||
@@ -623,13 +623,13 @@ const UniformityForm = ({
|
||||
Choose file to upload
|
||||
</span>
|
||||
<span className='text-xs font-light text-[#18181B80] text-center max-w-xs px-4'>
|
||||
{projectFlockKandangLookup?.available_quantity
|
||||
? `Jumlah data yang dibutuhkan: ${formatNumber(Math.round(projectFlockKandangLookup.available_quantity * 0.02))} (2% dari ${formatNumber(projectFlockKandangLookup.available_quantity)} populasi).`
|
||||
{projectFlockKandangLookup?.population
|
||||
? `Jumlah data yang dibutuhkan: ${formatNumber(Math.round(projectFlockKandangLookup.population * 0.02))} (2% dari ${formatNumber(projectFlockKandangLookup.population)} populasi).`
|
||||
: 'Upload data file (*.xlsx)'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{projectFlockKandangLookup?.available_quantity && (
|
||||
{projectFlockKandangLookup?.population && (
|
||||
<>
|
||||
<div className='flex items-center justify-center gap-2 py-4'>
|
||||
<div className='h-px bg-[#18181B33] w-8'></div>
|
||||
|
||||
+1
@@ -69,6 +69,7 @@ export type ProjectFlockKandangLookup = {
|
||||
project_flock: ProjectFlock;
|
||||
quantity: number;
|
||||
available_quantity?: number;
|
||||
population: number;
|
||||
};
|
||||
|
||||
export type ProjectFlockAvailableQuantity = {
|
||||
|
||||
Reference in New Issue
Block a user