Skip to content

Commit

Permalink
fix: toasts
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-dalmet committed Oct 21, 2024
1 parent 2f8c7df commit a9ed445
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/features/auth/OAuthLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useRouter } from 'next/navigation';
import { useTranslation } from 'react-i18next';

import { Icon } from '@/components/Icons';
import { useToastError } from '@/components/Toast';
import { toastCustom } from '@/components/Toast';
import {
OAUTH_PROVIDERS,
OAUTH_PROVIDERS_ENABLED_ARRAY,
Expand All @@ -26,13 +26,13 @@ export const OAuthLoginButton = ({
} & ButtonProps) => {
const { t } = useTranslation(['auth']);
const router = useRouter();
const toastError = useToastError();
const loginWith = trpc.oauth.createAuthorizationUrl.useMutation({
onSuccess: (data) => {
router.push(data.url);
},
onError: (error) => {
toastError({
toastCustom({
status: 'error',
title: t('auth:login.feedbacks.oAuthError.title', {
provider: OAUTH_PROVIDERS[provider].label,
}),
Expand Down
8 changes: 5 additions & 3 deletions src/features/auth/PageOAuthCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useTranslation } from 'react-i18next';
import { z } from 'zod';

import { LoaderFull } from '@/components/LoaderFull';
import { useToastError } from '@/components/Toast';
import { toastCustom } from '@/components/Toast';
import { ROUTES_ADMIN } from '@/features/admin/routes';
import { ROUTES_APP } from '@/features/app/routes';
import { zOAuthProvider } from '@/features/auth/oauth-config';
Expand All @@ -19,7 +19,6 @@ import { trpc } from '@/lib/trpc/client';

export default function PageOAuthCallback() {
const { i18n, t } = useTranslation(['auth']);
const toastError = useToastError();
const router = useRouter();
const isTriggeredRef = useRef(false);
const params = z
Expand All @@ -40,7 +39,10 @@ export default function PageOAuthCallback() {
router.replace(ROUTES_APP.root());
},
onError: () => {
toastError({ title: t('auth:login.feedbacks.loginError.title') });
toastCustom({
status: 'error',
title: t('auth:login.feedbacks.loginError.title'),
});
router.replace(ROUTES_AUTH.login());
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/features/auth/PageRegister.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
FormFieldController,
FormFieldLabel,
} from '@/components/Form';
import { useToastError } from '@/components/Toast';
import { toastCustom } from '@/components/Toast';
import {
OAuthLoginButtonsGrid,
OAuthLoginDivider,
Expand Down

0 comments on commit a9ed445

Please sign in to comment.