Remove obsolete 'Connect with Nostr' message from presentation page
**Motivations :** * Remove outdated message that appears after account creation/import * Clean up dead code and unused translation keys * Simplify presentation page UX now that key creation/import is available **Root causes :** * Message 'Connectez-vous avec Nostr pour créer votre article de présentation' was displayed even when account exists * NotConnected component and translation keys were no longer needed after implementing key creation/import **Correctifs :** * Removed NotConnected component and its message * Removed presentation.notConnected translation keys from all locale files * Simplified display to show ConnectButton directly when no pubkey is available * Added auto-loading of pubkey when account exists but pubkey not yet loaded **Evolutions :** * Presentation form now displays immediately when account exists (even if not unlocked) * Better UX: users can see the form and will get error message if they try to publish without unlocking **Page affectées :** * components/AuthorPresentationEditor.tsx * locales/fr.txt * locales/en.txt * public/locales/fr.txt * public/locales/en.txt
This commit is contained in:
parent
8f855fa61b
commit
aa21dc3ad6
@ -1,4 +1,4 @@
|
||||
import { useState, useCallback } from 'react'
|
||||
import { useState, useCallback, useEffect, type FormEvent } from 'react'
|
||||
import { useNostrAuth } from '@/hooks/useNostrAuth'
|
||||
import { useAuthorPresentation } from '@/hooks/useAuthorPresentation'
|
||||
import { ArticleField } from './ArticleField'
|
||||
@ -17,19 +17,6 @@ interface AuthorPresentationDraft {
|
||||
|
||||
const ADDRESS_PATTERN = /^(1|3|bc1)[a-zA-Z0-9]{25,62}$/
|
||||
|
||||
function NotConnected() {
|
||||
return (
|
||||
<div className="border border-neon-cyan/20 rounded-lg p-6 bg-cyber-dark/50">
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<p className="text-center text-cyber-accent">
|
||||
{t('presentation.notConnected')}
|
||||
</p>
|
||||
<ConnectButton />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function SuccessNotice() {
|
||||
return (
|
||||
<div className="border border-neon-green/50 rounded-lg p-6 bg-neon-green/10">
|
||||
@ -162,12 +149,12 @@ function PresentationForm({
|
||||
validationError: string | null
|
||||
error: string | null
|
||||
loading: boolean
|
||||
handleSubmit: (e: React.FormEvent) => Promise<void>
|
||||
handleSubmit: (e: FormEvent<HTMLFormElement>) => Promise<void>
|
||||
userName: string
|
||||
}) {
|
||||
return (
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
onSubmit={(e: FormEvent<HTMLFormElement>) => {
|
||||
void handleSubmit(e)
|
||||
}}
|
||||
className="border border-neon-cyan/20 rounded-lg p-6 bg-cyber-dark space-y-4"
|
||||
@ -190,7 +177,7 @@ function useAuthorPresentationState(pubkey: string | null) {
|
||||
const [validationError, setValidationError] = useState<string | null>(null)
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
async (e: React.FormEvent) => {
|
||||
async (e: FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault()
|
||||
const address = draft.mainnetAddress.trim()
|
||||
if (!ADDRESS_PATTERN.test(address)) {
|
||||
@ -217,8 +204,14 @@ function AuthorPresentationFormView({
|
||||
}) {
|
||||
const state = useAuthorPresentationState(pubkey)
|
||||
|
||||
if (!connected || !pubkey) {
|
||||
return <NotConnected />
|
||||
if (!pubkey) {
|
||||
return (
|
||||
<div className="border border-neon-cyan/20 rounded-lg p-6 bg-cyber-dark/50">
|
||||
<div className="flex flex-col items-center gap-4">
|
||||
<ConnectButton />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (state.success) {
|
||||
return <SuccessNotice />
|
||||
@ -240,7 +233,16 @@ function AuthorPresentationFormView({
|
||||
)
|
||||
}
|
||||
|
||||
function useAutoLoadPubkey(accountExists: boolean | null, pubkey: string | null, connect: () => Promise<void>) {
|
||||
useEffect(() => {
|
||||
if (accountExists === true && !pubkey) {
|
||||
void connect()
|
||||
}
|
||||
}, [accountExists, pubkey, connect])
|
||||
}
|
||||
|
||||
export function AuthorPresentationEditor() {
|
||||
const { connected, pubkey, profile } = useNostrAuth()
|
||||
const { connected, pubkey, profile, accountExists, connect } = useNostrAuth()
|
||||
useAutoLoadPubkey(accountExists, pubkey ?? null, connect)
|
||||
return <AuthorPresentationFormView pubkey={pubkey ?? null} connected={connected} profile={profile} />
|
||||
}
|
||||
|
||||
@ -59,7 +59,6 @@ presentation.title=Create your presentation article
|
||||
presentation.description=This article is required to publish on zapwall.fr. It allows readers to know you and sponsor you.
|
||||
presentation.success=Presentation article created!
|
||||
presentation.successMessage=Your presentation article has been created successfully. You can now publish articles.
|
||||
presentation.notConnected=Connect with Nostr to create your presentation article
|
||||
presentation.profileNote=This profile data is specific to zapwall.fr and may differ from your Nostr profile.
|
||||
presentation.field.picture=Profile picture
|
||||
presentation.field.picture.help=Profile image for your author page (max 5MB, formats: PNG, JPG, WebP)
|
||||
|
||||
@ -60,7 +60,6 @@ presentation.description=Cet article est obligatoire pour publier sur zapwall.fr
|
||||
presentation.profileNote=Les données de ce profil sont spécifiques à zapwall.fr et peuvent différer de votre profil Nostr.
|
||||
presentation.success=Article de présentation créé !
|
||||
presentation.successMessage=Votre article de présentation a été créé avec succès. Vous pouvez maintenant publier des articles.
|
||||
presentation.notConnected=Connectez-vous avec Nostr pour créer votre article de présentation
|
||||
|
||||
# Filters
|
||||
filters.clear=Effacer tout
|
||||
|
||||
@ -59,7 +59,6 @@ presentation.title=Create your presentation article
|
||||
presentation.description=This article is required to publish on zapwall.fr. It allows readers to know you and sponsor you.
|
||||
presentation.success=Presentation article created!
|
||||
presentation.successMessage=Your presentation article has been created successfully. You can now publish articles.
|
||||
presentation.notConnected=Connect with Nostr to create your presentation article
|
||||
presentation.profileNote=This profile data is specific to zapwall.fr and may differ from your Nostr profile.
|
||||
presentation.field.picture=Profile picture
|
||||
presentation.field.picture.help=Profile image for your author page (max 5MB, formats: PNG, JPG, WebP)
|
||||
|
||||
@ -59,7 +59,6 @@ presentation.title=Créer votre article de présentation
|
||||
presentation.description=Cet article est obligatoire pour publier sur zapwall.fr. Il permet aux lecteurs de vous connaître et de vous sponsoriser.
|
||||
presentation.success=Article de présentation créé !
|
||||
presentation.successMessage=Votre article de présentation a été créé avec succès. Vous pouvez maintenant publier des articles.
|
||||
presentation.notConnected=Connectez-vous avec Nostr pour créer votre article de présentation
|
||||
presentation.profileNote=Les données de ce profil sont spécifiques à zapwall.fr et peuvent différer de votre profil Nostr.
|
||||
presentation.field.picture=Photo de profil
|
||||
presentation.field.picture.help=Image de profil pour votre page auteur (max 5Mo, formats: PNG, JPG, WebP)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user