- **Motivations :** Assurer passage du lint strict et clarifier la logique paiements/publications. - **Root causes :** Fonctions trop longues, promesses non gérées et typages WebLN/Nostr incomplets. - **Correctifs :** Refactor PaymentModal (handlers void), extraction helpers articlePublisher, simplification polling sponsoring/zap, corrections curly et awaits. - **Evolutions :** Nouveau module articlePublisherHelpers pour présentation/aiguillage contenu privé. - **Page affectées :** components/PaymentModal.tsx, lib/articlePublisher.ts, lib/articlePublisherHelpers.ts, lib/paymentPolling.ts, lib/sponsoring.ts, lib/nostrZapVerification.ts et dépendances liées.
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import React from 'react'
|
|
import type { ArticleCategory } from '@/types/nostr'
|
|
|
|
interface CategorySelectProps {
|
|
id: string
|
|
label: string
|
|
value: ArticleCategory | undefined
|
|
onChange: (value: ArticleCategory) => void
|
|
required?: boolean
|
|
helpText?: string
|
|
}
|
|
|
|
export function CategorySelect({
|
|
id,
|
|
label,
|
|
value,
|
|
onChange,
|
|
required = false,
|
|
helpText,
|
|
}: CategorySelectProps) {
|
|
return (
|
|
<div>
|
|
<label htmlFor={id} className="block text-sm font-medium text-gray-700 mb-1">
|
|
{label} {required && '*'}
|
|
</label>
|
|
<select
|
|
id={id}
|
|
value={value ?? ''}
|
|
onChange={(e) => onChange(e.target.value as ArticleCategory)}
|
|
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
|
required={required}
|
|
>
|
|
<option value="">Sélectionnez une catégorie</option>
|
|
<option value="science-fiction">Science-fiction</option>
|
|
<option value="scientific-research">Recherche scientifique</option>
|
|
</select>
|
|
{helpText && <p className="text-xs text-gray-500 mt-1">{helpText}</p>}
|
|
</div>
|
|
)
|
|
}
|