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,
|
||||
@@ -156,7 +157,20 @@ export function PaymentExportButton({
|
||||
fields: {
|
||||
payments(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(paymentRef) => paymentRef.__ref.includes(paymentId) === false
|
||||
(paymentRef) =>
|
||||
paymentRef.__ref.includes([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "paymentid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -190,9 +204,31 @@ export function PaymentExportButton({
|
||||
key: "paymentsuccessexport",
|
||||
message: t("payments.successes.exported"),
|
||||
});
|
||||
client.cache.modify({
|
||||
id: "ROOT_QUERY",
|
||||
fields: {
|
||||
payments(existingJobs = []) {
|
||||
return existingJobs.filter(
|
||||
(paymentRef) =>
|
||||
paymentRef.__ref.includes([
|
||||
...new Set(
|
||||
successfulTransactions.map(
|
||||
(st) =>
|
||||
st[
|
||||
bodyshop.accountingconfig &&
|
||||
bodyshop.accountingconfig.qbo
|
||||
? "paymentid"
|
||||
: "id"
|
||||
]
|
||||
)
|
||||
),
|
||||
]) === false
|
||||
);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
if (!!loadingCallback) loadingCallback(false);
|
||||
if (bodyshop.accountingconfig && bodyshop.accountingconfig.qbo) refetch();
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user