Update E Card Client Portal
This commit is contained in:
@@ -17,6 +17,8 @@ import Typography from '@mui/material/Typography';
|
||||
import TableMoreMenu from '../../components/table/TableMoreMenu';
|
||||
import VisibilityOutlinedIcon from '@mui/icons-material/VisibilityOutlined';
|
||||
import Label from '../../components/Label';
|
||||
|
||||
import DownloadIcon from '@mui/icons-material/Download';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
|
||||
export default function List() {
|
||||
@@ -167,6 +169,26 @@ export default function List() {
|
||||
},
|
||||
];
|
||||
/* -------------------------------------------------------------------------- */
|
||||
// Download E-Card
|
||||
async function handleDownloadEcard(member_id: any, fullName:any) {
|
||||
return axios
|
||||
.get(corporateValue+`/download-ecard/${member_id}`, {
|
||||
responseType: 'blob',
|
||||
})
|
||||
.then((response) => {
|
||||
const namaFile = 'Ecard - '+fullName+".pdf";
|
||||
const url = URL.createObjectURL(response.data);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', namaFile);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
})
|
||||
.catch((error) => {
|
||||
enqueueSnackbar(error.message, { variant: 'error' });
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
@@ -182,7 +204,6 @@ export default function List() {
|
||||
const response = await axios.get(`${corporateValue}/members?type=employee-data`, {
|
||||
params: { ...parameters },
|
||||
});
|
||||
|
||||
setSearchParams(parameters);
|
||||
setData(
|
||||
response.data.data.map((obj: any) => ({
|
||||
@@ -205,6 +226,10 @@ export default function List() {
|
||||
<VisibilityOutlinedIcon />
|
||||
View
|
||||
</MenuItem>
|
||||
<MenuItem onClick={() => handleDownloadEcard(obj.id, obj.fullName)}>
|
||||
<DownloadIcon />
|
||||
Download E-card
|
||||
</MenuItem>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user