refactor(tender-details): enhance translation and summary features
- Integrated language selection and translation functionality in TenderDetails, allowing users to choose display language and translate tender metadata. - Added AI summary section to display overall summary of the tender. - Updated API service to support translation requests and handle responses effectively. - Improved pagination handling in AdminsTable for better user experience. - Refactored various components to ensure consistent data flow and state management.
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
import api from "../axios";
|
||||
import { API_ENDPOINTS } from "../endpoints";
|
||||
import { ApiResponse } from "../types";
|
||||
import { TTenderDetails, TTenderResponse } from "../types/Tenders";
|
||||
import {
|
||||
TTenderDetails,
|
||||
TTenderResponse,
|
||||
TTenderTranslationResponse,
|
||||
} from "../types/Tenders";
|
||||
|
||||
export const tendersService = {
|
||||
tendersList: async (
|
||||
@@ -14,9 +18,12 @@ export const tendersService = {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
tenderDetails: async (id: string): Promise<ApiResponse<TTenderDetails>> => {
|
||||
tenderDetails: async (
|
||||
id: string,
|
||||
params?: Record<string, any>,
|
||||
): Promise<ApiResponse<TTenderDetails>> => {
|
||||
try {
|
||||
return (await api.get(API_ENDPOINTS.TENDERS.DETAILS(id))).data;
|
||||
return (await api.get(API_ENDPOINTS.TENDERS.DETAILS(id), { params })).data;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
"ERROR caught in Tender Service => tender details: ",
|
||||
@@ -25,4 +32,22 @@ export const tendersService = {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
translateTender: async ({
|
||||
id,
|
||||
language,
|
||||
}: {
|
||||
id: string;
|
||||
language: string;
|
||||
}): Promise<ApiResponse<TTenderTranslationResponse>> => {
|
||||
try {
|
||||
return (
|
||||
await api.post(API_ENDPOINTS.TENDERS.AI_TRANSLATE(id), {
|
||||
language,
|
||||
})
|
||||
).data;
|
||||
} catch (error) {
|
||||
console.error("ERROR caught in Tender Service => translate tender: ", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user