fixed bug link loan history

This commit is contained in:
AmirHossein Mahmoodi
2024-02-03 06:53:53 +03:30
parent 872ba75b7d
commit 2aeb75f4cf

View File

@@ -3,33 +3,24 @@ import {useTranslations} from "next-intl";
import {useState} from "react";
import useRequest from "@/lib/app/hooks/useRequest";
import DescriptionIcon from '@mui/icons-material/Description';
import Link from "next/link";
const PrintHistory = ({attachment}) => {
const t = useTranslations();
const [loading, setLoading] = useState(false)
const requestServer = useRequest({auth: true, pending: false, success: {notification: {show: false}}})
const clickHandler = (attachment) => {
const anchor = document.createElement('a');
anchor.href = attachment;
anchor.setAttribute('download', '');
document.body.appendChild(anchor);
anchor.click();
document.body.removeChild(anchor);
}
return (<Button
color="primary"
variant="contained"
size="small"
disabled={loading}
sx={{textTransform: "unset", alignSelf: "center", mx: .25}}
startIcon={loading ? <CircularProgress size={18} color="inherit"/> : <DescriptionIcon/>}
onClick={() => clickHandler(attachment.file)}
>
{attachment.title}
</Button>)
return (
<Button
color="primary"
variant="contained"
size="small"
component={Link}
href={attachment.file}
target="_blank"
sx={{ textTransform: "unset", alignSelf: "center", mx: 0.25 }}
>
{attachment.title}
</Button>
);
}
export default PrintHistory