mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
fix: invite user service issues
This commit is contained in:
@@ -58,7 +58,7 @@ export default function InviteAcceptForm() {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
if (errors.find((e) => e.type === 'INVITE.TOKEN.NOT.FOUND')) {
|
||||
if (errors.find((e) => e.type === 'INVITE_TOKEN_INVALID')) {
|
||||
AppToaster.show({
|
||||
message: intl.get('an_unexpected_error_occurred'),
|
||||
intent: Intent.DANGER,
|
||||
@@ -71,14 +71,6 @@ export default function InviteAcceptForm() {
|
||||
phone_number: 'This phone number is used in another account.',
|
||||
});
|
||||
}
|
||||
if (errors.find((e) => e.type === 'INVITE.TOKEN.NOT.FOUND')) {
|
||||
AppToaster.show({
|
||||
message: intl.get('an_unexpected_error_occurred'),
|
||||
intent: Intent.DANGER,
|
||||
position: Position.BOTTOM,
|
||||
});
|
||||
history.push('/auth/login');
|
||||
}
|
||||
setSubmitting(false);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -29,14 +29,22 @@ function InviteAcceptProvider({ token, ...props }) {
|
||||
if (inviteMetaError) { history.push('/auth/login'); }
|
||||
}, [history, inviteMetaError]);
|
||||
|
||||
// Transform the backend response to match frontend expectations.
|
||||
const transformedInviteMeta = inviteMeta
|
||||
? {
|
||||
email: inviteMeta.inviteToken?.email,
|
||||
organizationName: inviteMeta.orgName,
|
||||
}
|
||||
: null;
|
||||
|
||||
// Provider payload.
|
||||
const provider = {
|
||||
token,
|
||||
inviteMeta,
|
||||
inviteMeta: transformedInviteMeta,
|
||||
inviteMetaError,
|
||||
isInviteMetaError,
|
||||
isInviteMetaLoading,
|
||||
inviteAcceptMutate
|
||||
inviteAcceptMutate,
|
||||
};
|
||||
|
||||
if (inviteMetaError) {
|
||||
@@ -45,7 +53,6 @@ function InviteAcceptProvider({ token, ...props }) {
|
||||
|
||||
return (
|
||||
<InviteAcceptLoading isLoading={isInviteMetaLoading}>
|
||||
{ isInviteMetaError }
|
||||
<InviteAcceptContext.Provider value={provider} {...props} />
|
||||
</InviteAcceptLoading>
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { useMutation } from 'react-query';
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformToCamelCase } from '@/utils';
|
||||
|
||||
/**
|
||||
* Authentication invite accept.
|
||||
@@ -22,9 +23,9 @@ export const useAuthInviteAccept = (props) => {
|
||||
export const useInviteMetaByToken = (token, props) => {
|
||||
return useRequestQuery(
|
||||
['INVITE_META', token],
|
||||
{ method: 'get', url: `invite/invited/${token}` },
|
||||
{ method: 'get', url: `invite/check/${token}` },
|
||||
{
|
||||
select: (res) => res.data,
|
||||
select: (res) => transformToCamelCase(res.data),
|
||||
...props
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user