fixed bug link loan history
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user