IO-710 Export Log page & insert actions on export
This commit is contained in:
@@ -7,15 +7,21 @@ import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { auth } from "../../firebase/firebase.utils";
|
||||
import { UPDATE_BILLS } from "../../graphql/bills.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
export function PayableExportButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
billId,
|
||||
disabled,
|
||||
loadingCallback,
|
||||
@@ -23,6 +29,7 @@ export function PayableExportButton({
|
||||
const { t } = useTranslation();
|
||||
const [updateBill] = useMutation(UPDATE_BILLS);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||
|
||||
const handleQbxml = async () => {
|
||||
logImEXEvent("accounting_export_payable");
|
||||
@@ -84,8 +91,35 @@ export function PayableExportButton({
|
||||
}),
|
||||
})
|
||||
);
|
||||
await insertExportLog({
|
||||
variables: {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
billid: billId,
|
||||
successful: false,
|
||||
message: JSON.stringify(
|
||||
failedTransactions.map((ft) => ft.errorMessage)
|
||||
),
|
||||
useremail: currentUser.email,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
}
|
||||
if (successfulTransactions.length > 0) {
|
||||
await insertExportLog({
|
||||
variables: {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
billid: billId,
|
||||
successful: true,
|
||||
useremail: currentUser.email,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
const billUpdateResponse = await updateBill({
|
||||
variables: {
|
||||
billIdList: successfulTransactions.map((st) => st.id),
|
||||
@@ -96,7 +130,9 @@ export function PayableExportButton({
|
||||
},
|
||||
});
|
||||
if (!!!billUpdateResponse.errors) {
|
||||
notification["success"]({
|
||||
notification.open({
|
||||
type: "success",
|
||||
key: "billsuccessexport",
|
||||
message: t("bills.successes.exported"),
|
||||
});
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user