IO-2368 Update Cache on success

This commit is contained in:
Allan Carr
2023-09-07 17:21:21 -07:00
parent 7a1984d037
commit d1407162d9
6 changed files with 256 additions and 17 deletions

View File

@@ -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);
};