| @@ -1,24 +1,30 @@ | |||
| //src\app\(main)\analytics\DelayReport\page.tsx | |||
| import { Metadata } from "next"; | |||
| import { I18nProvider } from "@/i18n"; | |||
| import Typography from "@mui/material/Typography"; | |||
| import ProjectClaimsReportComponent from "@/components/Report/ProjectClaimsReport"; | |||
| import { Suspense } from "react"; | |||
| import { I18nProvider, getServerI18n } from "@/i18n"; | |||
| import { fetchProjects } from "@/app/api/projects"; | |||
| import GenerateLateStartReport from "@/components/Report/LateStartReportGen"; | |||
| import { Typography } from "@mui/material"; | |||
| export const metadata: Metadata = { | |||
| title: "Project Claims Report", | |||
| title: "Late Start Report", | |||
| }; | |||
| const ProjectClaimsReport: React.FC = () => { | |||
| return ( | |||
| <I18nProvider namespaces={["analytics"]}> | |||
| <Typography variant="h4" marginInlineEnd={2}> | |||
| Project Claims Report | |||
| </Typography> | |||
| {/* <Suspense fallback={<ProgressCashFlowSearch.Loading />}> | |||
| <ProgressCashFlowSearch/> | |||
| </Suspense> */} | |||
| <ProjectClaimsReportComponent /> | |||
| </I18nProvider> | |||
| ); | |||
| const LateStartReport: React.FC = async () => { | |||
| const { t } = await getServerI18n("reports"); | |||
| fetchProjects(); | |||
| return ( | |||
| <> | |||
| <Typography variant="h4" marginInlineEnd={2}> | |||
| {t("Project Cash Flow Report")} | |||
| </Typography> | |||
| <I18nProvider namespaces={["report", "common"]}> | |||
| <Suspense fallback={<GenerateLateStartReport.Loading />}> | |||
| <GenerateLateStartReport /> | |||
| </Suspense> | |||
| </I18nProvider> | |||
| </> | |||
| ); | |||
| }; | |||
| export default ProjectClaimsReport; | |||
| export default LateStartReport; | |||
| @@ -49,17 +49,17 @@ export const fetchMonthlyWorkHoursReport = async (data: MonthlyWorkHoursReportRe | |||
| // }; | |||
| export const fetchLateStartReport = async (data: LateStartReportRequest) => { | |||
| const response = await fetch(`${BASE_API_URL}/reports/downloadLateStartReport`, { | |||
| const response = await serverFetchBlob<FileResponse>(`${BASE_API_URL}/reports/downloadLateStartReport`, { | |||
| method: "POST", | |||
| body: JSON.stringify(data), | |||
| headers: { "Content-Type": "application/json" }, | |||
| }); | |||
| if (!response.ok) { | |||
| const errorText = await response.text(); // Attempt to read the response text | |||
| throw new Error(`Network response was not ok: ${response.status} - ${errorText}`); | |||
| } | |||
| const blob = await response.blob(); | |||
| return { fileBlob: blob, fileName: 'Late_Start_Report.xlsx' }; | |||
| // if (!response.ok) { | |||
| // const errorText = await response.text(); // Attempt to read the response text | |||
| // throw new Error(`Network response was not ok: ${response.status} - ${errorText}`); | |||
| // } | |||
| // const blob = await response.blob(); | |||
| // return { fileBlob: blob, fileName: 'Late_Start_Report.xlsx' }; | |||
| return response | |||
| }; | |||
| @@ -21,14 +21,6 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects }) => { | |||
| const [clientCombo, setclientCombo] = useState<string[]>([]) | |||
| const [isLoading, setIsLoading] = useState(true) | |||
| // const [teamCombo, setteamCombo] = useState([]); | |||
| // const getteamCombo = () => { | |||
| // axios.get(`${apiPath}${GET_QC_CATEGORY_COMBO}`) | |||
| // .then(response => { | |||
| // setteamCombo(response.data.records)}) | |||
| // .catch(error => { | |||
| // console.error('Error fetching data: ', error); | |||
| // }); | |||
| // } | |||
| const getTeamCombo = async() => { | |||
| try { | |||
| @@ -39,6 +31,7 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects }) => { | |||
| console.log(err) | |||
| } | |||
| } | |||
| // const getClientCombo = async() => { | |||
| // try { | |||
| // const response = await fetchCombo() | |||
| @@ -48,6 +41,7 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects }) => { | |||
| // console.log(err) | |||
| // } | |||
| // } | |||
| useEffect(() => { | |||
| getTeamCombo() | |||
| }, []) | |||
| @@ -26,6 +26,7 @@ import { fetchLateStartReport } from "@/app/api/reports/actions"; | |||
| import * as XLSX from 'xlsx-js-style'; | |||
| import { LateStartReportRequest } from "@/app/api/reports"; | |||
| import { fetchTeamCombo } from "@/app/api/team/actions"; | |||
| import { downloadFile } from "@/app/utils/commonUtil"; | |||
| //import { DownloadReportButton } from '../LateStartReportGen/DownloadReportButton'; | |||
| interface BaseCriterion<T extends string> { | |||
| @@ -134,21 +135,24 @@ function SearchBox<T extends string>({ | |||
| // Call fetchLateStartReport and wait for the blob | |||
| //const responseBlob = await fetchLateStartReport(requestData); | |||
| const fileResponse = await fetchLateStartReport(requestData); | |||
| const blob = fileResponse.fileBlob; | |||
| if (fileResponse) { | |||
| downloadFile(new Uint8Array(fileResponse.blobValue), fileResponse.filename!!) | |||
| } | |||
| // const blob = fileResponse.fileBlob; | |||
| // Create a URL from the Blob response | |||
| const url = window.URL.createObjectURL(blob); | |||
| // // Create a URL from the Blob response | |||
| // const url = window.URL.createObjectURL(fileResponse); | |||
| // Create an anchor element and trigger the download | |||
| const a = document.createElement('a'); | |||
| a.href = url; | |||
| a.download = "Late_Start_Report.xlsx"; // Set the filename for download | |||
| document.body.appendChild(a); | |||
| a.click(); | |||
| a.remove(); | |||
| // // Create an anchor element and trigger the download | |||
| // const a = document.createElement('a'); | |||
| // a.href = url; | |||
| // a.download = "Late_Start_Report.xlsx"; // Set the filename for download | |||
| // document.body.appendChild(a); | |||
| // a.click(); | |||
| // a.remove(); | |||
| // Optionally revoke the URL if you want to free up resources | |||
| window.URL.revokeObjectURL(url); | |||
| // // Optionally revoke the URL if you want to free up resources | |||
| // window.URL.revokeObjectURL(url); | |||
| } catch (error) { | |||
| console.error('Error downloading the file: ', error); | |||
| } | |||