mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-26 00:05:45 +00:00
refactor(FE-335): Rename expedition HPP types and update usages
This commit is contained in:
@@ -5,24 +5,20 @@ import { ColumnDef } from '@tanstack/react-table';
|
|||||||
import Table from '@/components/Table';
|
import Table from '@/components/Table';
|
||||||
import Card from '@/components/Card';
|
import Card from '@/components/Card';
|
||||||
import { formatCurrency } from '@/lib/helper';
|
import { formatCurrency } from '@/lib/helper';
|
||||||
import {
|
import { BaseHppExpedition, BaseExpeditionCost } from '@/types/api/closing';
|
||||||
BaseClosingCostOfRevenueExpedition,
|
|
||||||
BaseCostOfRevenueExpedition,
|
|
||||||
} from '@/types/api/closing';
|
|
||||||
|
|
||||||
interface CostOfRevenueExpeditionReportTableProps {
|
interface CostOfRevenueExpeditionReportTableProps {
|
||||||
type?: 'detail';
|
type?: 'detail';
|
||||||
initialValues?: BaseClosingCostOfRevenueExpedition;
|
initialValues?: BaseHppExpedition;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CostOfRevenueExpeditionReportTable = ({
|
const CostOfRevenueExpeditionReportTable = ({
|
||||||
type = 'detail',
|
type = 'detail',
|
||||||
initialValues,
|
initialValues,
|
||||||
}: CostOfRevenueExpeditionReportTableProps) => {
|
}: CostOfRevenueExpeditionReportTableProps) => {
|
||||||
const costOfRevenueExpeditionData: BaseCostOfRevenueExpedition[] =
|
const costOfRevenueExpeditionData: BaseExpeditionCost[] = useMemo(() => {
|
||||||
useMemo(() => {
|
return initialValues?.expedition_costs || [];
|
||||||
return initialValues?.expedition_costs || [];
|
}, [initialValues]);
|
||||||
}, [initialValues]);
|
|
||||||
|
|
||||||
const totals = useMemo(() => {
|
const totals = useMemo(() => {
|
||||||
const totalHpp = initialValues?.total_hpp_amount || 0;
|
const totalHpp = initialValues?.total_hpp_amount || 0;
|
||||||
@@ -32,7 +28,7 @@ const CostOfRevenueExpeditionReportTable = ({
|
|||||||
};
|
};
|
||||||
}, [initialValues]);
|
}, [initialValues]);
|
||||||
|
|
||||||
const costOfRevenueExpeditionColumns: ColumnDef<BaseCostOfRevenueExpedition>[] =
|
const costOfRevenueExpeditionColumns: ColumnDef<BaseExpeditionCost>[] =
|
||||||
useMemo(
|
useMemo(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
ClosingOutgoingSapronak,
|
ClosingOutgoingSapronak,
|
||||||
ClosingOverhead,
|
ClosingOverhead,
|
||||||
ClosingSapronakCalculation,
|
ClosingSapronakCalculation,
|
||||||
ClosingCostOfRevenueExpedition,
|
ClosingHppExpedition,
|
||||||
} from '@/types/api/closing';
|
} from '@/types/api/closing';
|
||||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
@@ -198,20 +198,16 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
|||||||
|
|
||||||
async getHppEkspedisi(
|
async getHppEkspedisi(
|
||||||
id: number
|
id: number
|
||||||
): Promise<BaseApiResponse<ClosingCostOfRevenueExpedition> | undefined> {
|
): Promise<BaseApiResponse<ClosingHppExpedition> | undefined> {
|
||||||
try {
|
try {
|
||||||
const getHppEkspedisiPath = `${this.basePath}/${id}/expedition-hpp`;
|
const getHppEkspedisiPath = `${this.basePath}/${id}/expedition-hpp`;
|
||||||
const getHppEkspedisiRes =
|
const getHppEkspedisiRes =
|
||||||
await httpClient<BaseApiResponse<ClosingCostOfRevenueExpedition>>(
|
await httpClient<BaseApiResponse<ClosingHppExpedition>>(
|
||||||
getHppEkspedisiPath
|
getHppEkspedisiPath
|
||||||
);
|
);
|
||||||
return getHppEkspedisiRes;
|
return getHppEkspedisiRes;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (
|
if (axios.isAxiosError<BaseApiResponse<ClosingHppExpedition>>(error)) {
|
||||||
axios.isAxiosError<BaseApiResponse<ClosingCostOfRevenueExpedition>>(
|
|
||||||
error
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return error.response?.data;
|
return error.response?.data;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
Vendored
+4
-8
@@ -143,19 +143,15 @@ export type OverheadTotal = {
|
|||||||
cost_per_bird: number;
|
cost_per_bird: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BaseCostOfRevenueExpedition = {
|
export type BaseExpeditionCost = {
|
||||||
id: number;
|
id: number;
|
||||||
expedition_vendor_id: number;
|
|
||||||
expedition_vendor_name: string;
|
expedition_vendor_name: string;
|
||||||
qty: number;
|
|
||||||
unit_price: number;
|
|
||||||
hpp_amount: number;
|
hpp_amount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BaseClosingCostOfRevenueExpedition = {
|
export type BaseHppExpedition = {
|
||||||
expedition_costs: BaseCostOfRevenueExpedition[];
|
expedition_costs: BaseExpeditionCost[];
|
||||||
total_hpp_amount: number;
|
total_hpp_amount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ClosingCostOfRevenueExpedition = BaseMetadata &
|
export type ClosingHppExpedition = BaseMetadata & BaseHppExpedition;
|
||||||
BaseClosingCostOfRevenueExpedition;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user