import { useProjectSlug } from "@contember/react-client";
import { useCallback } from "react";
import { useAuthedTenantMutation } from "../../lib/auth.js";
const UPDATE_MEMBERSHIP_QUERY = `
	mutation (
		$projectSlug: String!,
		$identityId: String!
	) {
		removeProjectMember(
			projectSlug: $projectSlug,
			identityId: $identityId
		) {
			ok
			errors {
				code
			}
		}
	}
`;
const useRemoveMembership = () => useAuthedTenantMutation(UPDATE_MEMBERSHIP_QUERY);
const useRemoveProjectMembership = () => {
  const [update, state] = useRemoveMembership();
  const cb = useCallback((project, identityId) => {
    if (update) {
      return update({
        projectSlug: project,
        identityId
      });
    }
    return Promise.reject();
  }, [update]);
  return [cb, state];
};
const useRemoveCurrentProjectMembership = () => {
  const project = useProjectSlug();
  const [update, state] = useRemoveProjectMembership();
  const cb = useCallback((identityId) => {
    if (project !== void 0) {
      return update(project, identityId);
    }
    return Promise.reject();
  }, [project, update]);
  return [cb, state];
};
export { useRemoveCurrentProjectMembership, useRemoveProjectMembership };
//# sourceMappingURL=removeMember.js.map
