diff --git a/src/app/api/reports/index.ts b/src/app/api/reports/index.ts index 797c530..dd1afb8 100644 --- a/src/app/api/reports/index.ts +++ b/src/app/api/reports/index.ts @@ -7,10 +7,12 @@ export interface FinancialStatusReportFilter { // - Project Cash Flow Report export interface ProjectCashFlowReportFilter { project: string[]; + dateType: string[]; } export interface ProjectCashFlowReportRequest { projectId: number; + dateType: string; } // - Monthly Work Hours Report diff --git a/src/app/utils/comboUtil.ts b/src/app/utils/comboUtil.ts index 0fcb75b..c0ce4bb 100644 --- a/src/app/utils/comboUtil.ts +++ b/src/app/utils/comboUtil.ts @@ -8,4 +8,9 @@ export const claimStatusCombo = [ "Waiting for Approval", "Approved", "Rejected" +] + +export const dateTypeCombo = [ + "Month", + "Date" ] \ No newline at end of file diff --git a/src/components/GenerateProjectCashFlowReport/GenerateProjectCashFlowReport.tsx b/src/components/GenerateProjectCashFlowReport/GenerateProjectCashFlowReport.tsx index e23888f..a1554b7 100644 --- a/src/components/GenerateProjectCashFlowReport/GenerateProjectCashFlowReport.tsx +++ b/src/components/GenerateProjectCashFlowReport/GenerateProjectCashFlowReport.tsx @@ -7,7 +7,7 @@ import { ProjectResult } from "@/app/api/projects"; import { ProjectCashFlowReportFilter } from "@/app/api/reports"; import { fetchProjectCashFlowReport } from "@/app/api/reports/actions"; import { downloadFile } from "@/app/utils/commonUtil"; -import { BASE_API_URL } from "@/config/api"; +import { dateTypeCombo } from "@/app/utils/comboUtil"; interface Props { projects: ProjectResult[]; @@ -17,12 +17,13 @@ type SearchQuery = Partial>; type SearchParamNames = keyof SearchQuery; const GenerateProjectCashFlowReport: React.FC = ({ projects }) => { - const { t } = useTranslation(); + const { t } = useTranslation("report"); const projectCombo = projects.map(project => `${project.code} - ${project.name}`) const searchCriteria: Criterion[] = useMemo( () => [ { label: t("Project"), paramName: "project", type: "select", options: projectCombo, needAll: false}, + { label: t("Date Type"), paramName: "dateType", type: "select", options: dateTypeCombo, needAll: false}, ], [t], ); @@ -35,7 +36,7 @@ const GenerateProjectCashFlowReport: React.FC = ({ projects }) => { if (query.project.length > 0 && query.project.toLocaleLowerCase() !== "all") { const projectIndex = projectCombo.findIndex(project => project === query.project) - const response = await fetchProjectCashFlowReport({ projectId: projects[projectIndex].id }) + const response = await fetchProjectCashFlowReport({ projectId: projects[projectIndex].id, dateType: query.dateType }) if (response) { downloadFile(new Uint8Array(response.blobValue), response.filename!!) } diff --git a/src/components/SearchBox/SearchBox.tsx b/src/components/SearchBox/SearchBox.tsx index 716d495..d8f502c 100644 --- a/src/components/SearchBox/SearchBox.tsx +++ b/src/components/SearchBox/SearchBox.tsx @@ -73,7 +73,7 @@ function SearchBox({ () => criteria.reduce>( (acc, c) => { - return { ...acc, [c.paramName]: c.type === "select" ? "All" : "" }; + return { ...acc, [c.paramName]: c.type === "select" ? !(c.needAll === false) ? "All" : c.options[0] : "" }; }, {} as Record ), diff --git a/src/i18n/en/report.json b/src/i18n/en/report.json index e7e61fb..541c75d 100644 --- a/src/i18n/en/report.json +++ b/src/i18n/en/report.json @@ -1,3 +1,4 @@ { - "Project": "Project" + "Project": "Project", + "Date Type": "Date Type" } \ No newline at end of file diff --git a/src/i18n/zh/common.json b/src/i18n/zh/common.json index ffcec1d..6f5e25c 100644 --- a/src/i18n/zh/common.json +++ b/src/i18n/zh/common.json @@ -15,6 +15,9 @@ "Do you want to delete?": "你是否確認要刪除?", "Delete Success": "刪除成功", + "Date": "日期", + "Month": "月份", + "Details": "詳情", "Delete": "刪除", "Download": "下載", diff --git a/src/i18n/zh/report.json b/src/i18n/zh/report.json index a6257cf..5b2e784 100644 --- a/src/i18n/zh/report.json +++ b/src/i18n/zh/report.json @@ -1,3 +1,4 @@ { - "Project": "項目" + "Project": "項目", + "Date Type": "日期類型" } \ No newline at end of file