File size: 801 Bytes
1e92f2d |
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 |
import { useMutation } from '@tanstack/react-query';
import wpcom from 'calypso/lib/wp';
import type { TitanMailboxFields } from 'calypso/my-sites/email/form/mailboxes/constants';
/**
* Creates a mailbox for a Professional Email (Titan) account
* @returns Returns the result of the `useMutation` call
*/
export const useCreateTitanMailboxMutation = () => {
return useMutation< unknown, unknown, TitanMailboxFields >( {
mutationFn: ( { domain, isAdmin, mailbox, name, password, passwordResetEmail } ) => {
return wpcom.req.post( {
path: `/emails/titan/${ encodeURIComponent( domain ) }/mailbox/create`,
apiNamespace: 'wpcom/v2',
body: {
name,
mailbox,
password,
alternate_email_address: passwordResetEmail,
is_admin: isAdmin,
},
} );
},
} );
};
|