IO-2368 Update Cache on success
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
@@ -157,7 +158,20 @@ export function PayableExportButton({
|
||||
fields: {
|
||||
bills(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(billRef) => billRef.__ref.includes(billId) === false
|
||||
(billRef) =>
|
||||
billRef.__ref.includes([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "billid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -184,6 +198,29 @@ export function PayableExportButton({
|
||||
key: "billsuccessexport",
|
||||
message: t("bills.successes.exported"),
|
||||
});
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
bills(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(billRef) =>
|
||||
billRef.__ref.includes([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "billid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (setSelectedBills) {
|
||||
@@ -194,7 +231,6 @@ export function PayableExportButton({
|
||||
}
|
||||
|
||||
if (!!loadingCallback) loadingCallback(false);
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user