feat(dashboard): integrate new dashboard queries and refactor closing soon component

- Replaced TTenderDetails with TDashboardClosingSoonItem in the ClosingSoonCard component for better type accuracy.
- Removed the fake-data.ts file as it is no longer needed with the new dashboard queries.
- Introduced new hooks for fetching dashboard data, including summary, trend, countries, notice types, and closing soon items.
- Updated useDashboardData to utilize the new dashboard queries, enhancing data retrieval and management.
- Enhanced the API service layer with new endpoints for dashboard functionalities, improving overall architecture.
This commit is contained in:
AmirReza Jamali
2026-05-20 13:01:36 +03:30
parent d7a3db07ab
commit f080d51e63
14 changed files with 310 additions and 313 deletions
+74
View File
@@ -0,0 +1,74 @@
import api from "../axios";
import { API_ENDPOINTS } from "../endpoints";
import {
ApiResponse,
TDashboardClosingSoon,
TDashboardCountries,
TDashboardNoticeTypes,
TDashboardSummary,
TDashboardTrend,
} from "../types";
export const dashboardService = {
summary: async (params?: {
closing_window?: number;
}): Promise<ApiResponse<TDashboardSummary>> => {
try {
return (await api.get(API_ENDPOINTS.DASHBOARD.SUMMARY, { params })).data;
} catch (error) {
console.error("ERROR caught in Dashboard Service => summary:", error);
throw error;
}
},
trend: async (params?: {
days?: number;
metric?: "created" | "published" | "awarded";
}): Promise<ApiResponse<TDashboardTrend>> => {
try {
return (await api.get(API_ENDPOINTS.DASHBOARD.TREND, { params })).data;
} catch (error) {
console.error("ERROR caught in Dashboard Service => trend:", error);
throw error;
}
},
countries: async (params?: {
limit?: number;
}): Promise<ApiResponse<TDashboardCountries>> => {
try {
return (await api.get(API_ENDPOINTS.DASHBOARD.COUNTRIES, { params })).data;
} catch (error) {
console.error("ERROR caught in Dashboard Service => countries:", error);
throw error;
}
},
noticeTypes: async (): Promise<ApiResponse<TDashboardNoticeTypes>> => {
try {
return (await api.get(API_ENDPOINTS.DASHBOARD.NOTICE_TYPES)).data;
} catch (error) {
console.error(
"ERROR caught in Dashboard Service => notice-types:",
error,
);
throw error;
}
},
closingSoon: async (params?: {
limit?: number;
window?: number;
}): Promise<ApiResponse<TDashboardClosingSoon>> => {
try {
return (await api.get(API_ENDPOINTS.DASHBOARD.CLOSING_SOON, { params }))
.data;
} catch (error) {
console.error(
"ERROR caught in Dashboard Service => closing-soon:",
error,
);
throw error;
}
},
};
+1
View File
@@ -1,4 +1,5 @@
export * from "./companies-service";
export * from "./dashboard-service";
export * from "./inquiries-service";
export * from "./profile-service";
export * from "./tenders-service";