Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 78x 2x 2x 2x 2x 1x 1x 1x | import type { ReceiptId } from "~db/ids";
import { updateRevert as updateRevertReceipts } from "../cache/receipts";
import type { UseContextedMutationOptions } from "../context";
import { getConsumersItems } from "./utils";
export const options: UseContextedMutationOptions<
"receiptItemConsumers.remove",
{ receiptId: ReceiptId }
> = {
mutationKey: "receiptItemConsumers.remove",
onMutate:
(controllerContext, { receiptId }) =>
(variables) => {
Eif (variables.itemId === receiptId) {
return updateRevertReceipts(controllerContext, {
get: (controller) =>
controller.removePayer(receiptId, variables.peerId),
getPaged: undefined,
});
}
return updateRevertReceipts(controllerContext, {
get: (controller) =>
controller.removeItemConsumer(
receiptId,
variables.itemId,
variables.peerId,
),
getPaged: undefined,
});
},
errorToastOptions:
({ t }, contexts) =>
(errors, variablesSet) => ({
text: t("toasts.removeConsumer.error", {
ns: "receipts",
items: getConsumersItems(
t,
variablesSet.map(({ itemId }) => itemId),
contexts.map((context) => context.receiptId),
),
errors,
}),
}),
};
|