0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

refactor(ui): remove continue page notification (#3197)

This commit is contained in:
simeng-li 2023-02-24 10:15:05 +08:00 committed by GitHub
parent e7b2b643fc
commit 0e9d851f68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 33 deletions

View file

@ -15,7 +15,6 @@ import useErrorHandler from '@/hooks/use-error-handler';
import useRequiredProfileErrorHandler from '@/hooks/use-required-profile-error-handler'; import useRequiredProfileErrorHandler from '@/hooks/use-required-profile-error-handler';
import { useSieMethods } from '@/hooks/use-sie'; import { useSieMethods } from '@/hooks/use-sie';
import type { VerificationCodeIdentifier } from '@/types'; import type { VerificationCodeIdentifier } from '@/types';
import { UserFlow } from '@/types';
import { formatPhoneNumberWithCountryCallingCode } from '@/utils/country-code'; import { formatPhoneNumberWithCountryCallingCode } from '@/utils/country-code';
import useGeneralVerificationCodeErrorHandler from './use-general-verification-code-error-handler'; import useGeneralVerificationCodeErrorHandler from './use-general-verification-code-error-handler';
@ -40,7 +39,6 @@ const useSignInFlowCodeVerification = (
const requiredProfileErrorHandlers = useRequiredProfileErrorHandler({ const requiredProfileErrorHandlers = useRequiredProfileErrorHandler({
replace: true, replace: true,
flow: UserFlow.signIn,
}); });
const showIdentifierErrorAlert = useIdentifierErrorAlert(); const showIdentifierErrorAlert = useIdentifierErrorAlert();

View file

@ -5,7 +5,6 @@ import { signInWithPasswordIdentifier } from '@/apis/interaction';
import useApi from '@/hooks/use-api'; import useApi from '@/hooks/use-api';
import type { ErrorHandlers } from '@/hooks/use-error-handler'; import type { ErrorHandlers } from '@/hooks/use-error-handler';
import useErrorHandler from '@/hooks/use-error-handler'; import useErrorHandler from '@/hooks/use-error-handler';
import { UserFlow } from '@/types';
import useRequiredProfileErrorHandler from './use-required-profile-error-handler'; import useRequiredProfileErrorHandler from './use-required-profile-error-handler';
@ -19,7 +18,7 @@ const usePasswordSignIn = () => {
const handleError = useErrorHandler(); const handleError = useErrorHandler();
const asyncSignIn = useApi(signInWithPasswordIdentifier); const asyncSignIn = useApi(signInWithPasswordIdentifier);
const requiredProfileErrorHandler = useRequiredProfileErrorHandler({ flow: UserFlow.signIn }); const requiredProfileErrorHandler = useRequiredProfileErrorHandler();
const errorHandlers: ErrorHandlers = useMemo( const errorHandlers: ErrorHandlers = useMemo(
() => ({ () => ({

View file

@ -13,10 +13,9 @@ import { PageContext } from './use-page-context';
type Options = { type Options = {
replace?: boolean; replace?: boolean;
linkSocial?: string; linkSocial?: string;
flow?: UserFlow;
}; };
const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options = {}) => { const useRequiredProfileErrorHandler = ({ replace, linkSocial }: Options = {}) => {
const navigate = useNavigate(); const navigate = useNavigate();
const { setToast } = useContext(PageContext); const { setToast } = useContext(PageContext);
@ -42,7 +41,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
{ {
pathname: `/${UserFlow.continue}/${missingProfile}`, pathname: `/${UserFlow.continue}/${missingProfile}`,
}, },
{ replace, state: { flow } } { replace }
); );
break; break;
} }
@ -54,7 +53,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
pathname: `/${UserFlow.continue}/${missingProfile}`, pathname: `/${UserFlow.continue}/${missingProfile}`,
search: linkSocialQueryString, search: linkSocialQueryString,
}, },
{ replace, state: { registeredSocialIdentity, flow } } { replace, state: { registeredSocialIdentity } }
); );
break; break;
} }
@ -66,7 +65,7 @@ const useRequiredProfileErrorHandler = ({ replace, linkSocial, flow }: Options =
} }
}, },
}), }),
[flow, linkSocial, navigate, replace, setToast] [linkSocial, navigate, replace, setToast]
); );
return requiredProfileErrorHandler; return requiredProfileErrorHandler;

View file

@ -6,7 +6,6 @@ import { useNavigate } from 'react-router-dom';
import { validate } from 'superstruct'; import { validate } from 'superstruct';
import { signInWithSocial } from '@/apis/interaction'; import { signInWithSocial } from '@/apis/interaction';
import { UserFlow } from '@/types';
import { socialAccountNotExistErrorDataGuard } from '@/types/guard'; import { socialAccountNotExistErrorDataGuard } from '@/types/guard';
import { parseQueryParameters } from '@/utils'; import { parseQueryParameters } from '@/utils';
import { stateValidation } from '@/utils/social-connectors'; import { stateValidation } from '@/utils/social-connectors';
@ -55,7 +54,6 @@ const useSocialSignInListener = (connectorId?: string) => {
); );
const requiredProfileErrorHandlers = useRequiredProfileErrorHandler({ const requiredProfileErrorHandlers = useRequiredProfileErrorHandler({
replace: true, replace: true,
flow: UserFlow.signIn,
}); });
const signInWithSocialErrorHandlers: ErrorHandlers = useMemo( const signInWithSocialErrorHandlers: ErrorHandlers = useMemo(
() => ({ () => ({

View file

@ -1,11 +1,7 @@
import { MissingProfile } from '@logto/schemas'; import { MissingProfile } from '@logto/schemas';
import { conditional } from '@silverhand/essentials'; import { useParams } from 'react-router-dom';
import { useLocation, useParams } from 'react-router-dom';
import { validate } from 'superstruct';
import ErrorPage from '@/pages/ErrorPage'; import ErrorPage from '@/pages/ErrorPage';
import { UserFlow } from '@/types';
import { continueFlowStateGuard } from '@/types/guard';
import SetEmailOrPhone from './SetEmailOrPhone'; import SetEmailOrPhone from './SetEmailOrPhone';
import SetPassword from './SetPassword'; import SetPassword from './SetPassword';
@ -17,20 +13,13 @@ type Parameters = {
const Continue = () => { const Continue = () => {
const { method = '' } = useParams<Parameters>(); 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) { if (method === MissingProfile.password) {
return <SetPassword notification={notification} />; return <SetPassword />;
} }
if (method === MissingProfile.username) { if (method === MissingProfile.username) {
return <SetUsername notification={notification} />; return <SetUsername />;
} }
if ( if (
@ -38,7 +27,7 @@ const Continue = () => {
method === MissingProfile.phone || method === MissingProfile.phone ||
method === MissingProfile.emailOrPhone method === MissingProfile.emailOrPhone
) { ) {
return <SetEmailOrPhone notification={notification} missingProfile={method} />; return <SetEmailOrPhone missingProfile={method} />;
} }
return <ErrorPage />; return <ErrorPage />;

View file

@ -16,13 +16,6 @@ export const passwordIdentifierStateGuard = s.object({
value: s.string(), value: s.string(),
}); });
/* Continue Flow */
export const continueFlowStateGuard = s.optional(
s.type({
flow: userFlowGuard,
})
);
/* Verification Code Flow Guard */ /* Verification Code Flow Guard */
const verificationCodeMethodGuard = s.union([ const verificationCodeMethodGuard = s.union([
s.literal(SignInIdentifier.Email), s.literal(SignInIdentifier.Email),