improvement: error handeling structure changed and unified all across the app. user no longer sees inappropriate messages.
This commit is contained in:
@@ -14,6 +14,7 @@ import { Button } from '@/components/ui/shared/Button';
|
||||
import { Input } from '@/components/ui/shared/Input';
|
||||
import { OrganizationDetailsFields } from '@/components/ui/auth/OrganizationDetailsFields';
|
||||
import { RegistrationProgressSteps } from '@/components/ui/auth/RegistrationProgressSteps';
|
||||
import { getUserFacingError } from '@/components/shared/formatApiError';
|
||||
import { organizationApi } from '@/lib/api/organization';
|
||||
|
||||
type AcceptOrganizationInviteForm = {
|
||||
@@ -27,6 +28,7 @@ type AcceptOrganizationInviteForm = {
|
||||
|
||||
function AcceptOrganizationInviteContent() {
|
||||
const t = useTranslations('auth');
|
||||
const tErrors = useTranslations('errors');
|
||||
const tCommon = useTranslations('common');
|
||||
const tValidation = useTranslations('validation');
|
||||
const params = useSearchParams();
|
||||
@@ -115,8 +117,7 @@ function AcceptOrganizationInviteContent() {
|
||||
setSuccess(t('invitationAlreadyAccepted'));
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
const message = e && typeof e === 'object' && 'message' in e ? String(e.message) : '';
|
||||
setError(message || t('errorLoadInvitation'));
|
||||
setError(getUserFacingError(e, tErrors, t('errorLoadInvitation')));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -148,8 +149,7 @@ function AcceptOrganizationInviteContent() {
|
||||
setSuccess(t('organizationAcceptedRedirect'));
|
||||
setTimeout(() => router.replace('/login'), 1000);
|
||||
} catch (e: unknown) {
|
||||
const message = e && typeof e === 'object' && 'message' in e ? String(e.message) : '';
|
||||
setError(message || t('errorAcceptInvitation'));
|
||||
setError(getUserFacingError(e, tErrors, t('errorAcceptInvitation')));
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user