tombol loading

This commit is contained in:
2024-02-02 14:46:29 +07:00
parent 73411013c6
commit f83d07db84

View File

@@ -175,6 +175,7 @@ export default function List() {
const createMenu = Boolean(anchorEl);
const importForm = useRef<HTMLInputElement>(null);
const [currentImportFileName, setCurrentImportFileName] = useState(null);
const [importLoading, setImportLoading] = useState(false);
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
setAnchorEl(event.currentTarget);
@@ -205,7 +206,7 @@ export default function List() {
Object.keys(appliedParams).length !== 0
? appliedParams
: Object.fromEntries([...searchParams.entries(), ['order', order], ['orderBy', orderBy]]);
setImportLoading(true);
axios.get('/report/logs/export', {
params: { ...parameters },
}).then((response) => {
@@ -215,6 +216,7 @@ export default function List() {
document.body.appendChild(link);
link.click();
handleClose();
setImportLoading(false);
});
// axios.get(`report/logs/export`)
// .then((response) => {
@@ -240,14 +242,15 @@ export default function List() {
{!currentImportFileName && (
<Stack direction={'row'} spacing={2} sx={{ p: 2 }}>
<SearchInput onSearch={applyFilter} />
<Button
<LoadingButton
variant="outlined"
startIcon={<UploadIcon />}
sx={{ p: 1.8 }}
onClick={handleClick}
loading={importLoading}
>
Export
</Button>
</LoadingButton>
<Menu
id="import-button"
anchorEl={anchorEl}