mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor(ui): remove continue page notification (#3197)
This commit is contained in:
parent
e7b2b643fc
commit
0e9d851f68
6 changed files with 9 additions and 33 deletions
|
@ -15,7 +15,6 @@ import useErrorHandler from '@/hooks/use-error-handler';
|
|||
import useRequiredProfileErrorHandler from '@/hooks/use-required-profile-error-handler';
|
||||
import { useSieMethods } from '@/hooks/use-sie';
|
||||
import type { VerificationCodeIdentifier } from '@/types';
|
||||
import { UserFlow } from '@/types';
|
||||
import { formatPhoneNumberWithCountryCallingCode } from '@/utils/country-code';
|
||||
|
||||
import useGeneralVerificationCodeErrorHandler from './use-general-verification-code-error-handler';
|
||||
|
@ -40,7 +39,6 @@ const useSignInFlowCodeVerification = (
|
|||
|
||||
const requiredProfileErrorHandlers = useRequiredProfileErrorHandler({
|
||||
replace: true,
|
||||
flow: UserFlow.signIn,
|
||||
});
|
||||
const showIdentifierErrorAlert = useIdentifierErrorAlert();
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import { signInWithPasswordIdentifier } from '@/apis/interaction';
|
|||
import useApi from '@/hooks/use-api';
|
||||
import type { ErrorHandlers } from '@/hooks/use-error-handler';
|
||||
import useErrorHandler from '@/hooks/use-error-handler';
|
||||
import { UserFlow } from '@/types';
|
||||
|
||||
import useRequiredProfileErrorHandler from './use-required-profile-error-handler';
|
||||
|
||||
|
@ -19,7 +18,7 @@ const usePasswordSignIn = () => {
|
|||
const handleError = useErrorHandler();
|
||||
const asyncSignIn = useApi(signInWithPasswordIdentifier);
|
||||
|
||||
const requiredProfileErrorHandler = useRequiredProfileErrorHandler({ flow: UserFlow.signIn });
|
||||
const requiredProfileErrorHandler = useRequiredProfileErrorHandler();
|
||||
|
||||
const errorHandlers: ErrorHandlers = useMemo(
|
||||
() => ({
|
||||
|
|
|
@ -13,10 +13,9 @@ import { PageContext } from './use-page-context';
|
|||
type Options = {
|
||||
replace?: boolean;
|
||||
linkSocial?: string;
|
||||
flow?: UserFlow;
|
||||
};
|
||||
|
||||
const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options = {}) => {
|
||||
const useRequiredProfileErrorHandler = ({ replace, linkSocial }: Options = {}) => {
|
||||
const navigate = useNavigate();
|
||||
const { setToast } = useContext(PageContext);
|
||||
|
||||
|
@ -42,7 +41,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
|
|||
{
|
||||
pathname: `/${UserFlow.continue}/${missingProfile}`,
|
||||
},
|
||||
{ replace, state: { flow } }
|
||||
{ replace }
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -54,7 +53,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
|
|||
pathname: `/${UserFlow.continue}/${missingProfile}`,
|
||||
search: linkSocialQueryString,
|
||||
},
|
||||
{ replace, state: { registeredSocialIdentity, flow } }
|
||||
{ replace, state: { registeredSocialIdentity } }
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -66,7 +65,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
|
|||
}
|
||||
},
|
||||
}),
|
||||
[flow, linkSocial, navigate, replace, setToast]
|
||||
[linkSocial, navigate, replace, setToast]
|
||||
);
|
||||
|
||||
return requiredProfileErrorHandler;
|
||||
|
|
|
@ -6,7 +6,6 @@ import { useNavigate } from 'react-router-dom';
|
|||
import { validate } from 'superstruct';
|
||||
|
||||
import { signInWithSocial } from '@/apis/interaction';
|
||||
import { UserFlow } from '@/types';
|
||||
import { socialAccountNotExistErrorDataGuard } from '@/types/guard';
|
||||
import { parseQueryParameters } from '@/utils';
|
||||
import { stateValidation } from '@/utils/social-connectors';
|
||||
|
@ -55,7 +54,6 @@ const useSocialSignInListener = (connectorId?: string) => {
|
|||
);
|
||||
const requiredProfileErrorHandlers = useRequiredProfileErrorHandler({
|
||||
replace: true,
|
||||
flow: UserFlow.signIn,
|
||||
});
|
||||
const signInWithSocialErrorHandlers: ErrorHandlers = useMemo(
|
||||
() => ({
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import { MissingProfile } from '@logto/schemas';
|
||||
import { conditional } from '@silverhand/essentials';
|
||||
import { useLocation, useParams } from 'react-router-dom';
|
||||
import { validate } from 'superstruct';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
import ErrorPage from '@/pages/ErrorPage';
|
||||
import { UserFlow } from '@/types';
|
||||
import { continueFlowStateGuard } from '@/types/guard';
|
||||
|
||||
import SetEmailOrPhone from './SetEmailOrPhone';
|
||||
import SetPassword from './SetPassword';
|
||||
|
@ -17,20 +13,13 @@ type Parameters = {
|
|||
|
||||
const Continue = () => {
|
||||
const { method = '' } = useParams<Parameters>();
|
||||
const { state } = useLocation();
|
||||
|
||||
const [_, data] = validate(state, continueFlowStateGuard);
|
||||
|
||||
const notification = conditional(
|
||||
data?.flow === UserFlow.signIn && 'description.continue_with_more_information'
|
||||
);
|
||||
|
||||
if (method === MissingProfile.password) {
|
||||
return <SetPassword notification={notification} />;
|
||||
return <SetPassword />;
|
||||
}
|
||||
|
||||
if (method === MissingProfile.username) {
|
||||
return <SetUsername notification={notification} />;
|
||||
return <SetUsername />;
|
||||
}
|
||||
|
||||
if (
|
||||
|
@ -38,7 +27,7 @@ const Continue = () => {
|
|||
method === MissingProfile.phone ||
|
||||
method === MissingProfile.emailOrPhone
|
||||
) {
|
||||
return <SetEmailOrPhone notification={notification} missingProfile={method} />;
|
||||
return <SetEmailOrPhone missingProfile={method} />;
|
||||
}
|
||||
|
||||
return <ErrorPage />;
|
||||
|
|
|
@ -16,13 +16,6 @@ export const passwordIdentifierStateGuard = s.object({
|
|||
value: s.string(),
|
||||
});
|
||||
|
||||
/* Continue Flow */
|
||||
export const continueFlowStateGuard = s.optional(
|
||||
s.type({
|
||||
flow: userFlowGuard,
|
||||
})
|
||||
);
|
||||
|
||||
/* Verification Code Flow Guard */
|
||||
const verificationCodeMethodGuard = s.union([
|
||||
s.literal(SignInIdentifier.Email),
|
||||
|
|
Loading…
Reference in a new issue