mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-21 05:45:46 +00:00
fix(FE): fix merge conflict
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
dummyGetPerhitunganSapronak,
|
||||
} from '@/dummy/closing.dummy';
|
||||
import { httpClient, httpClientFetcher } from '@/services/http/client';
|
||||
import { ClosingSales } from '@/types/api/closing';
|
||||
|
||||
export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
constructor(basePath: string) {
|
||||
@@ -57,6 +58,23 @@ export class ClosingApiService extends BaseApiService<Closing, null, null> {
|
||||
}
|
||||
}
|
||||
|
||||
async getPenjualan(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<ClosingSales> | undefined> {
|
||||
try {
|
||||
const getPenjualanPath = `${this.basePath}/${id}/penjualan`;
|
||||
const getPenjualanRes =
|
||||
await httpClient<BaseApiResponse<ClosingSales>>(getPenjualanPath);
|
||||
|
||||
return getPenjualanRes;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError<BaseApiResponse<ClosingSales>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async getAllIncomingSapronakFetcher(
|
||||
endpoint: string
|
||||
): Promise<BaseApiResponse<ClosingIncomingSapronak[]>> {
|
||||
|
||||
@@ -492,8 +492,8 @@ export class ExpenseApiService extends BaseApiService<
|
||||
});
|
||||
|
||||
formData.append(
|
||||
'cost_per_kandangs',
|
||||
JSON.stringify(payload.cost_per_kandangs)
|
||||
'expense_nonstocks',
|
||||
JSON.stringify(payload.expense_nonstocks)
|
||||
);
|
||||
|
||||
return formData;
|
||||
@@ -514,8 +514,8 @@ export class ExpenseApiService extends BaseApiService<
|
||||
});
|
||||
|
||||
formData.append(
|
||||
'cost_per_kandang',
|
||||
JSON.stringify(payload.cost_per_kandang)
|
||||
'expense_nonstocks',
|
||||
JSON.stringify(payload.expense_nonstocks)
|
||||
);
|
||||
|
||||
return formData;
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
CreateInventoryAdjustmentPayload,
|
||||
InventoryAdjustment,
|
||||
} from '@/types/api/inventory/adjustment';
|
||||
import { InventoryProduct } from '@/types/api/inventory/product';
|
||||
|
||||
export const ProductWarehouseApi = new BaseApiService<
|
||||
ProductWarehouse,
|
||||
@@ -25,8 +26,14 @@ export const MovementApi = new BaseApiService<
|
||||
unknown
|
||||
>('/inventory/transfers');
|
||||
|
||||
export const inventoryAdjustmentApi = new BaseApiService<
|
||||
export const InventoryAdjustmentApi = new BaseApiService<
|
||||
InventoryAdjustment,
|
||||
CreateInventoryAdjustmentPayload,
|
||||
unknown
|
||||
>('/inventory/adjustments');
|
||||
|
||||
export const InventoryProductApi = new BaseApiService<
|
||||
InventoryProduct,
|
||||
unknown,
|
||||
unknown
|
||||
>('/inventory/product-stocks');
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BaseApiService } from './base';
|
||||
import { BaseApiService } from '@/services/api/base';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import {
|
||||
CreateProjectFlockPayload,
|
||||
|
||||
@@ -2,10 +2,189 @@ import { BaseApiService } from '@/services/api/base';
|
||||
import {
|
||||
BaseProjectFlockKandang,
|
||||
ProjectFlockKandang,
|
||||
ClosingProjectFlockKandangPayload,
|
||||
CheckClosingResponse,
|
||||
} from '@/types/api/production/project-flock-kandang';
|
||||
import { BaseApiResponse } from '@/types/api/api-general';
|
||||
import { httpClient } from '@/services/http/client';
|
||||
import axios from 'axios';
|
||||
|
||||
export const ProjectFlockKandangApi = new BaseApiService<
|
||||
export class ProjectFlockKandangService extends BaseApiService<
|
||||
BaseProjectFlockKandang,
|
||||
ProjectFlockKandang,
|
||||
unknown
|
||||
>('project-flock-kandang');
|
||||
> {
|
||||
constructor(basePath: string = '') {
|
||||
super(basePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close or Unclose Project Flock Kandang
|
||||
*/
|
||||
async closing(
|
||||
id: number,
|
||||
payload: ClosingProjectFlockKandangPayload
|
||||
): Promise<BaseApiResponse<{ message: string }> | undefined> {
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/closing`;
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...(this.header ?? {}),
|
||||
};
|
||||
|
||||
return await httpClient<BaseApiResponse<{ message: string }>>(path, {
|
||||
method: 'POST',
|
||||
body: payload,
|
||||
headers,
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
if (axios.isAxiosError<BaseApiResponse<{ message: string }>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Closing Requirements for Project Flock Kandang
|
||||
* TODO: Replace with actual API call when backend is ready
|
||||
*/
|
||||
async checkClosing(
|
||||
id: number
|
||||
): Promise<BaseApiResponse<CheckClosingResponse> | undefined> {
|
||||
// Dummy data - replace with actual API call when backend is ready
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve({
|
||||
code: 200,
|
||||
status: 'success',
|
||||
message: 'Cek persyaratan closing kandang',
|
||||
data: {
|
||||
unfinished_expenses: 2,
|
||||
stock_remaining: [
|
||||
{
|
||||
id: 1,
|
||||
product_id: 1,
|
||||
warehouse_id: 1,
|
||||
quantity: 0,
|
||||
product: {
|
||||
id: 1,
|
||||
name: 'Pakan Starter',
|
||||
brand: 'Brand A',
|
||||
sku: 'PKN-STR-001',
|
||||
product_price: 15000,
|
||||
selling_price: 17000,
|
||||
tax: 0,
|
||||
expiry_period: 365,
|
||||
flags: ['active'],
|
||||
uom: {
|
||||
id: 1,
|
||||
name: 'Kg',
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
product_category: {
|
||||
id: 1,
|
||||
name: 'Pakan',
|
||||
code: 'PKN',
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
suppliers: [],
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
warehouse: {
|
||||
id: 1,
|
||||
name: 'Gudang Utama',
|
||||
type: 'AREA',
|
||||
area: {
|
||||
id: 1,
|
||||
name: 'Area 1',
|
||||
},
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2024-01-01',
|
||||
updated_at: '2024-01-01',
|
||||
},
|
||||
created_user: {
|
||||
id: 1,
|
||||
id_user: 1,
|
||||
email: 'admin@example.com',
|
||||
name: 'Admin User',
|
||||
},
|
||||
created_at: '2025-01-01',
|
||||
updated_at: '2025-01-01',
|
||||
},
|
||||
],
|
||||
expenses: [
|
||||
{
|
||||
id: 1,
|
||||
po_number: 'PO-BOP-LTI-00001',
|
||||
category: 'NON-BOP',
|
||||
total: 110000,
|
||||
status: 'SELESAI',
|
||||
step_name: 'Approval Finance',
|
||||
step: 5,
|
||||
reference_number: 'BOP-LTI-00001',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
po_number: 'PO-BOP-LTI-00003',
|
||||
category: 'BOP',
|
||||
total: 110000,
|
||||
status: 'SELESAI',
|
||||
step_name: 'Approval Finance',
|
||||
step: 5,
|
||||
reference_number: 'BOP-LTI-00003',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}, 500); // Simulate network delay
|
||||
});
|
||||
|
||||
/*
|
||||
// Original API call - uncomment when backend is ready
|
||||
try {
|
||||
const path = `${this.basePath}/${id}/closing/check`;
|
||||
|
||||
return await httpClient<BaseApiResponse<CheckClosingResponse>>(path, {
|
||||
method: 'GET',
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
if (axios.isAxiosError<BaseApiResponse<CheckClosingResponse>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
export const ProjectFlockKandangApi = new ProjectFlockKandangService(
|
||||
'/production/project-flock-kandangs'
|
||||
);
|
||||
|
||||
@@ -141,6 +141,38 @@ export class ProjectFlockService extends BaseApiService<
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resubmit Project Flock
|
||||
*/
|
||||
async resubmit(
|
||||
id: number,
|
||||
payload: UpdateProjectFlockPayload
|
||||
): Promise<BaseApiResponse<ProjectFlock> | undefined> {
|
||||
try {
|
||||
const updatePath = `${this.basePath}/${id}/resubmit`;
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
...(this.header ?? {}),
|
||||
};
|
||||
|
||||
const updateRes = await httpClient<BaseApiResponse<ProjectFlock>>(
|
||||
updatePath,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: payload,
|
||||
headers,
|
||||
}
|
||||
);
|
||||
return updateRes;
|
||||
} catch (error: unknown) {
|
||||
if (axios.isAxiosError<BaseApiResponse<ProjectFlock>>(error)) {
|
||||
return error.response?.data;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve single Project Flock
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,8 @@ import axios from 'axios';
|
||||
import type { AxiosError, AxiosRequestConfig } from 'axios';
|
||||
import { RequestOptions } from '@/services/http/base';
|
||||
|
||||
import { redirectToSSO } from '@/lib/auth-helper';
|
||||
|
||||
const BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL ?? '';
|
||||
const axiosClient = axios.create({ baseURL: BASE_URL, timeout: 10_000 });
|
||||
|
||||
@@ -9,8 +11,7 @@ axiosClient.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error: AxiosError) => {
|
||||
if (error.response?.status === 401) {
|
||||
const ssoLoginUrl = `${process.env.NEXT_PUBLIC_SSO_LOGIN_URL as string}?redirect_url=${window.location.href}`;
|
||||
window.location.href = ssoLoginUrl;
|
||||
redirectToSSO();
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
|
||||
Reference in New Issue
Block a user