diff --git a/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx b/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx index c0c45a4ab3..215202ebf5 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx @@ -8,12 +8,14 @@ import KeyStep from './steps/key-step'; import KeygenStep from './steps/keygen-step'; import RegisterStep from './steps/register-step'; +type Step = 'extension' | 'identity' | 'key' | 'keygen' | 'account' | 'register'; + interface INostrSigninModal { onClose: (type?: string) => void; } const NostrSigninModal: React.FC = ({ onClose }) => { - const [step, setStep] = useState(window.nostr ? 0 : 1); + const [step, setStep] = useState(window.nostr ? 'extension' : 'identity'); const [, setSigner] = useState(); const [accountId, setAccountId] = useState(); @@ -21,21 +23,23 @@ const NostrSigninModal: React.FC = ({ onClose }) => { const handleClose = () => onClose('NOSTR_SIGNIN'); switch (step) { - case 0: + case 'extension': return ; - case 1: + case 'identity': return ; - case 2: + case 'key': return ; - case 3: - return ; - case 4: - return ; - case 5: + case 'keygen': return ; + case 'account': + return ; + case 'register': + return ; default: return null; } }; export default NostrSigninModal; + +export type { Step }; diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx index a69f6b635d..fcd023a2a6 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx @@ -6,9 +6,11 @@ import { useAccount } from 'soapbox/api/hooks'; import { Avatar, Text, Stack, Emoji, Button, Tooltip, Modal } from 'soapbox/components/ui'; import { useInstance } from 'soapbox/hooks'; +import { Step } from '../nostr-signin-modal'; + interface IAccountStep { accountId: string; - setStep(step: number): void; + setStep(step: Step): void; onClose(): void; } @@ -29,7 +31,7 @@ const AccountStep: React.FC = ({ accountId, setStep, onClose }) => } onClose={onClose} - onBack={() => setStep(1)} + onBack={() => setStep('identity')} > diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx index 1e5afd869d..82a9f43e51 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx @@ -6,9 +6,10 @@ import { Button, Stack, Modal } from 'soapbox/components/ui'; import { useAppDispatch } from 'soapbox/hooks'; import EmojiGraphic from '../components/emoji-graphic'; +import { Step } from '../nostr-signin-modal'; interface IExtensionStep { - setStep: (step: number) => void; + setStep: (step: Step) => void; onClose(): void; } @@ -16,7 +17,7 @@ const ExtensionStep: React.FC = ({ setStep, onClose }) => { const dispatch = useAppDispatch(); const onClick = () => dispatch(nostrExtensionLogIn()); - const onClickAlt = () => setStep(1); + const onClickAlt = () => setStep('identity'); return ( } onClose={onClose}> diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx index 97e7044367..91c12711da 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx @@ -7,10 +7,11 @@ import { useAppDispatch } from 'soapbox/hooks'; import EmojiGraphic from '../components/emoji-graphic'; import NostrExtensionIndicator from '../components/nostr-extension-indicator'; +import { Step } from '../nostr-signin-modal'; interface IIdentityStep { setAccountId(accountId: string): void; - setStep(step: number): void; + setStep(step: Step): void; onClose(): void; } @@ -32,7 +33,7 @@ const IdentityStep: React.FC = ({ setAccountId, setStep, onClose await dispatch(accountLookup(username)) .then((account) => { setAccountId(account.id); - setStep(3); + setStep('account'); setNotFound(false); setLoading(false); }) @@ -71,7 +72,7 @@ const IdentityStep: React.FC = ({ setAccountId, setStep, onClose - + - diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/keygen-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/keygen-step.tsx index d1e1055add..630068f08a 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/keygen-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/keygen-step.tsx @@ -10,10 +10,11 @@ import { download } from 'soapbox/utils/download'; import { slugify } from 'soapbox/utils/input'; import EmojiGraphic from '../components/emoji-graphic'; +import { Step } from '../nostr-signin-modal'; interface IKeygenStep { setSigner(signer: NostrSigner): void; - setStep(step: number): void; + setStep(step: Step): void; onClose(): void; }