fix: invite user service issues

This commit is contained in:
Ahmed Bouhuolia
2026-02-18 12:32:04 +02:00
parent 06b8a836c5
commit 78032d7bfc
9 changed files with 95 additions and 49 deletions

View File

@@ -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);
},
);

View File

@@ -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>
);

View File

@@ -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
}
);