fix employee data export

This commit is contained in:
Muhammad Fajar
2024-01-04 08:39:53 +07:00
parent 3580c93c02
commit f208f0b133
5 changed files with 1493 additions and 1111 deletions

View File

@@ -288,11 +288,7 @@ export default function Table<T>({
{exportReport && exportReport.useExport ? (
<Grid item xs={12} lg={2} xl={2}>
<FormControl fullWidth>
<Button
variant="contained"
sx={{ p: 2 }}
onClick={() => exportReport.handleExportReport}
>
<Button variant="contained" sx={{ p: 2 }} onClick={exportReport.handleExportReport}>
<Download />
<Typography variant="inherit" sx={{ marginLeft: 1 }}>
Export

View File

@@ -280,58 +280,56 @@ export default function Index() {
});
setDivisionData(corporateDivision.data);
setMemberData(
corporateMembers.data.data.map((obj: any) => {
return {
...obj,
// limit: (
// <Stack>
// <BorderLinearProgress
// variant="determinate"
// value={obj.limit.percentage}
// sx={{ mb: 1 }}
// />
// <Typography sx={{ typography: 'caption', color: '#637381' }}>
// {fSplit(obj.limit.current)} / {fSplit(obj.limit.total)}
// </Typography>
// </Stack>
// ),
status:
obj.status === 1 ? (
<Button
sx={{
backgroundColor: 'rgba(84, 214, 44, 0.16)',
color: palette.dark.success.dark,
paddingY: 0,
'&:hover': {
backgroundColor: 'rgba(84, 214, 44, 0.32)',
color: palette.dark.success.darker,
},
}}
>
Active
</Button>
) : (
<Button
sx={{
backgroundColor: 'rgba(255, 72, 66, 0.16)',
color: palette.dark.error.dark,
paddingY: 0,
'&:hover': {
backgroundColor: 'rgba(255, 72, 66, 0.32)',
color: palette.dark.error.darker,
},
}}
>
Inactive
</Button>
),
/* action: (
corporateMembers.data.data.map((obj: any) => ({
...obj,
// limit: (
// <Stack>
// <BorderLinearProgress
// variant="determinate"
// value={obj.limit.percentage}
// sx={{ mb: 1 }}
// />
// <Typography sx={{ typography: 'caption', color: '#637381' }}>
// {fSplit(obj.limit.current)} / {fSplit(obj.limit.total)}
// </Typography>
// </Stack>
// ),
status:
obj.status === 1 ? (
<Button
sx={{
backgroundColor: 'rgba(84, 214, 44, 0.16)',
color: palette.dark.success.dark,
paddingY: 0,
'&:hover': {
backgroundColor: 'rgba(84, 214, 44, 0.32)',
color: palette.dark.success.darker,
},
}}
>
Active
</Button>
) : (
<Button
sx={{
backgroundColor: 'rgba(255, 72, 66, 0.16)',
color: palette.dark.error.dark,
paddingY: 0,
'&:hover': {
backgroundColor: 'rgba(255, 72, 66, 0.32)',
color: palette.dark.error.darker,
},
}}
>
Inactive
</Button>
),
/* action: (
<IconButton onClick={handleAction}>
<MoreVertIcon />
</IconButton>
), */
};
})
}))
);
setPaginationTable(corporateMembers.data);
setRowsPerPage(corporateMembers.data.per_page);
@@ -351,7 +349,7 @@ export default function Index() {
anchorOrigin: { horizontal: 'right', vertical: 'bottom' },
});
})();
}, [appliedParams, searchParams, order, orderBy, setSearchParams, corporateValue]);
}, [appliedParams, searchParams, order, orderBy, pathname, setSearchParams, corporateValue]);
return (
<Page title="Dashboard">

View File

@@ -108,27 +108,23 @@ export default function List() {
setSearchText: setSearchText,
handleSearchSubmit: handleSearchSubmit,
};
const [startDateValue, setStartDateValue] = useState('');
const [endDateValue, setEndDateValue] = useState('');
const [statusValue, setStatusValue] = useState('all');
const handleExportReport = async (appliedFilter = null) => {
axios.get(corporateValue + '/export-members/list').then((response) => {
const handleExportReport = async () => {
axios.get(corporateValue + '/export-members/list').then((response) => {
const link = document.createElement('a');
link.href = response.data.data.file_url;
link.setAttribute('download', response.data.data.file_name);
document.body.appendChild(link);
link.click();
// handleClose();
});
}
};
const exportReport = {
useExport: true,
startDate: startDateValue,
endDate: endDateValue,
status: statusValue,
handleExportReport: handleExportReport
}
startDate: '',
endDate: '',
status: 'all',
handleExportReport: handleExportReport,
};
/* -------------------------------- headCell -------------------------------- */
const headCells: HeadCell<never>[] = [