From e131467af97b95f89741ea896fb7df64b085eb8c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 18 Mar 2024 13:44:34 -0500 Subject: [PATCH] Fix up login/signing paths and buttons --- src/features/auth-login/components/login-page.tsx | 10 ++++++++-- .../auth-login/components/registration-page.tsx | 11 ++++++++++- src/features/ui/components/panels/sign-up-panel.tsx | 10 ++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/features/auth-login/components/login-page.tsx b/src/features/auth-login/components/login-page.tsx index 8817b6d39..9ceec4a55 100644 --- a/src/features/auth-login/components/login-page.tsx +++ b/src/features/auth-login/components/login-page.tsx @@ -4,9 +4,9 @@ import { Redirect } from 'react-router-dom'; import { logIn, verifyCredentials, switchAccount } from 'soapbox/actions/auth'; import { fetchInstance } from 'soapbox/actions/instance'; -import { closeModal } from 'soapbox/actions/modals'; +import { closeModal, openModal } from 'soapbox/actions/modals'; import { BigCard } from 'soapbox/components/big-card'; -import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; +import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks'; import { getRedirectUrl } from 'soapbox/utils/redirect'; import { isStandalone } from 'soapbox/utils/state'; @@ -21,6 +21,7 @@ const LoginPage = () => { const me = useAppSelector((state) => state.me); const standalone = useAppSelector((state) => isStandalone(state)); + const { nostrSignup } = useFeatures(); const token = new URLSearchParams(window.location.search).get('token'); @@ -62,6 +63,11 @@ const LoginPage = () => { event.preventDefault(); }; + if (nostrSignup) { + setTimeout(() => dispatch(openModal('NOSTR_LOGIN')), 100); + return ; + } + if (standalone) return ; if (shouldRedirect) { diff --git a/src/features/auth-login/components/registration-page.tsx b/src/features/auth-login/components/registration-page.tsx index db5f53a05..589fbeed2 100644 --- a/src/features/auth-login/components/registration-page.tsx +++ b/src/features/auth-login/components/registration-page.tsx @@ -1,15 +1,24 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; +import { Redirect } from 'react-router-dom'; +import { openModal } from 'soapbox/actions/modals'; import { BigCard } from 'soapbox/components/big-card'; import { Text } from 'soapbox/components/ui'; -import { useInstance, useRegistrationStatus } from 'soapbox/hooks'; +import { useAppDispatch, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks'; import RegistrationForm from './registration-form'; const RegistrationPage: React.FC = () => { const instance = useInstance(); const { isOpen } = useRegistrationStatus(); + const { nostrSignup } = useFeatures(); + const dispatch = useAppDispatch(); + + if (nostrSignup) { + setTimeout(() => dispatch(openModal('NOSTR_SIGNUP')), 100); + return ; + } if (!isOpen) { return ( diff --git a/src/features/ui/components/panels/sign-up-panel.tsx b/src/features/ui/components/panels/sign-up-panel.tsx index 203c84987..eaf30b41c 100644 --- a/src/features/ui/components/panels/sign-up-panel.tsx +++ b/src/features/ui/components/panels/sign-up-panel.tsx @@ -3,10 +3,11 @@ import { FormattedMessage } from 'react-intl'; import { openModal } from 'soapbox/actions/modals'; import { Button, Stack, Text } from 'soapbox/components/ui'; -import { useAppDispatch, useAppSelector, useInstance, useRegistrationStatus } from 'soapbox/hooks'; +import { useAppDispatch, useAppSelector, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks'; const SignUpPanel = () => { const instance = useInstance(); + const { nostrSignup } = useFeatures(); const { isOpen } = useRegistrationStatus(); const me = useAppSelector((state) => state.me); const dispatch = useAppDispatch(); @@ -25,7 +26,12 @@ const SignUpPanel = () => { -