i18n
This commit is contained in:
@@ -4,11 +4,13 @@ import { fetchMe } from "@/features/players/server";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import toast from '@/lib/sonner'
|
||||
import { playerKeys } from "@/features/players/queries";
|
||||
import { useLingui } from "@lingui/react/macro";
|
||||
|
||||
const useConsumeCode = (onWrongCode: () => void) => {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const { t } = useLingui();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (code: string) => consumeCode({ userInputCode: code }),
|
||||
onSuccess: async (data) => {
|
||||
@@ -18,18 +20,18 @@ const useConsumeCode = (onWrongCode: () => void) => {
|
||||
navigate({ to: '/login', search: { stage: 'name' } });
|
||||
} else {
|
||||
queryClient.setQueryData(playerKeys.auth, response.data);
|
||||
toast.success('Successfully logged in. Welcome back!');
|
||||
toast.success(t`Successfully logged in. Welcome back!`);
|
||||
navigate({ to: '/' })
|
||||
}
|
||||
} else if (data.status === 'INCORRECT_USER_INPUT_CODE_ERROR') {
|
||||
onWrongCode();
|
||||
} else if (data.status === 'EXPIRED_USER_INPUT_CODE_ERROR') {
|
||||
toast.error('Code has expired. Please request a new code.');
|
||||
toast.error(t`Code has expired. Please request a new code.`);
|
||||
} else if (data.status === "RESTART_FLOW_ERROR") {
|
||||
toast.error('Too many failed attempts. Please try again.');
|
||||
toast.error(t`Too many failed attempts. Please try again.`);
|
||||
navigate({ to: '/login', search: { stage: undefined, number: undefined } });
|
||||
} else {
|
||||
toast.error('Unknown error. Please try again later.');
|
||||
toast.error(t`Unknown error. Please try again later.`);
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -38,7 +40,7 @@ const useConsumeCode = (onWrongCode: () => void) => {
|
||||
if (error.isSuperTokensGeneralError === true) {
|
||||
toast.error(error.message);
|
||||
} else {
|
||||
toast.error("Unknown error. Please try again later.");
|
||||
toast.error(t`Unknown error. Please try again later.`);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user