feat: add search parameter keys for redirect and message handling in login flow

This commit is contained in:
GW_MC
2025-12-19 18:53:01 +08:00
parent 227256e0e0
commit 1d1a469fe0
3 changed files with 39 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ import { Text } from '@radix-ui/themes';
import { AxiosError } from 'axios';
import { useLocation, useNavigate } from 'react-router';
import { toast } from 'react-toastify';
import { SearchParamKeys } from '../lib/constants';
export enum ResponseErrorToastId {
NetworkError = 'network-error',
@@ -74,8 +75,8 @@ const defaultResponseErrorHandler =
// store current path for redirect after login
const currentPath = location.pathname + location.search;
const searchParam = new URLSearchParams();
searchParam.set('redirect', currentPath);
searchParam.set('message', 'Session expired, please log in again');
searchParam.set(SearchParamKeys.Redirect, currentPath);
searchParam.set(SearchParamKeys.Message, 'Session expired, please log in again');
navigate(`/login?${searchParam.toString()}`);
return true;
}