Browse Source

update ex02 report

tags/Baseline_30082024_FRONTEND_UAT
cyril.tsui 1 year ago
parent
commit
114d49f34f
7 changed files with 19 additions and 6 deletions
  1. +2
    -0
      src/app/api/reports/index.ts
  2. +5
    -0
      src/app/utils/comboUtil.ts
  3. +4
    -3
      src/components/GenerateProjectCashFlowReport/GenerateProjectCashFlowReport.tsx
  4. +1
    -1
      src/components/SearchBox/SearchBox.tsx
  5. +2
    -1
      src/i18n/en/report.json
  6. +3
    -0
      src/i18n/zh/common.json
  7. +2
    -1
      src/i18n/zh/report.json

+ 2
- 0
src/app/api/reports/index.ts View File

@@ -7,10 +7,12 @@ export interface FinancialStatusReportFilter {
// - Project Cash Flow Report // - Project Cash Flow Report
export interface ProjectCashFlowReportFilter { export interface ProjectCashFlowReportFilter {
project: string[]; project: string[];
dateType: string[];
} }


export interface ProjectCashFlowReportRequest { export interface ProjectCashFlowReportRequest {
projectId: number; projectId: number;
dateType: string;
} }


// - Monthly Work Hours Report // - Monthly Work Hours Report


+ 5
- 0
src/app/utils/comboUtil.ts View File

@@ -8,4 +8,9 @@ export const claimStatusCombo = [
"Waiting for Approval", "Waiting for Approval",
"Approved", "Approved",
"Rejected" "Rejected"
]

export const dateTypeCombo = [
"Month",
"Date"
] ]

+ 4
- 3
src/components/GenerateProjectCashFlowReport/GenerateProjectCashFlowReport.tsx View File

@@ -7,7 +7,7 @@ import { ProjectResult } from "@/app/api/projects";
import { ProjectCashFlowReportFilter } from "@/app/api/reports"; import { ProjectCashFlowReportFilter } from "@/app/api/reports";
import { fetchProjectCashFlowReport } from "@/app/api/reports/actions"; import { fetchProjectCashFlowReport } from "@/app/api/reports/actions";
import { downloadFile } from "@/app/utils/commonUtil"; import { downloadFile } from "@/app/utils/commonUtil";
import { BASE_API_URL } from "@/config/api";
import { dateTypeCombo } from "@/app/utils/comboUtil";


interface Props { interface Props {
projects: ProjectResult[]; projects: ProjectResult[];
@@ -17,12 +17,13 @@ type SearchQuery = Partial<Omit<ProjectCashFlowReportFilter, "id">>;
type SearchParamNames = keyof SearchQuery; type SearchParamNames = keyof SearchQuery;


const GenerateProjectCashFlowReport: React.FC<Props> = ({ projects }) => { const GenerateProjectCashFlowReport: React.FC<Props> = ({ projects }) => {
const { t } = useTranslation();
const { t } = useTranslation("report");
const projectCombo = projects.map(project => `${project.code} - ${project.name}`) const projectCombo = projects.map(project => `${project.code} - ${project.name}`)


const searchCriteria: Criterion<SearchParamNames>[] = useMemo( const searchCriteria: Criterion<SearchParamNames>[] = useMemo(
() => [ () => [
{ label: t("Project"), paramName: "project", type: "select", options: projectCombo, needAll: false}, { label: t("Project"), paramName: "project", type: "select", options: projectCombo, needAll: false},
{ label: t("Date Type"), paramName: "dateType", type: "select", options: dateTypeCombo, needAll: false},
], ],
[t], [t],
); );
@@ -35,7 +36,7 @@ const GenerateProjectCashFlowReport: React.FC<Props> = ({ projects }) => {


if (query.project.length > 0 && query.project.toLocaleLowerCase() !== "all") { if (query.project.length > 0 && query.project.toLocaleLowerCase() !== "all") {
const projectIndex = projectCombo.findIndex(project => project === query.project) 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) { if (response) {
downloadFile(new Uint8Array(response.blobValue), response.filename!!) downloadFile(new Uint8Array(response.blobValue), response.filename!!)
} }


+ 1
- 1
src/components/SearchBox/SearchBox.tsx View File

@@ -73,7 +73,7 @@ function SearchBox<T extends string>({
() => () =>
criteria.reduce<Record<T, string>>( criteria.reduce<Record<T, string>>(
(acc, c) => { (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<T, string> {} as Record<T, string>
), ),


+ 2
- 1
src/i18n/en/report.json View File

@@ -1,3 +1,4 @@
{ {
"Project": "Project"
"Project": "Project",
"Date Type": "Date Type"
} }

+ 3
- 0
src/i18n/zh/common.json View File

@@ -15,6 +15,9 @@
"Do you want to delete?": "你是否確認要刪除?", "Do you want to delete?": "你是否確認要刪除?",
"Delete Success": "刪除成功", "Delete Success": "刪除成功",
"Date": "日期",
"Month": "月份",

"Details": "詳情", "Details": "詳情",
"Delete": "刪除", "Delete": "刪除",
"Download": "下載", "Download": "下載",


+ 2
- 1
src/i18n/zh/report.json View File

@@ -1,3 +1,4 @@
{ {
"Project": "項目"
"Project": "項目",
"Date Type": "日期類型"
} }

Loading…
Cancel
Save