From c9cf99e1662c412f0600f5ebf7e8b23461b4ff90 Mon Sep 17 00:00:00 2001 From: natreex Date: Sun, 16 Nov 2025 11:55:52 -0500 Subject: [PATCH] Update imports and Electron compatibility - Removed unnecessary React imports. - Adjusted package.json scripts for Electron integration. - Updated components to replace Next.js-specific imports with Electron-compatible alternatives. - Minor tsconfig.json changes for better compatibility. --- app/layout.tsx | 14 +-- app/page.tsx | 21 ++-- components/AlertBox.tsx | 2 +- components/AlertStack.tsx | 8 +- components/Collapse.tsx | 2 +- components/CreditMeters.tsx | 2 +- components/ExportBook.tsx | 2 +- components/GuideTour.tsx | 6 +- components/ListItem.tsx | 2 +- components/Modal.tsx | 2 +- components/NoPicture.tsx | 2 +- components/QSTextGeneratedPreview.tsx | 2 +- components/ScribeControllerBar.tsx | 2 +- components/ScribeFooterBar.tsx | 2 +- components/ScribeTopBar.tsx | 7 +- components/ShortStoryGenerator.tsx | 2 +- components/StaticAlert.tsx | 6 +- components/TermsOfUse.tsx | 14 +-- components/UserMenu.tsx | 2 +- components/book/AddNewBookForm.tsx | 2 +- components/book/BookCard.tsx | 11 +- components/book/BookList.tsx | 2 +- components/book/SearchBook.tsx | 2 +- .../book/settings/BookSettingSidebar.tsx | 12 +- components/book/settings/DeleteBook.tsx | 2 +- .../characters/CharacterComponent.tsx | 2 +- components/book/settings/goals/page.tsx | 2 +- .../settings/guide-line/GuideLineSetting.tsx | 2 +- .../settings/locations/LocationComponent.tsx | 2 +- components/book/settings/objects/page.tsx | 2 +- components/book/settings/story/Act.tsx | 2 +- components/book/settings/story/Issue.tsx | 2 +- .../book/settings/story/MainChapter.tsx | 2 +- .../book/settings/story/StorySetting.tsx | 2 +- .../book/settings/story/act/ActChapter.tsx | 2 +- .../settings/story/act/ActChaptersSection.tsx | 2 +- .../settings/story/act/ActDescription.tsx | 2 +- .../book/settings/story/act/ActIncidents.tsx | 2 +- .../book/settings/story/act/ActPlotPoints.tsx | 2 +- .../book/settings/world/WorldSetting.tsx | 2 +- components/editor/DraftCompanion.tsx | 2 +- components/editor/NoBookHome.tsx | 1 - components/editor/ScribeEditor.tsx | 2 +- components/editor/TextEditor.tsx | 2 +- components/editor/UserEditorSetting.tsx | 2 +- components/form/CheckBox.tsx | 2 +- components/form/DatePicker.tsx | 2 +- components/form/InlineAddInput.tsx | 2 +- components/form/NumberInput.tsx | 2 +- components/form/RadioBox.tsx | 2 +- components/form/SearchInputWithSelect.tsx | 2 +- components/form/SelectBox.tsx | 2 +- components/form/SuggestFieldInput.tsx | 2 +- components/form/TextInput.tsx | 2 +- components/form/TexteAreaInput.tsx | 2 +- components/ghostwriter/GhostWriter.tsx | 2 +- .../ghostwriter/GhostWriterSettings.tsx | 2 +- components/ghostwriter/GhostWriterTags.tsx | 2 +- components/input/SelectOptionField.tsx | 2 +- components/input/TextInputField.tsx | 2 +- components/leftbar/ScribeChapterComponent.tsx | 2 +- components/leftbar/ScribeLeftBar.tsx | 2 +- components/quillsense/QuillSenseComponent.tsx | 2 +- components/quillsense/modes/InspireMe.tsx | 2 +- .../quillsense/modes/QuillConversation.tsx | 2 +- components/quillsense/modes/QuillList.tsx | 2 +- components/quillsense/modes/Synonyms.tsx | 2 +- components/rightbar/AboutERitors.tsx | 2 +- components/rightbar/ComposerRightBar.tsx | 2 +- package-lock.json | 103 +++++++++++++++++- package.json | 9 +- tsconfig.json | 34 ++++-- 72 files changed, 237 insertions(+), 127 deletions(-) diff --git a/app/layout.tsx b/app/layout.tsx index 7828cef..f524906 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,15 +1,6 @@ -import type {Metadata} from "next"; import "./globals.css"; import {ReactNode} from "react"; -export const metadata: Metadata = { - title: "ERitors Scribe", - description: "Les meilleurs livres sont ceux qui ont le meilleur plan.", - icons: { - icon: "/eritors-favicon-white.png" - } -}; - export default function RootLayout( { children, @@ -18,6 +9,11 @@ export default function RootLayout( }>) { return ( + + ERitors Scribe + + + {children} diff --git a/app/page.tsx b/app/page.tsx index 748cffb..86bb502 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,5 +1,5 @@ 'use client'; -import React, {useContext, useEffect, useState} from 'react'; +import {useContext, useEffect, useState} from 'react'; import {BookContext} from "@/context/BookContext"; import {ChapterProps} from "@/lib/models/Chapter"; import {ChapterContext} from '@/context/ChapterContext'; @@ -14,8 +14,7 @@ import {SessionContext} from '@/context/SessionContext'; import {SessionProps} from "@/lib/models/Session"; import User, {UserProps} from "@/lib/models/User"; import {BookProps} from "@/lib/models/Book"; -import {AppRouterInstance} from "next/dist/shared/lib/app-router-context.shared-runtime"; -import {useRouter} from "next/navigation"; +// Removed Next.js router imports for Electron import ScribeTopBar from "@/components/ScribeTopBar"; import ScribeControllerBar from "@/components/ScribeControllerBar"; import ScribeLeftBar from "@/components/leftbar/ScribeLeftBar"; @@ -28,7 +27,7 @@ import {faBookMedical, faFeather} from "@fortawesome/free-solid-svg-icons"; import TermsOfUse from "@/components/TermsOfUse"; import frMessages from '@/lib/locales/fr.json'; import enMessages from '@/lib/locales/en.json'; -import Image from "next/image"; +// Removed Next.js Image import for Electron import {NextIntlClientProvider, useTranslations} from "next-intl"; import {LangContext} from "@/context/LangContext"; import {AIUsageContext} from "@/context/AIUsageContext"; @@ -41,7 +40,7 @@ const messagesMap = { function ScribeContent() { const t = useTranslations(); const {lang: locale} = useContext(LangContext); - const {errorMessage, successMessage} = useContext(AlertContext); + const {errorMessage} = useContext(AlertContext); const editor: Editor | null = useEditor({ extensions: [ StarterKit, @@ -54,7 +53,7 @@ function ScribeContent() { immediatelyRender: false, }); - const router: AppRouterInstance = useRouter(); + // Router removed for Electron - using window.location instead const [session, setSession] = useState({user: null, accessToken: '', isConnected: false}); const [currentChapter, setCurrentChapter] = useState(undefined); const [currentBook, setCurrentBook] = useState(null); @@ -147,7 +146,7 @@ function ScribeContent() { setIsLoading(false); } else { if (sessionAttempts > 2) { - router.push('/'); + // Redirect handled by checkAuthentification } } setSessionAttempts(sessionAttempts + 1); @@ -202,10 +201,12 @@ function ScribeContent() { } else { errorMessage(t("homePage.errors.authenticationError")); } - window.location.href = 'https://eritors.com/login'; + // TODO: Afficher la fenêtre de login Electron + console.log('Pas de session - afficher login Electron'); } } else { - window.location.href = 'https://eritors.com/login'; + // TODO: Afficher la fenêtre de login Electron + console.log('Pas de token - afficher login Electron'); } } @@ -262,7 +263,7 @@ function ScribeContent() { className="bg-background text-text-primary h-screen flex flex-col items-center justify-center font-['Lora']">
- ERitors Logo + ERitors Logo
diff --git a/components/AlertBox.tsx b/components/AlertBox.tsx index 3b38292..7bfcf90 100644 --- a/components/AlertBox.tsx +++ b/components/AlertBox.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react'; +import {useEffect, useState} from 'react'; import {createPortal} from 'react-dom'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import {faCheck, faExclamationTriangle, faInfoCircle, faTimes} from '@fortawesome/free-solid-svg-icons'; diff --git a/components/AlertStack.tsx b/components/AlertStack.tsx index 9a5f6a9..3958ebc 100644 --- a/components/AlertStack.tsx +++ b/components/AlertStack.tsx @@ -1,6 +1,6 @@ 'use client'; -import React from 'react'; +import {useEffect, useState} from 'react'; import {createPortal} from 'react-dom'; import StaticAlert from '@/components/StaticAlert'; import {Alert} from '@/context/AlertProvider'; @@ -11,9 +11,9 @@ interface AlertStackProps { } export default function AlertStack({alerts, onClose}: AlertStackProps) { - const [mounted, setMounted] = React.useState(false); + const [mounted, setMounted] = useState(false); - React.useEffect(() => { + useEffect(() => { setMounted(true); return () => setMounted(false); }, []); @@ -38,7 +38,7 @@ export default function AlertStack({alerts, onClose}: AlertStackProps) { />
))} -