mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
fix(FE): remove pullet table, change doc table to conditional data base on project flock category
This commit is contained in:
@@ -13,15 +13,16 @@ import { useMemo } from 'react';
|
||||
import useSWR from 'swr';
|
||||
import { ClosingApi } from '@/services/api/closing';
|
||||
import { isResponseSuccess } from '@/lib/api-helper';
|
||||
import { ClosingGeneralInformation } from '@/types/api/closing';
|
||||
|
||||
interface ClosingSapronakCalculationTableProps {
|
||||
type?: 'detail';
|
||||
projectFlockId: number;
|
||||
closingGeneralInformation?: ClosingGeneralInformation;
|
||||
}
|
||||
|
||||
const ClosingSapronakCalculationTable = ({
|
||||
type,
|
||||
projectFlockId,
|
||||
closingGeneralInformation,
|
||||
}: ClosingSapronakCalculationTableProps) => {
|
||||
const { data: sapronakCalculation, isLoading } = useSWR(
|
||||
`/closing/sapronak-calculation/${projectFlockId}`,
|
||||
@@ -182,8 +183,13 @@ const ClosingSapronakCalculationTable = ({
|
||||
|
||||
return (
|
||||
<div className='flex flex-col gap-4'>
|
||||
{/* Table DOC jika kategori Project Flock Growing */}
|
||||
<Card
|
||||
title='DOC'
|
||||
title={
|
||||
closingGeneralInformation?.project_category === 'GROWING'
|
||||
? 'DOC'
|
||||
: 'Pullet'
|
||||
}
|
||||
collapsible
|
||||
defaultCollapsed={false}
|
||||
className={{
|
||||
@@ -194,10 +200,16 @@ const ClosingSapronakCalculationTable = ({
|
||||
<Table<RowSapronakCalculation>
|
||||
data={
|
||||
isResponseSuccess(sapronakCalculation)
|
||||
? (sapronakCalculation.data?.doc?.rows ?? [])
|
||||
? ((closingGeneralInformation?.project_category === 'GROWING'
|
||||
? sapronakCalculation.data?.doc?.rows
|
||||
: sapronakCalculation.data?.pullet?.rows) ?? [])
|
||||
: []
|
||||
}
|
||||
columns={docColumns}
|
||||
columns={
|
||||
closingGeneralInformation?.project_category === 'GROWING'
|
||||
? docColumns
|
||||
: pulletColumns
|
||||
}
|
||||
className={{
|
||||
containerClassName: 'my-4',
|
||||
}}
|
||||
@@ -250,29 +262,6 @@ const ClosingSapronakCalculationTable = ({
|
||||
renderFooter={isResponseSuccess(sapronakCalculation)}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
title='Pullet'
|
||||
variant='bordered'
|
||||
collapsible
|
||||
defaultCollapsed={true}
|
||||
className={{
|
||||
wrapper: 'w-full',
|
||||
}}
|
||||
>
|
||||
<Table<RowSapronakCalculation>
|
||||
data={
|
||||
isResponseSuccess(sapronakCalculation)
|
||||
? (sapronakCalculation.data?.pullet?.rows ?? [])
|
||||
: []
|
||||
}
|
||||
columns={pulletColumns}
|
||||
className={{
|
||||
containerClassName: 'my-4',
|
||||
}}
|
||||
renderFooter={isResponseSuccess(sapronakCalculation)}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user