mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 08:23:34 +00:00
Replace complex Nostr login/signup modals with simpler Soapbox/Ditto-inspired design
- Created SimpleLoginDialog and SimpleSignupDialog with clean, minimal design - Simplified step-based flow similar to Soapbox/Ditto implementation - Reduced visual complexity while maintaining all functionality - Updated LoginArea and NostrSettings to use new simple modals - Updated tests to reference new components - All tests passing
This commit is contained in:
1 parent
d3e257f759
commit
ce29d036ad
5 files changed
+664
-10
No files matched your search
@@ -35,12 +35,12 @@ vi.mock('@/components/RelaySelector', () => ({
|
||||
)
|
||||
}));
|
||||
|
||||
vi.mock('./LoginDialog', () => ({
|
||||
vi.mock('./SimpleLoginDialog', () => ({
|
||||
default: ({ isOpen }: { isOpen: boolean; onClose: () => void }) =>
|
||||
isOpen ? <div data-testid="login-dialog">Login Dialog</div> : null
|
||||
}));
|
||||
|
||||
vi.mock('./SignupDialog', () => ({
|
||||
vi.mock('./SimpleSignupDialog', () => ({
|
||||
default: ({ isOpen }: { isOpen: boolean; onClose: () => void }) =>
|
||||
isOpen ? <div data-testid="signup-dialog">Signup Dialog</div> : null
|
||||
}));
|
||||
|
||||
@@ -12,8 +12,8 @@ import {
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu.tsx';
|
||||
import { Avatar, AvatarFallback } from '@/components/ui/avatar.tsx';
|
||||
import LoginDialog from './LoginDialog';
|
||||
import SignupDialog from './SignupDialog';
|
||||
import SimpleLoginDialog from './SimpleLoginDialog';
|
||||
import SimpleSignupDialog from './SimpleSignupDialog';
|
||||
import { useLoggedInAccounts } from '@/hooks/useLoggedInAccounts';
|
||||
import { AccountSwitcher } from './AccountSwitcher';
|
||||
import { cn } from '@/lib/utils';
|
||||
@@ -88,14 +88,14 @@ export function LoginArea({ className }: LoginAreaProps) {
|
||||
</DropdownMenu>
|
||||
)}
|
||||
|
||||
<LoginDialog
|
||||
<SimpleLoginDialog
|
||||
isOpen={loginDialogOpen}
|
||||
onClose={() => setLoginDialogOpen(false)}
|
||||
onLogin={handleLogin}
|
||||
onSignup={() => setSignupDialogOpen(true)}
|
||||
/>
|
||||
|
||||
<SignupDialog
|
||||
<SimpleSignupDialog
|
||||
isOpen={signupDialogOpen}
|
||||
onClose={() => setSignupDialogOpen(false)}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,339 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Shield, Key, Cloud, AlertTriangle } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { useLoginActions } from '@/hooks/useLoginActions';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
type Step = 'extension' | 'key-add';
|
||||
|
||||
interface SimpleLoginDialogProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onLogin: () => void;
|
||||
onSignup?: () => void;
|
||||
}
|
||||
|
||||
const validateNsec = (nsec: string) => {
|
||||
return /^nsec1[a-zA-Z0-9]{58}$/.test(nsec);
|
||||
};
|
||||
|
||||
const validateBunkerUri = (uri: string) => {
|
||||
return uri.startsWith('bunker://');
|
||||
};
|
||||
|
||||
const SimpleLoginDialog: React.FC<SimpleLoginDialogProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onLogin,
|
||||
onSignup
|
||||
}) => {
|
||||
const [step, setStep] = useState<Step>('extension');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [nsec, setNsec] = useState('');
|
||||
const [bunkerUri, setBunkerUri] = useState('');
|
||||
const [activeTab, setActiveTab] = useState<'nsec' | 'bunker'>('nsec');
|
||||
const [errors, setErrors] = useState<{
|
||||
nsec?: string;
|
||||
bunker?: string;
|
||||
extension?: string;
|
||||
}>({});
|
||||
|
||||
const login = useLoginActions();
|
||||
|
||||
// Reset state when dialog opens/closes
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setStep(window.nostr ? 'extension' : 'key-add');
|
||||
setIsLoading(false);
|
||||
setNsec('');
|
||||
setBunkerUri('');
|
||||
setActiveTab('nsec');
|
||||
setErrors({});
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
const handleExtensionLogin = async () => {
|
||||
setIsLoading(true);
|
||||
setErrors(prev => ({ ...prev, extension: undefined }));
|
||||
|
||||
try {
|
||||
if (!('nostr' in window)) {
|
||||
throw new Error('Nostr extension not found. Please install a NIP-07 extension.');
|
||||
}
|
||||
await login.extension();
|
||||
onLogin();
|
||||
onClose();
|
||||
} catch (e: unknown) {
|
||||
const error = e as Error;
|
||||
setErrors(prev => ({
|
||||
...prev,
|
||||
extension: error instanceof Error ? error.message : 'Extension login failed'
|
||||
}));
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleKeyLogin = () => {
|
||||
if (!nsec.trim()) {
|
||||
setErrors(prev => ({ ...prev, nsec: 'Please enter your secret key' }));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validateNsec(nsec)) {
|
||||
setErrors(prev => ({ ...prev, nsec: 'Invalid secret key format. Must be a valid nsec starting with nsec1.' }));
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
setErrors({});
|
||||
|
||||
setTimeout(() => {
|
||||
try {
|
||||
login.nsec(nsec);
|
||||
onLogin();
|
||||
onClose();
|
||||
} catch {
|
||||
setErrors({ nsec: "Failed to login with this key. Please check that it's correct." });
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, 50);
|
||||
};
|
||||
|
||||
const handleBunkerLogin = async () => {
|
||||
if (!bunkerUri.trim()) {
|
||||
setErrors(prev => ({ ...prev, bunker: 'Please enter a bunker URI' }));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!validateBunkerUri(bunkerUri)) {
|
||||
setErrors(prev => ({ ...prev, bunker: 'Invalid bunker URI format. Must start with bunker://' }));
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
setErrors(prev => ({ ...prev, bunker: undefined }));
|
||||
|
||||
try {
|
||||
await login.bunker(bunkerUri);
|
||||
onLogin();
|
||||
onClose();
|
||||
setBunkerUri('');
|
||||
} catch {
|
||||
setErrors(prev => ({
|
||||
...prev,
|
||||
bunker: 'Failed to connect to bunker. Please check the URI.'
|
||||
}));
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSignupClick = () => {
|
||||
onClose();
|
||||
if (onSignup) {
|
||||
onSignup();
|
||||
}
|
||||
};
|
||||
|
||||
if (step === 'extension') {
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">Log in</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-col items-center space-y-6 py-6">
|
||||
<div className="text-center">
|
||||
<h3 className="font-semibold mb-2">Welcome to Shakespeare</h3>
|
||||
</div>
|
||||
|
||||
<div className="w-32 h-32 flex items-center justify-center">
|
||||
<Shield className="w-16 h-16 text-primary" />
|
||||
</div>
|
||||
|
||||
{errors.extension && (
|
||||
<Alert variant="destructive" className="w-full">
|
||||
<AlertTriangle className="h-4 w-4" />
|
||||
<AlertDescription>{errors.extension}</AlertDescription>
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<div className="flex flex-col space-y-3 w-full">
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={handleExtensionLogin}
|
||||
disabled={isLoading}
|
||||
className="w-full"
|
||||
>
|
||||
{isLoading ? 'Logging in...' : 'Log in with extension'}
|
||||
</Button>
|
||||
|
||||
<div className="relative">
|
||||
<div className="absolute inset-0 flex items-center">
|
||||
<div className="w-full border-t"></div>
|
||||
</div>
|
||||
<div className="relative flex justify-center text-xs uppercase">
|
||||
<span className="bg-background px-2 text-muted-foreground">or</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setStep('key-add')}
|
||||
className="w-full"
|
||||
>
|
||||
<AlertTriangle className="w-4 h-4 mr-2" />
|
||||
Log in with key
|
||||
</Button>
|
||||
|
||||
<div className="flex justify-center space-x-2 text-xs">
|
||||
<span className="text-muted-foreground">New on Shakespeare?</span>
|
||||
<button
|
||||
onClick={handleSignupClick}
|
||||
className="text-blue-500 hover:underline"
|
||||
>
|
||||
Sign Up
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">Import Key</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-col items-center space-y-6 py-6">
|
||||
<div className="w-32 h-32 flex items-center justify-center">
|
||||
<Key className="w-16 h-16 text-primary" />
|
||||
</div>
|
||||
|
||||
<div className="w-full space-y-4">
|
||||
{/* Tab selector */}
|
||||
<div className="flex space-x-1 bg-muted rounded-lg p-1">
|
||||
<button
|
||||
onClick={() => setActiveTab('nsec')}
|
||||
className={cn(
|
||||
"flex-1 px-3 py-2 text-sm font-medium rounded-md transition-colors",
|
||||
activeTab === 'nsec'
|
||||
? "bg-background text-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground"
|
||||
)}
|
||||
>
|
||||
Secret Key
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('bunker')}
|
||||
className={cn(
|
||||
"flex-1 px-3 py-2 text-sm font-medium rounded-md transition-colors",
|
||||
activeTab === 'bunker'
|
||||
? "bg-background text-foreground shadow-sm"
|
||||
: "text-muted-foreground hover:text-foreground"
|
||||
)}
|
||||
>
|
||||
Bunker
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{activeTab === 'nsec' && (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Input
|
||||
type="password"
|
||||
value={nsec}
|
||||
onChange={(e) => {
|
||||
setNsec(e.target.value);
|
||||
if (errors.nsec) setErrors(prev => ({ ...prev, nsec: undefined }));
|
||||
}}
|
||||
placeholder="nsec1..."
|
||||
className={errors.nsec ? 'border-red-500' : ''}
|
||||
/>
|
||||
{errors.nsec && (
|
||||
<p className="text-sm text-red-500">{errors.nsec}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={handleKeyLogin}
|
||||
disabled={isLoading || !nsec.trim()}
|
||||
className="w-full"
|
||||
>
|
||||
{isLoading ? 'Verifying...' : 'Add Key'}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'bunker' && (
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Input
|
||||
value={bunkerUri}
|
||||
onChange={(e) => {
|
||||
setBunkerUri(e.target.value);
|
||||
if (errors.bunker) setErrors(prev => ({ ...prev, bunker: undefined }));
|
||||
}}
|
||||
placeholder="bunker://"
|
||||
className={errors.bunker ? 'border-red-500' : ''}
|
||||
/>
|
||||
{errors.bunker && (
|
||||
<p className="text-sm text-red-500">{errors.bunker}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={handleBunkerLogin}
|
||||
disabled={isLoading || !bunkerUri.trim()}
|
||||
className="w-full"
|
||||
>
|
||||
<Cloud className="w-4 h-4 mr-2" />
|
||||
{isLoading ? 'Connecting...' : 'Connect'}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="relative">
|
||||
<div className="absolute inset-0 flex items-center">
|
||||
<div className="w-full border-t"></div>
|
||||
</div>
|
||||
<div className="relative flex justify-center text-xs uppercase">
|
||||
<span className="bg-background px-2 text-muted-foreground">or</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Extension indicator */}
|
||||
<div className="rounded-lg bg-muted p-3">
|
||||
<p className="text-xs text-center">
|
||||
{window.nostr ? (
|
||||
<button
|
||||
onClick={handleExtensionLogin}
|
||||
className="text-blue-500 hover:underline"
|
||||
disabled={isLoading}
|
||||
>
|
||||
Sign in with browser extension
|
||||
</button>
|
||||
) : (
|
||||
'Browser extension not found.'
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default SimpleLoginDialog;
|
||||
@@ -0,0 +1,315 @@
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import { Key, Download, UserPlus, Shield } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { toast } from '@/hooks/useToast';
|
||||
import { useLoginActions } from '@/hooks/useLoginActions';
|
||||
import { generateSecretKey, nip19 } from 'nostr-tools';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
type Step = 'extension' | 'key' | 'keygen';
|
||||
|
||||
interface SimpleSignupDialogProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
onComplete?: () => void;
|
||||
}
|
||||
|
||||
const SimpleSignupDialog: React.FC<SimpleSignupDialogProps> = ({
|
||||
isOpen,
|
||||
onClose,
|
||||
onComplete
|
||||
}) => {
|
||||
const [step, setStep] = useState<Step>('key');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [downloaded, setDownloaded] = useState(false);
|
||||
|
||||
const login = useLoginActions();
|
||||
|
||||
// Generate key once and keep it stable
|
||||
const secretKey = useMemo(() => generateSecretKey(), []);
|
||||
const nsec = useMemo(() => nip19.nsecEncode(secretKey), [secretKey]);
|
||||
|
||||
// Reset state when dialog opens/closes
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setStep(window.nostr ? 'extension' : 'key');
|
||||
setIsLoading(false);
|
||||
setDownloaded(false);
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
const handleExtensionSignup = async () => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
if (!('nostr' in window)) {
|
||||
throw new Error('Nostr extension not found. Please install a NIP-07 extension.');
|
||||
}
|
||||
await login.extension();
|
||||
onClose();
|
||||
if (onComplete) {
|
||||
setTimeout(() => {
|
||||
onComplete();
|
||||
}, 600);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
const error = e as Error;
|
||||
toast({
|
||||
title: 'Extension signup failed',
|
||||
description: error instanceof Error ? error.message : 'Extension signup failed',
|
||||
variant: 'destructive',
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleDownload = () => {
|
||||
try {
|
||||
const blob = new Blob([nsec], { type: 'text/plain; charset=utf-8' });
|
||||
const url = globalThis.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'secret-key.txt';
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
globalThis.URL.revokeObjectURL(url);
|
||||
document.body.removeChild(a);
|
||||
setDownloaded(true);
|
||||
toast({
|
||||
title: 'Secret Key Saved!',
|
||||
description: 'Your key has been safely stored.',
|
||||
});
|
||||
} catch {
|
||||
toast({
|
||||
title: 'Download failed',
|
||||
description: 'Could not download the key file. Please copy it manually.',
|
||||
variant: 'destructive',
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleNext = async () => {
|
||||
setIsLoading(true);
|
||||
try {
|
||||
login.nsec(nsec);
|
||||
|
||||
// Mark signup completion time for fallback welcome modal
|
||||
localStorage.setItem('signup_completed', Date.now().toString());
|
||||
|
||||
onClose();
|
||||
if (onComplete) {
|
||||
setTimeout(() => {
|
||||
onComplete();
|
||||
}, 600);
|
||||
}
|
||||
} catch {
|
||||
toast({
|
||||
title: 'Login Failed',
|
||||
description: 'Failed to login with the generated key. Please try again.',
|
||||
variant: 'destructive',
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLoginClick = () => {
|
||||
onClose();
|
||||
// This would typically open the login modal
|
||||
// Since we don't have direct access to the login modal state here,
|
||||
// we'll rely on the parent component to handle this
|
||||
};
|
||||
|
||||
if (step === 'extension') {
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">Sign up</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-col items-center space-y-6 py-6">
|
||||
<div className="text-center">
|
||||
<h3 className="font-semibold mb-2">Welcome to Shakespeare</h3>
|
||||
</div>
|
||||
|
||||
<div className="w-32 h-32 flex items-center justify-center">
|
||||
<Shield className="w-16 h-16 text-primary" />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col space-y-3 w-full">
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={handleExtensionSignup}
|
||||
disabled={isLoading}
|
||||
className="w-full"
|
||||
>
|
||||
{isLoading ? 'Signing up...' : 'Sign up with extension'}
|
||||
</Button>
|
||||
|
||||
<div className="relative">
|
||||
<div className="absolute inset-0 flex items-center">
|
||||
<div className="w-full border-t"></div>
|
||||
</div>
|
||||
<div className="relative flex justify-center text-xs uppercase">
|
||||
<span className="bg-background px-2 text-muted-foreground">or</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => setStep('key')}
|
||||
className="w-full"
|
||||
>
|
||||
Don't have an extension?
|
||||
</Button>
|
||||
|
||||
<div className="flex justify-center space-x-2 text-xs">
|
||||
<span className="text-muted-foreground">New on Shakespeare?</span>
|
||||
<button
|
||||
onClick={handleLoginClick}
|
||||
className="text-blue-500 hover:underline"
|
||||
>
|
||||
Sign Up
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
if (step === 'key') {
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">Sign up</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-col items-center space-y-6 py-6">
|
||||
<div className="text-center">
|
||||
<h3 className="font-semibold mb-2">You need a key to continue</h3>
|
||||
</div>
|
||||
|
||||
<div className="w-32 h-32 flex items-center justify-center">
|
||||
<Key className="w-16 h-16 text-primary" />
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col space-y-3 w-full">
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={() => setStep('keygen')}
|
||||
className="w-full"
|
||||
>
|
||||
<UserPlus className="w-4 h-4 mr-2" />
|
||||
Generate key
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={handleLoginClick}
|
||||
className="w-full"
|
||||
>
|
||||
I already have a key
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="relative w-full">
|
||||
<div className="absolute inset-0 flex items-center">
|
||||
<div className="w-full border-t"></div>
|
||||
</div>
|
||||
<div className="relative flex justify-center text-xs uppercase">
|
||||
<span className="bg-background px-2 text-muted-foreground">or</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Extension indicator */}
|
||||
<div className="rounded-lg bg-muted p-3 w-full">
|
||||
<p className="text-xs text-center">
|
||||
{window.nostr ? (
|
||||
<button
|
||||
onClick={handleExtensionSignup}
|
||||
className="text-blue-500 hover:underline"
|
||||
disabled={isLoading}
|
||||
>
|
||||
Sign up with browser extension
|
||||
</button>
|
||||
) : (
|
||||
'Browser extension not found.'
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className="max-w-sm">
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-center">Your new key</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-col items-center space-y-6 py-6">
|
||||
<div className="w-32 h-32 flex items-center justify-center">
|
||||
<Key className="w-16 h-16 text-primary" />
|
||||
</div>
|
||||
|
||||
<div className="w-full space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">Secret Key</label>
|
||||
<Input
|
||||
type="password"
|
||||
value={nsec}
|
||||
readOnly
|
||||
className="font-mono"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="rounded-xl bg-muted p-4">
|
||||
<p className="text-xs text-justify">
|
||||
Back up your secret key in a secure place. If lost, your account cannot be recovered.
|
||||
Never share your secret key with anyone.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex space-x-3 justify-center">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="lg"
|
||||
onClick={handleDownload}
|
||||
className="flex-1"
|
||||
>
|
||||
<Download className="w-4 h-4 mr-2" />
|
||||
Download key
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={handleNext}
|
||||
disabled={!downloaded || isLoading}
|
||||
className={cn(
|
||||
"flex-1",
|
||||
!downloaded && "opacity-50 cursor-not-allowed"
|
||||
)}
|
||||
title={!downloaded ? "Download your key to continue" : ""}
|
||||
>
|
||||
{isLoading ? 'Setting up...' : 'Next'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default SimpleSignupDialog;
|
||||
@@ -6,8 +6,8 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { RelaySelector } from '@/components/RelaySelector';
|
||||
import LoginDialog from '@/components/auth/LoginDialog';
|
||||
import SignupDialog from '@/components/auth/SignupDialog';
|
||||
import SimpleLoginDialog from '@/components/auth/SimpleLoginDialog';
|
||||
import SimpleSignupDialog from '@/components/auth/SimpleSignupDialog';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts';
|
||||
@@ -207,7 +207,7 @@ export function NostrSettings() {
|
||||
</div>
|
||||
|
||||
{/* Login Dialog */}
|
||||
<LoginDialog
|
||||
<SimpleLoginDialog
|
||||
isOpen={showLoginDialog}
|
||||
onClose={() => setShowLoginDialog(false)}
|
||||
onLogin={handleLoginSuccess}
|
||||
@@ -218,7 +218,7 @@ export function NostrSettings() {
|
||||
/>
|
||||
|
||||
{/* Signup Dialog */}
|
||||
<SignupDialog
|
||||
<SimpleSignupDialog
|
||||
isOpen={showSignupDialog}
|
||||
onClose={() => setShowSignupDialog(false)}
|
||||
onComplete={handleSignupComplete}
|
||||
|
||||
Reference in new issue
Block a user