mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu
This commit is contained in:
@@ -5,21 +5,27 @@ import { cn, formatCurrency, formatDate, formatNumber } from '@/lib/helper';
|
|||||||
import { ClosingApi } from '@/services/api/closing';
|
import { ClosingApi } from '@/services/api/closing';
|
||||||
import { Overhead, OverheadTotal } from '@/types/api/closing';
|
import { Overhead, OverheadTotal } from '@/types/api/closing';
|
||||||
import { ColumnDef } from '@tanstack/react-table';
|
import { ColumnDef } from '@tanstack/react-table';
|
||||||
|
import { useSearchParams } from 'next/navigation';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
|
|
||||||
interface ClosingOverheadTableProps {
|
interface ClosingOverheadTableProps {
|
||||||
type?: 'detail';
|
|
||||||
projectFlockId: number;
|
projectFlockId: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ClosingOverheadTable = ({
|
const ClosingOverheadTable = ({
|
||||||
type,
|
|
||||||
projectFlockId,
|
projectFlockId,
|
||||||
}: ClosingOverheadTableProps) => {
|
}: ClosingOverheadTableProps) => {
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
const kandangId = searchParams.get('kandangId');
|
||||||
|
|
||||||
const { data: overhead, isLoading: isLoadingOverhead } = useSWR(
|
const { data: overhead, isLoading: isLoadingOverhead } = useSWR(
|
||||||
`${ClosingApi.basePath}/${projectFlockId}/overhead`,
|
`${ClosingApi.basePath}/${projectFlockId}${kandangId ? `/${kandangId}` : ''}/overhead`,
|
||||||
() => ClosingApi.getOverhead(projectFlockId),
|
() =>
|
||||||
|
ClosingApi.getOverhead(
|
||||||
|
projectFlockId,
|
||||||
|
kandangId ? Number(kandangId) : undefined
|
||||||
|
),
|
||||||
{
|
{
|
||||||
keepPreviousData: true,
|
keepPreviousData: true,
|
||||||
}
|
}
|
||||||
@@ -148,6 +154,7 @@ const ClosingOverheadTable = ({
|
|||||||
'whitespace-nowrap'
|
'whitespace-nowrap'
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
|
isLoading={isLoadingOverhead}
|
||||||
renderFooter={
|
renderFooter={
|
||||||
isResponseSuccess(overhead)
|
isResponseSuccess(overhead)
|
||||||
? overhead.data?.overheads.length > 0
|
? overhead.data?.overheads.length > 0
|
||||||
|
|||||||
@@ -131,10 +131,11 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getOverhead(
|
async getOverhead(
|
||||||
id: number
|
id: number,
|
||||||
|
kandangId?: number
|
||||||
): Promise<BaseApiResponse<ClosingOverhead> | undefined> {
|
): Promise<BaseApiResponse<ClosingOverhead> | undefined> {
|
||||||
try {
|
try {
|
||||||
const path = `${this.basePath}/${id}/overhead`;
|
const path = `${this.basePath}/${id}${kandangId ? `/${kandangId}` : ''}/overhead`;
|
||||||
return await httpClient<BaseApiResponse<ClosingOverhead>>(path, {
|
return await httpClient<BaseApiResponse<ClosingOverhead>>(path, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user