"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const reactClient = require("@contember/react-client");
const react = require("react");
const auth = require("../../lib/auth.cjs");
const UPDATE_MEMBERSHIP_QUERY = `
	mutation (
		$projectSlug: String!,
		$identityId: String!
	) {
		removeProjectMember(
			projectSlug: $projectSlug,
			identityId: $identityId
		) {
			ok
			errors {
				code
			}
		}
	}
`;
const useRemoveMembership = () => auth.useAuthedTenantMutation(UPDATE_MEMBERSHIP_QUERY);
const useRemoveProjectMembership = () => {
  const [update, state] = useRemoveMembership();
  const cb = react.useCallback(
    (project, identityId) => {
      if (update) {
        return update({
          projectSlug: project,
          identityId
        });
      }
      return Promise.reject();
    },
    [update]
  );
  return [cb, state];
};
const useRemoveCurrentProjectMembership = () => {
  const project = reactClient.useProjectSlug();
  const [update, state] = useRemoveProjectMembership();
  const cb = react.useCallback(
    (identityId) => {
      if (project !== void 0) {
        return update(project, identityId);
      }
      return Promise.reject();
    },
    [project, update]
  );
  return [cb, state];
};
exports.useRemoveCurrentProjectMembership = useRemoveCurrentProjectMembership;
exports.useRemoveProjectMembership = useRemoveProjectMembership;
//# sourceMappingURL=removeMember.cjs.map
