This commit is contained in:
dx-tan 2024-02-02 14:18:13 +07:00
commit 9d9ddd62d5
6 changed files with 33 additions and 14 deletions

@ -1 +1 @@
Subproject commit 6907ea0183b141e3b4f3c21758c9123f1e9b2a27 Subproject commit b6d4fab46f7f8689dd6b050cfbff2faa6a6f3fec

View File

@ -295,6 +295,9 @@ const ReportOverViewTable: React.FC<ReportOverViewTableProps> = ({
dataIndex: 'extractionDate', dataIndex: 'extractionDate',
key: 'extractionDate', key: 'extractionDate',
width: '130px', width: '130px',
render: (_, record) => {
return <span>{record?.extractionDate.toString().split('T')[0]}</span>;
},
}, },
{ {
title: 'SN/IMEI', title: 'SN/IMEI',
@ -452,10 +455,10 @@ const ReportOverViewTable: React.FC<ReportOverViewTableProps> = ({
scroll={{ x: 2000 }} scroll={{ x: 2000 }}
pagination={{ pagination={{
current: pagination.page, current: pagination.page,
pageSize: pagination.page_size, pageSize: 10,
total: overviewDataResponse?.page.count, total: dataSubsRows?.length,
showTotal: (total, range) => // showTotal: (total, range) =>
`${range[0]}-${range[1]} of ${total} items`, // `${range[0]}-${range[1]} of ${total} items`,
onChange: (page, pageSize) => { onChange: (page, pageSize) => {
setPagination({ setPagination({
page, page,

View File

@ -19,10 +19,10 @@ const ReportTable: React.FC = () => {
})); }));
const handleDownloadReport = async (report_id: string) => { const handleDownloadReport = async (report_id: string) => {
const reportFile = await downloadReport(report_id); const {file, filename} = await downloadReport(report_id);
const anchorElement = document.createElement('a'); const anchorElement = document.createElement('a');
anchorElement.href = URL.createObjectURL(reportFile); anchorElement.href = URL.createObjectURL(file);
anchorElement.download = `${report_id}.xlsx`; // Set the desired new filename anchorElement.download = filename;
document.body.appendChild(anchorElement); document.body.appendChild(anchorElement);
anchorElement.click(); anchorElement.click();
@ -43,6 +43,9 @@ const ReportTable: React.FC = () => {
title: 'Created Date', title: 'Created Date',
dataIndex: 'Created Date', dataIndex: 'Created Date',
key: 'Created Date', key: 'Created Date',
render: (_, record) => {
return <span>{record['Created Date'].toString().split('T')[0]}</span>;
},
}, },
{ {
title: 'No. Requests', title: 'No. Requests',

View File

@ -32,6 +32,8 @@ const Dashboard = () => {
start_date: fromData.start_date, start_date: fromData.start_date,
end_date: fromData.end_date, end_date: fromData.end_date,
subsidiary: fromData.subsidiary, subsidiary: fromData.subsidiary,
page: pagination.page,
page_size: 30,
}); });
const handleSubmit = (values: ReportFormValues) => { const handleSubmit = (values: ReportFormValues) => {
console.log('check values >>>', values); console.log('check values >>>', values);

View File

@ -258,10 +258,10 @@ const ReportDetail = () => {
}); });
const report_data = data as ReportDetailList; const report_data = data as ReportDetailList;
const handleDownloadReport = async () => { const handleDownloadReport = async () => {
const reportFile = await downloadReport(id); const {file, filename} = await downloadReport(id);
const anchorElement = document.createElement('a'); const anchorElement = document.createElement('a');
anchorElement.href = URL.createObjectURL(reportFile); anchorElement.href = URL.createObjectURL(file);
anchorElement.download = `${id}.xlsx`; // Set the desired new filename anchorElement.download = filename;
document.body.appendChild(anchorElement); document.body.appendChild(anchorElement);
anchorElement.click(); anchorElement.click();
@ -302,13 +302,13 @@ const ReportDetail = () => {
<Typography.Title level={5}> <Typography.Title level={5}>
Start date:{' '} Start date:{' '}
<span style={{ fontWeight: '400' }}> <span style={{ fontWeight: '400' }}>
{report_data?.metadata?.start_at} {report_data?.metadata?.start_at.split('T')[0]}
</span> </span>
</Typography.Title> </Typography.Title>
<Typography.Title level={5}> <Typography.Title level={5}>
End date:{' '} End date:{' '}
<span style={{ fontWeight: '400' }}> <span style={{ fontWeight: '400' }}>
{report_data?.metadata?.end_at} {report_data?.metadata?.end_at.split('T')[0]}
</span> </span>
</Typography.Title> </Typography.Title>
</HeaderContainer> </HeaderContainer>

View File

@ -93,12 +93,23 @@ export async function downloadReport(report_id: string) {
const response = await API.get(`/ctel/get_report_file/${report_id}/`, { const response = await API.get(`/ctel/get_report_file/${report_id}/`, {
responseType: 'blob', // Important responseType: 'blob', // Important
}); });
let filename = "report.xlsx";
try {
let basename = response.headers['content-disposition'].split('filename=')[1].split('.')[0];
let extension = response.headers['content-disposition'].split('.')[1].split(';')[0];
filename = `${basename}.${extension}`
} catch(err) {
console.log(err);
}
const file = new Blob([response.data], { const file = new Blob([response.data], {
type: 'application/vnd.ms-excel', type: 'application/vnd.ms-excel',
}); });
// const fileURL = URL.createObjectURL(file); // const fileURL = URL.createObjectURL(file);
// window.open(fileURL); // window.open(fileURL);
return file; return {
file: file,
filename: filename,
}
} catch (error) { } catch (error) {
notification.error({ notification.error({
message: `${error?.message}`, message: `${error?.message}`,