File size: 472 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { useMutation } from '@tanstack/react-query';
import wpcomRequest from 'wpcom-proxy-request';

interface Invitee {
	email_or_username: string;
	role: string;
}

export function useSendInvites( siteId: number ) {
	return useMutation( {
		mutationFn: ( invitees: Invitee[] ) => {
			return wpcomRequest( {
				path: `/sites/${ encodeURIComponent( siteId ) }/invites/new`,
				apiNamespace: 'wpcom/v2',
				method: 'POST',
				body: { invitees },
			} );
		},
	} );
}