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 | 5x 43x 43x 1x 43x 1x 1x 1x 1x 1x 43x | import { useMutation, useQueryClient } from "react-query";
import { customInstance } from "@services/api";
import {
QKEY_LIST_TEAM_MEMBERS,
QKEY_CHECK_OWNER_MEMBER,
QKEY_MERCHANT_OWNER_REASSIGNMENT,
} from "@constants/queryKeys";
/**
* GB-21471 — cancel an in-flight Primary Account Holder reassignment.
*
* POSTs to `/accounts/{merchantId}/invites/{inviteId}/cancel` (the same
* invite-scoped endpoint the acquirer side uses). The BE voids the pending
* owner change request without declining the incoming PAH's person status, so
* the same email can be reassigned afterwards. On success the reassignment
* status, the team list and the owner queries are invalidated so every Team-tab
* surface returns to the idle state.
*/
const useCancelPahReassignment = (merchantId: number) => {
const queryClient = useQueryClient();
const mutation = useMutation((inviteId: number) =>
customInstance({
url: `/accounts/${merchantId}/invites/${inviteId}/cancel`,
method: "POST",
}),
);
const cancelReassignment = (inviteId: number) =>
mutation.mutateAsync(inviteId).then((res) => {
queryClient.invalidateQueries([
QKEY_MERCHANT_OWNER_REASSIGNMENT,
merchantId,
]);
queryClient.invalidateQueries(QKEY_LIST_TEAM_MEMBERS);
queryClient.invalidateQueries([QKEY_CHECK_OWNER_MEMBER, merchantId]);
return res;
});
return { cancelReassignment, isLoading: mutation.isLoading };
};
export default useCancelPahReassignment;
|