Some checks failed
CI/CD Pipeline - Xpeditis PreProd / Backend - Build & Test (push) Failing after 5m51s
CI/CD Pipeline - Xpeditis PreProd / Backend - Docker Build & Push (push) Has been skipped
CI/CD Pipeline - Xpeditis PreProd / Frontend - Build & Test (push) Successful in 10m57s
CI/CD Pipeline - Xpeditis PreProd / Frontend - Docker Build & Push (push) Failing after 12m28s
CI/CD Pipeline - Xpeditis PreProd / Deploy to PreProd Server (push) Has been skipped
CI/CD Pipeline - Xpeditis PreProd / Run Smoke Tests (push) Has been skipped
67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
/**
|
|
* Admin CSV Rates API Client
|
|
*
|
|
* ADMIN-only endpoints for managing CSV rate files
|
|
*/
|
|
|
|
import { get, post, del, upload } from '../client';
|
|
import type {
|
|
CsvRateUploadResponse,
|
|
SuccessResponse,
|
|
} from '@/types/api';
|
|
|
|
// TODO: These types should be moved to @/types/api.ts
|
|
export interface CsvFileInfo {
|
|
filename: string;
|
|
size: number;
|
|
uploadedAt: string;
|
|
rowCount?: number;
|
|
}
|
|
|
|
export interface CsvFileListResponse {
|
|
files: CsvFileInfo[];
|
|
}
|
|
|
|
/**
|
|
* Upload CSV rate file (ADMIN only)
|
|
* POST /api/v1/admin/csv-rates/upload
|
|
*/
|
|
export async function uploadCsvRates(formData: FormData): Promise<CsvRateUploadResponse> {
|
|
return upload<CsvRateUploadResponse>('/api/v1/admin/csv-rates/upload', formData);
|
|
}
|
|
|
|
/**
|
|
* List all CSV files
|
|
* GET /api/v1/admin/csv-rates/files
|
|
*/
|
|
export async function listCsvFiles(): Promise<CsvFileListResponse> {
|
|
return get<CsvFileListResponse>('/api/v1/admin/csv-rates/files');
|
|
}
|
|
|
|
/**
|
|
* Delete CSV file
|
|
* DELETE /api/v1/admin/csv-rates/files/:filename
|
|
*/
|
|
export async function deleteCsvFile(filename: string): Promise<SuccessResponse> {
|
|
return del<SuccessResponse>(`/api/v1/admin/csv-rates/files/${encodeURIComponent(filename)}`);
|
|
}
|
|
|
|
/**
|
|
* Get CSV file statistics
|
|
* GET /api/v1/admin/csv-rates/stats/:filename
|
|
*/
|
|
export async function getCsvFileStats(filename: string): Promise<any> {
|
|
return get<any>(`/api/v1/admin/csv-rates/stats/${encodeURIComponent(filename)}`);
|
|
}
|
|
|
|
/**
|
|
* Convert CSV format (FOB FRET to Standard)
|
|
* POST /api/v1/admin/csv-rates/convert
|
|
*/
|
|
export async function convertCsvFormat(data: {
|
|
sourceFile: string;
|
|
targetFormat: 'STANDARD';
|
|
}): Promise<any> {
|
|
return post<any>('/api/v1/admin/csv-rates/convert', data);
|
|
}
|