IO-1926 Add export log to mark as exported.
This commit is contained in:
@@ -4,14 +4,15 @@ import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||
import {
|
||||
selectAuthLevel,
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
authLevel: selectAuthLevel,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
@@ -23,6 +24,8 @@ export default connect(
|
||||
)(BillMarkSelectedExported);
|
||||
|
||||
export function BillMarkSelectedExported({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
billids,
|
||||
disabled,
|
||||
loadingCallback,
|
||||
@@ -31,7 +34,7 @@ export function BillMarkSelectedExported({
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||
const [updateBill] = useMutation(gql`
|
||||
mutation UPDATE_BILL($billIds: [uuid!]!) {
|
||||
update_bills(where: { id: { _in: $billIds } }, _set: { exported: true }) {
|
||||
@@ -49,9 +52,21 @@ export function BillMarkSelectedExported({
|
||||
loadingCallback(true);
|
||||
const result = await updateBill({
|
||||
variables: { billIds: billids },
|
||||
update(cache){
|
||||
|
||||
}
|
||||
update(cache) {},
|
||||
});
|
||||
|
||||
await insertExportLog({
|
||||
variables: {
|
||||
logs: billids.map((id) => {
|
||||
return {
|
||||
bodyshopid: bodyshop.id,
|
||||
billid: id,
|
||||
successful: true,
|
||||
message: t("general.labels.markedexported"),
|
||||
useremail: currentUser.email,
|
||||
};
|
||||
}),
|
||||
},
|
||||
});
|
||||
|
||||
if (!result.errors) {
|
||||
|
||||
Reference in New Issue
Block a user