From 899c20631a0bb59649f2f4615044b5168d202984 Mon Sep 17 00:00:00 2001 From: Nicolas Cantu Date: Thu, 8 Jan 2026 23:53:05 +0100 Subject: [PATCH] lint fix wip --- components/CreateSeriesModal.tsx | 226 +----------------- components/ReviewForm.tsx | 173 +------------- components/ReviewTipForm.tsx | 150 +----------- .../CreateSeriesModalView.tsx | 220 +++++++++++++++++ .../createSeriesModalTypes.ts | 21 ++ .../useCreateSeriesModalController.ts | 154 ++++++++++++ .../reviewForms/ConnectRequiredCard.tsx | 16 ++ components/reviewForms/ReviewFormView.tsx | 132 ++++++++++ components/reviewForms/ReviewTipFormView.tsx | 65 +++++ components/reviewForms/reviewFormTypes.ts | 14 ++ .../reviewForms/useReviewFormController.ts | 166 +++++++++++++ .../reviewForms/useReviewTipFormController.ts | 83 +++++++ hooks/useArticlePublishing.ts | 94 +++++--- lib/accessControl.ts | 35 ++- lib/relayRotation.ts | 130 +++++----- lib/versionManager.ts | 74 +++--- pages/series/[id].tsx | 73 ++++-- 17 files changed, 1159 insertions(+), 667 deletions(-) create mode 100644 components/createSeriesModal/CreateSeriesModalView.tsx create mode 100644 components/createSeriesModal/createSeriesModalTypes.ts create mode 100644 components/createSeriesModal/useCreateSeriesModalController.ts create mode 100644 components/reviewForms/ConnectRequiredCard.tsx create mode 100644 components/reviewForms/ReviewFormView.tsx create mode 100644 components/reviewForms/ReviewTipFormView.tsx create mode 100644 components/reviewForms/reviewFormTypes.ts create mode 100644 components/reviewForms/useReviewFormController.ts create mode 100644 components/reviewForms/useReviewTipFormController.ts diff --git a/components/CreateSeriesModal.tsx b/components/CreateSeriesModal.tsx index 3e20394..58e4d31 100644 --- a/components/CreateSeriesModal.tsx +++ b/components/CreateSeriesModal.tsx @@ -1,227 +1,11 @@ -import { useState } from 'react' -import { ImageUploadField } from './ImageUploadField' -import { publishSeries } from '@/lib/articleMutations' -import { useNostrAuth } from '@/hooks/useNostrAuth' -import { nostrService } from '@/lib/nostr' -import { t } from '@/lib/i18n' -import type { ArticleDraft } from '@/lib/articlePublisherTypes' - -interface CreateSeriesModalProps { - isOpen: boolean - onClose: () => void - onSuccess: () => void - authorPubkey: string -} - -interface SeriesDraft { - title: string - description: string - preview: string - coverUrl: string - category: ArticleDraft['category'] -} +import type { CreateSeriesModalProps } from './createSeriesModal/createSeriesModalTypes' +import { CreateSeriesModalView } from './createSeriesModal/CreateSeriesModalView' +import { useCreateSeriesModalController } from './createSeriesModal/useCreateSeriesModalController' export function CreateSeriesModal({ isOpen, onClose, onSuccess, authorPubkey }: CreateSeriesModalProps): React.ReactElement | null { - const { pubkey, isUnlocked } = useNostrAuth() - const [draft, setDraft] = useState({ - title: '', - description: '', - preview: '', - coverUrl: '', - category: 'science-fiction', - }) - const [loading, setLoading] = useState(false) - const [error, setError] = useState(null) - + const ctrl = useCreateSeriesModalController({ authorPubkey, onClose, onSuccess, isOpen }) if (!isOpen) { return null } - - const privateKey = nostrService.getPrivateKey() - const canPublish = pubkey === authorPubkey && isUnlocked && privateKey !== null - - const handleSubmit = async (e: React.FormEvent): Promise => { - e.preventDefault() - if (!canPublish) { - setError(t('series.create.error.notAuthor')) - return - } - - if (!draft.title.trim() || !draft.description.trim() || !draft.preview.trim()) { - setError(t('series.create.error.missingFields')) - return - } - - setLoading(true) - setError(null) - - try { - if (!privateKey) { - setError(t('series.create.error.notAuthor')) - return - } - await publishSeries({ - title: draft.title, - description: draft.description, - preview: draft.preview, - ...(draft.coverUrl ? { coverUrl: draft.coverUrl } : {}), - category: draft.category, - authorPubkey, - authorPrivateKey: privateKey, - }) - // Reset form - setDraft({ - title: '', - description: '', - preview: '', - coverUrl: '', - category: 'science-fiction', - }) - onSuccess() - onClose() - } catch (submitError) { - setError(submitError instanceof Error ? submitError.message : t('series.create.error.publishFailed')) - } finally { - setLoading(false) - } - } - - const handleClose = (): void => { - if (!loading) { - setDraft({ - title: '', - description: '', - preview: '', - coverUrl: '', - category: 'science-fiction', - }) - setError(null) - onClose() - } - } - - return ( -
-
-
-

{t('series.create.title')}

- -
- - {!canPublish && ( -
-

{t('series.create.error.notAuthor')}

-
- )} - -
{ - void handleSubmit(e) - }} className="space-y-4"> -
- - setDraft({ ...draft, title: e.target.value })} - className="w-full px-3 py-2 bg-cyber-darker border border-cyber-accent/30 rounded text-cyber-light focus:border-neon-cyan focus:outline-none" - required - disabled={loading || !canPublish} - /> -
- -
- -