I would like to use updateQueryData to update some data in my Redux State.
export const useUpdateBankFeesByInvoiceId = ({ orderId, data, invoiceNumber}: ParamsBankFeesOrderSummary) => {
return calcApi.util.updateQueryData('getBankFeesByOrderId', orderId, (draft) => {
const newBankFees = draft?.map(invoice => invoice.invoice_num === invoiceNumber ? {
...invoice,
banking_commissions: invoice.banking_commissions.map((bankingCommission: BankFees) =>
bankingCommission.id === data.id ? data: bankingCommission
),
} : invoice)
return newBankFees;
}
);
}
When I dispatch that function:
const patchBankFees = dispatch(useUpdateBankFeesByInvoiceId(dataToSend));
But when I open Redux State I see the only difference in queries, there is no updates in the state app.
I also want the specific Redux State node get updated like in this screenshot:
I even added patchQueryData but result is the same:
export const usePatchBankFeesByInvoiceId = ({ orderId, func}) => {
return calcApi.util.patchQueryData(
'getBankFeesByOrderId',
orderId,
func.patches,
);
}
dispatch(usePatchBankFeesByInvoiceId({ orderId, func: patchBankFees}))
What's wrong is there? When I used upsertQueryData instead of updateQueryData I've got the desired result. But the code was weird.

