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