Skip to content

Commit

Permalink
Merge pull request #44 from openimis/feature/OP-1486
Browse files Browse the repository at this point in the history
OP-1468: fix dialog when export fails
  • Loading branch information
jdolkowski authored Mar 27, 2024
2 parents e3fccf6 + 4f65ab9 commit f6a6773
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/components/BillSearcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { bindActionCreators } from "redux";
import { connect } from "react-redux";
import { injectIntl } from "react-intl";

import { IconButton, Tooltip, Button, Dialog, DialogActions, DialogTitle } from "@material-ui/core";
import { IconButton, Tooltip, Button, Dialog, DialogActions, DialogTitle, DialogContent } from "@material-ui/core";
import EditIcon from "@material-ui/icons/Edit";
import DeleteIcon from "@material-ui/icons/Delete";

Expand Down Expand Up @@ -72,13 +72,17 @@ const BillSearcher = ({
}, [confirmed]);

useEffect(() => {
setFailedExport(true);
if (errorBillsExport) {
setFailedExport(true);
}
}, [errorBillsExport]);

useEffect(() => {
if (billsExport) {
downloadExport(billsExport, "bill_export.csv")();
}

return setFailedExport(false);
}, [billsExport]);

useEffect(() => {
Expand Down Expand Up @@ -250,12 +254,15 @@ const BillSearcher = ({
"status": "Status",
}}
/>

{failedExport && (
<Dialog fullWidth maxWidth="sm">
<DialogTitle>{errorBillsExport}</DialogTitle>
<Dialog open={failedExport} fullWidth maxWidth="sm">
<DialogTitle>{errorBillsExport?.message}</DialogTitle>
<DialogContent>
<strong>{`${errorBillsExport?.code}: `}</strong>
{errorBillsExport?.detail}
</DialogContent>
<DialogActions>
<Button onClick={setFailedExport(false)} variant="contained">
<Button onClick={() => setFailedExport(false)} color="primary" variant="contained">
{formatMessage(intl, "invoice", "ok")}
</Button>
</DialogActions>
Expand Down

0 comments on commit f6a6773

Please sign in to comment.