Add components for Act management and integrate Electron setup
This commit is contained in:
551
app/globals.css
Normal file
551
app/globals.css
Normal file
@@ -0,0 +1,551 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
/* Colors */
|
||||
--color-primary: #51AE84;
|
||||
--color-primary-dark: #3A8B69;
|
||||
--color-primary-light: #74C9A0;
|
||||
--color-secondary: #3E3E3E;
|
||||
--color-tertiary: #2C2C2C;
|
||||
--color-background: #2B2D30;
|
||||
--color-dark-background: #2C2C2C;
|
||||
--color-darkest-background: #1A1A1A;
|
||||
--color-text-primary: #FFFFFF;
|
||||
--color-text-secondary: #B0B0B0;
|
||||
--color-muted: #B0B0B0;
|
||||
--color-success: #28A745;
|
||||
--color-error: #DC3545;
|
||||
--color-warning: #FFC107;
|
||||
--color-info: #17A2B8;
|
||||
|
||||
--color-gray: #808080;
|
||||
--color-gray-light: #A0A0A0;
|
||||
--color-gray-dark: #404040;
|
||||
|
||||
/* Font Family */
|
||||
--font-family-lora: 'Lora', Georgia, serif;
|
||||
--font-family-lora-italic: 'Lora Italic', serif;
|
||||
--font-family-adlam: 'ADLaM Display', serif;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lora';
|
||||
src: url('../fonts/lora-variable.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lora Italic';
|
||||
src: url('../fonts/lora-Italic.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'ADLaM Display';
|
||||
src: url('../fonts/adlam-display.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
:root {
|
||||
--foreground-rgb: 0, 0, 0;
|
||||
--background-start-rgb: 214, 219, 220;
|
||||
--background-end-rgb: 255, 255, 255;
|
||||
}
|
||||
|
||||
body {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(17 24 39 / var(--tw-bg-opacity))
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #2d2d2d;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #51AE84;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #3a8b69;
|
||||
}
|
||||
|
||||
/* Scrollbar Styles for Firefox */
|
||||
* {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: #51AE84 #2d2d2d;
|
||||
}
|
||||
|
||||
.fade-in {
|
||||
opacity: 0;
|
||||
animation: fadeIn 0.8s ease-out forwards;
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideInFromLeft {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(-20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideInFromRight {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes smoothBounce {
|
||||
0%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
}
|
||||
|
||||
.tiptap {
|
||||
min-height: calc(100vh - 15rem);
|
||||
font-family: 'Lora', sans-serif;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.indent-0 {
|
||||
text-indent: 0px !important;
|
||||
}
|
||||
|
||||
.indent-1 {
|
||||
text-indent: 4px !important;
|
||||
}
|
||||
|
||||
.indent-2 {
|
||||
text-indent: 8px !important;
|
||||
}
|
||||
|
||||
.indent-3 {
|
||||
text-indent: 12px !important;
|
||||
}
|
||||
|
||||
.indent-4 {
|
||||
text-indent: 16px !important;
|
||||
}
|
||||
|
||||
.indent-5 {
|
||||
text-indent: 20px !important;
|
||||
}
|
||||
|
||||
.indent-6 {
|
||||
text-indent: 24px !important;
|
||||
}
|
||||
|
||||
.indent-7 {
|
||||
text-indent: 28px !important;
|
||||
}
|
||||
|
||||
.indent-8 {
|
||||
text-indent: 32px !important;
|
||||
}
|
||||
|
||||
.indent-9 {
|
||||
text-indent: 36px !important;
|
||||
}
|
||||
|
||||
.indent-10 {
|
||||
text-indent: 40px !important;
|
||||
}
|
||||
|
||||
.indent-11 {
|
||||
text-indent: 44px !important;
|
||||
}
|
||||
|
||||
.indent-12 {
|
||||
text-indent: 48px !important;
|
||||
}
|
||||
|
||||
.indent-13 {
|
||||
text-indent: 52px !important;
|
||||
}
|
||||
|
||||
/* Styles pour l'éditeur principal avec classes dynamiques */
|
||||
.editor-content .tiptap p {
|
||||
color: #dedede;
|
||||
margin-top: 0.7em;
|
||||
margin-bottom: 0.7em;
|
||||
}
|
||||
|
||||
.editor-content .tiptap p {
|
||||
text-indent: inherit;
|
||||
}
|
||||
|
||||
.editor-content .tiptap p strong {
|
||||
font-weight: 900;
|
||||
color: #f9f9f9;
|
||||
}
|
||||
|
||||
.editor-content .tiptap h1, .editor-content .tiptap h2, .editor-content .tiptap h3 {
|
||||
color: #34acd0;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.editor-content .tiptap h1 {
|
||||
text-indent: 5px;
|
||||
font-size: 1.7em;
|
||||
}
|
||||
|
||||
.editor-content .tiptap h2 {
|
||||
text-indent: 3px;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
.editor-content .tiptap h3 {
|
||||
text-indent: 1px;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.editor-content .tiptap ul[data-type="bulletList"],
|
||||
.editor-content .tiptap ol[data-type="orderedList"] {
|
||||
text-indent: 0px !important;
|
||||
}
|
||||
|
||||
.editor-content .tiptap li p {
|
||||
text-indent: 0px !important;
|
||||
margin: 0.2em 0;
|
||||
}
|
||||
|
||||
.ProseMirror-focused {
|
||||
outline: none !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.setting-container {
|
||||
height: calc(100vh - 10rem);
|
||||
}
|
||||
|
||||
.composer-panel-h {
|
||||
height: calc(100vh - 8rem);
|
||||
}
|
||||
|
||||
.composer-panel-component-h {
|
||||
height: calc(100vh - 14rem);
|
||||
}
|
||||
|
||||
.embla__viewport {
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.embla__container {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.embla__slide {
|
||||
flex: 0 0 18%; /* Changez à 10% pour afficher plus de livres */
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
.embla__slide img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
object-fit: cover;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* Nouvelles classes pour les cartes de fonctionnalités */
|
||||
.feature-card {
|
||||
position: relative;
|
||||
transition: all 0.3s ease;
|
||||
overflow: hidden;
|
||||
background-color: #3E3E3E;
|
||||
border-radius: 0.75rem;
|
||||
}
|
||||
|
||||
.feature-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 10px 25px -5px rgba(81, 174, 132, 0.2);
|
||||
}
|
||||
|
||||
.feature-card-bg {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.feature-card:hover .feature-card-bg {
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.feature-icon-container {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #313131, #4A4A4A);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 1.5rem;
|
||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
|
||||
transition: box-shadow 0.3s ease, transform 0.3s ease;
|
||||
}
|
||||
|
||||
.feature-card:hover .feature-icon-container {
|
||||
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.feature-icon {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.feature-title-container {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.feature-title-underline {
|
||||
position: absolute;
|
||||
bottom: -2px;
|
||||
left: 0;
|
||||
height: 2px;
|
||||
width: 0;
|
||||
transition: width 0.3s ease;
|
||||
}
|
||||
|
||||
.feature-card:hover .feature-title-underline {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.feature-shine-line {
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background-color: #4A4A4A;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.feature-shine {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 1px;
|
||||
width: 0;
|
||||
transition: width 0.7s ease-out;
|
||||
}
|
||||
|
||||
.feature-card:hover .feature-shine {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.feature-button {
|
||||
margin-top: 1.5rem;
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.feature-card:hover .feature-button {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/* Classes pour les cartes de communauté */
|
||||
.community-card {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
border-radius: 0.75rem;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.community-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.community-glow {
|
||||
position: absolute;
|
||||
inset: -2px;
|
||||
opacity: 0.75;
|
||||
filter: blur(15px);
|
||||
transition: opacity 1s ease, inset 1s ease;
|
||||
}
|
||||
|
||||
.community-card:hover .community-glow {
|
||||
opacity: 1;
|
||||
inset: -4px;
|
||||
}
|
||||
|
||||
.community-content {
|
||||
position: relative;
|
||||
padding: 2rem;
|
||||
border-radius: 0.75rem;
|
||||
}
|
||||
|
||||
.community-icon {
|
||||
width: 4rem;
|
||||
height: 4rem;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 auto 1rem;
|
||||
}
|
||||
|
||||
/* Animation pour le statut "En développement" */
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
opacity: 0.6;
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
.dev-status {
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
.last-updated {
|
||||
color: #777777;
|
||||
font-size: 0.75rem;
|
||||
text-align: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.tiptap-draft {
|
||||
min-height: auto;
|
||||
height: 100%;
|
||||
font-family: 'Lora', sans-serif;
|
||||
}
|
||||
|
||||
.tiptap-draft .ProseMirror {
|
||||
min-height: auto !important;
|
||||
height: auto !important;
|
||||
overflow: visible !important;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.tiptap-draft .ProseMirror em {
|
||||
font-family: 'Lora Italic', serif;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.tiptap-draft .ProseMirror h1,
|
||||
.tiptap-draft .ProseMirror h2,
|
||||
.tiptap-draft .ProseMirror h3 {
|
||||
font-family: 'Lora', sans-serif;
|
||||
text-indent: 30px;
|
||||
}
|
||||
|
||||
.tiptap-draft p {
|
||||
font-family: 'Lora', sans-serif;
|
||||
text-indent: 30px;
|
||||
margin-top: 0.7em;
|
||||
margin-bottom: 0.7em;
|
||||
}
|
||||
|
||||
/* Smooth transitions for all interactive elements */
|
||||
button, a, input, textarea, select {
|
||||
transition: all 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
/* Enhanced focus states */
|
||||
button:focus-visible,
|
||||
input:focus-visible,
|
||||
textarea:focus-visible,
|
||||
select:focus-visible {
|
||||
outline: 2px solid #51AE84;
|
||||
outline-offset: 2px;
|
||||
box-shadow: 0 0 0 4px rgba(81, 174, 132, 0.1);
|
||||
}
|
||||
|
||||
/* Smooth hover scale for interactive elements */
|
||||
.hover-lift:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
/* Literary decorative elements */
|
||||
.literary-ornament::before,
|
||||
.literary-ornament::after {
|
||||
content: "❖";
|
||||
color: #51AE84;
|
||||
opacity: 0.3;
|
||||
font-size: 0.8em;
|
||||
margin: 0 0.5em;
|
||||
}
|
||||
|
||||
/* Subtle pulse for active states */
|
||||
@keyframes subtlePulse {
|
||||
0%, 100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
.pulse-subtle {
|
||||
animation: subtlePulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
/* Glass morphism effect */
|
||||
.glass-effect {
|
||||
background: rgba(62, 62, 62, 0.7);
|
||||
backdrop-filter: blur(10px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
/* Fade in pour le texte qui stream */
|
||||
.fade-in-text {
|
||||
animation: textFadeIn 100ms ease-out;
|
||||
}
|
||||
|
||||
@keyframes textFadeIn {
|
||||
from {
|
||||
opacity: 0.7;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
26
app/layout.tsx
Normal file
26
app/layout.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
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,
|
||||
}: Readonly<{
|
||||
children: ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="fr">
|
||||
<body>
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
339
app/page.tsx
Normal file
339
app/page.tsx
Normal file
@@ -0,0 +1,339 @@
|
||||
'use client';
|
||||
import React, {useContext, useEffect, useState} from 'react';
|
||||
import {BookContext} from "@/context/BookContext";
|
||||
import {ChapterProps} from "@/lib/models/Chapter";
|
||||
import {ChapterContext} from '@/context/ChapterContext';
|
||||
import {EditorContext} from '@/context/EditorContext'
|
||||
import {Editor, useEditor} from "@tiptap/react";
|
||||
import StarterKit from "@tiptap/starter-kit";
|
||||
import Underline from "@tiptap/extension-underline";
|
||||
import TextAlign from "@tiptap/extension-text-align";
|
||||
import {AlertContext, AlertProvider} from "@/context/AlertContext";
|
||||
import System from "@/lib/models/System";
|
||||
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";
|
||||
import ScribeTopBar from "@/components/ScribeTopBar";
|
||||
import ScribeControllerBar from "@/components/ScribeControllerBar";
|
||||
import ScribeLeftBar from "@/components/leftbar/ScribeLeftBar";
|
||||
import ScribeEditor from "@/components/editor/ScribeEditor";
|
||||
import ComposerRightBar from "@/components/rightbar/ComposerRightBar";
|
||||
import ScribeFooterBar from "@/components/ScribeFooterBar";
|
||||
import GuideTour, {GuideStep} from "@/components/GuideTour";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
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";
|
||||
import {NextIntlClientProvider, useTranslations} from "next-intl";
|
||||
import {LangContext} from "@/context/LangContext";
|
||||
import {AIUsageContext} from "@/context/AIUsageContext";
|
||||
|
||||
const messagesMap = {
|
||||
fr: frMessages,
|
||||
en: enMessages
|
||||
};
|
||||
|
||||
function ScribeContent() {
|
||||
const t = useTranslations();
|
||||
const {lang: locale} = useContext(LangContext);
|
||||
const {errorMessage, successMessage} = useContext(AlertContext);
|
||||
const editor: Editor | null = useEditor({
|
||||
extensions: [
|
||||
StarterKit,
|
||||
Underline,
|
||||
TextAlign.configure({
|
||||
types: ['heading', 'paragraph'],
|
||||
}),
|
||||
],
|
||||
injectCSS: false,
|
||||
immediatelyRender: false,
|
||||
});
|
||||
|
||||
const router: AppRouterInstance = useRouter();
|
||||
const [session, setSession] = useState<SessionProps>({user: null, accessToken: '', isConnected: false});
|
||||
const [currentChapter, setCurrentChapter] = useState<ChapterProps | undefined>(undefined);
|
||||
const [currentBook, setCurrentBook] = useState<BookProps | null>(null);
|
||||
|
||||
const [currentCredits, setCurrentCredits] = useState<number>(160);
|
||||
const [amountSpent, setAmountSpent] = useState<number>(session.user?.aiUsage || 0);
|
||||
|
||||
const [isLoading, setIsLoading] = useState<boolean>(true);
|
||||
|
||||
const [sessionAttempts, setSessionAttempts] = useState<number>(0)
|
||||
|
||||
const [isTermsAccepted, setIsTermsAccepted] = useState<boolean>(false);
|
||||
const [homeStepsGuide, setHomeStepsGuide] = useState<boolean>(false);
|
||||
|
||||
const homeSteps: GuideStep[] = [
|
||||
{
|
||||
id: 0,
|
||||
x: 50,
|
||||
y: 50,
|
||||
title: t("homePage.guide.welcome", {name: session.user?.name || ''}),
|
||||
content: (
|
||||
<div>
|
||||
<p>{t("homePage.guide.step0.description1")}</p>
|
||||
<br/>
|
||||
<p>{t("homePage.guide.step0.description2")}</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 1, position: 'right',
|
||||
targetSelector: `[data-guide="left-panel-container"]`,
|
||||
title: t("homePage.guide.step1.title"),
|
||||
content: (
|
||||
<div>
|
||||
<p className={'flex items-center space-x-2'}>
|
||||
<strong>
|
||||
<FontAwesomeIcon icon={faBookMedical} className={'w-5 h-5'}/> :
|
||||
</strong>
|
||||
{t("homePage.guide.step1.addBook")}
|
||||
</p>
|
||||
<br/>
|
||||
<p><strong><FontAwesomeIcon icon={faFeather}
|
||||
className={'w-5 h-5'}/> :</strong> {t("homePage.guide.step1.generateStory")}
|
||||
</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: t("homePage.guide.step2.title"), position: 'bottom',
|
||||
targetSelector: `[data-guide="search-bar"]`,
|
||||
content: (
|
||||
<div>
|
||||
<p>{t("homePage.guide.step2.description")}</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: t("homePage.guide.step3.title"),
|
||||
targetSelector: `[data-guide="user-dropdown"]`,
|
||||
position: 'auto',
|
||||
content: (
|
||||
<div>
|
||||
<p>{t("homePage.guide.step3.description")}</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: t("homePage.guide.step4.title"),
|
||||
content: (
|
||||
<div>
|
||||
<p>{t("homePage.guide.step4.description1")}</p>
|
||||
<br/>
|
||||
<p>{t("homePage.guide.step4.description2")}</p>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
useEffect((): void => {
|
||||
checkAuthentification().then()
|
||||
}, []);
|
||||
|
||||
useEffect((): void => {
|
||||
if (session.isConnected) {
|
||||
setIsTermsAccepted(session.user?.termsAccepted ?? false);
|
||||
setHomeStepsGuide(User.guideTourDone(session.user?.guideTour ?? [], 'home-basic'));
|
||||
setIsLoading(false);
|
||||
} else {
|
||||
if (sessionAttempts > 2) {
|
||||
router.push('/');
|
||||
}
|
||||
}
|
||||
setSessionAttempts(sessionAttempts + 1);
|
||||
}, [session]);
|
||||
|
||||
useEffect((): void => {
|
||||
if (currentBook) {
|
||||
getLastChapter().then();
|
||||
}
|
||||
}, [currentBook]);
|
||||
|
||||
async function handleHomeTour(): Promise<void> {
|
||||
try {
|
||||
const response: boolean = await System.authPostToServer<boolean>('logs/tour', {
|
||||
plateforme: 'web',
|
||||
tour: 'home-basic'
|
||||
},
|
||||
session.accessToken,
|
||||
locale
|
||||
);
|
||||
if (response) {
|
||||
setSession(User.setNewGuideTour(session, 'home-basic'));
|
||||
setHomeStepsGuide(false);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Error) {
|
||||
errorMessage(e.message);
|
||||
} else {
|
||||
errorMessage(t("homePage.errors.termsError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function checkAuthentification(): Promise<void> {
|
||||
const token: string | null = System.getCookie('token');
|
||||
if (token) {
|
||||
try {
|
||||
const user: UserProps = await System.authGetQueryToServer<UserProps>('user/infos', token, locale);
|
||||
if (!user) {
|
||||
errorMessage(t("homePage.errors.userNotFound"));
|
||||
}
|
||||
setSession({
|
||||
isConnected: true,
|
||||
user: user,
|
||||
accessToken: token,
|
||||
});
|
||||
setCurrentCredits(user.creditsBalance)
|
||||
setAmountSpent(user.aiUsage)
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Error) {
|
||||
errorMessage(e.message);
|
||||
} else {
|
||||
errorMessage(t("homePage.errors.authenticationError"));
|
||||
}
|
||||
window.location.href = 'https://eritors.com/login';
|
||||
}
|
||||
} else {
|
||||
window.location.href = 'https://eritors.com/login';
|
||||
}
|
||||
}
|
||||
|
||||
async function handleTermsAcceptance(): Promise<void> {
|
||||
try {
|
||||
const response: boolean = await System.authPostToServer<boolean>(`user/terms/accept`, {
|
||||
version: '2025-07-1'
|
||||
}, session.accessToken, locale);
|
||||
if (response) {
|
||||
setIsTermsAccepted(true);
|
||||
setHomeStepsGuide(true);
|
||||
const newSession: SessionProps = {
|
||||
...session,
|
||||
user: {
|
||||
...session?.user as UserProps,
|
||||
termsAccepted: true
|
||||
}
|
||||
}
|
||||
setSession(newSession);
|
||||
} else {
|
||||
errorMessage(t("homePage.errors.termsAcceptError"));
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Error) {
|
||||
errorMessage(e.message);
|
||||
} else {
|
||||
errorMessage(t("homePage.errors.termsAcceptError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getLastChapter(): Promise<void> {
|
||||
if (session?.accessToken) {
|
||||
try {
|
||||
const response: ChapterProps | null = await System.authGetQueryToServer<ChapterProps | null>(`chapter/last-chapter`, session.accessToken, locale, {bookid: currentBook?.bookId});
|
||||
if (response) {
|
||||
setCurrentChapter(response)
|
||||
} else {
|
||||
setCurrentChapter(undefined);
|
||||
}
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Error) {
|
||||
errorMessage(e.message);
|
||||
} else {
|
||||
errorMessage(t("homePage.errors.lastChapterError"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div
|
||||
className="bg-background text-text-primary h-screen flex flex-col items-center justify-center font-['Lora']">
|
||||
<div className="flex flex-col items-center space-y-6">
|
||||
<div className="animate-pulse">
|
||||
<Image src={'/logo.png'} alt="ERitors Logo" width={400} height={400}/>
|
||||
</div>
|
||||
<div className="flex space-x-2">
|
||||
<div className="w-2 h-2 bg-primary rounded-full animate-bounce"></div>
|
||||
<div className="w-2 h-2 bg-primary rounded-full animate-bounce delay-100"></div>
|
||||
<div className="w-2 h-2 bg-primary rounded-full animate-bounce delay-200"></div>
|
||||
</div>
|
||||
<p className="text-text-secondary text-sm">
|
||||
{t("homePage.loading")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<SessionContext.Provider value={{session: session, setSession: setSession}}>
|
||||
<BookContext.Provider value={{book: currentBook, setBook: setCurrentBook}}>
|
||||
<ChapterContext.Provider value={{chapter: currentChapter, setChapter: setCurrentChapter}}>
|
||||
<AIUsageContext.Provider value={{
|
||||
totalCredits: currentCredits,
|
||||
setTotalCredits: setCurrentCredits,
|
||||
totalPrice: amountSpent,
|
||||
setTotalPrice: setAmountSpent
|
||||
}}>
|
||||
<div
|
||||
className="bg-background text-text-primary h-screen flex flex-col font-['Lora']">
|
||||
<ScribeTopBar/>
|
||||
<EditorContext.Provider value={{editor: editor}}>
|
||||
<ScribeControllerBar/>
|
||||
<div className="flex-1 flex overflow-hidden">
|
||||
<ScribeLeftBar/>
|
||||
<ScribeEditor/>
|
||||
<ComposerRightBar/>
|
||||
</div>
|
||||
<ScribeFooterBar/>
|
||||
</EditorContext.Provider>
|
||||
</div>
|
||||
{
|
||||
homeStepsGuide &&
|
||||
<GuideTour stepId={0} steps={homeSteps} onComplete={handleHomeTour}
|
||||
onClose={(): void => setHomeStepsGuide(false)}/>
|
||||
}
|
||||
{
|
||||
!isTermsAccepted && <TermsOfUse onAccept={handleTermsAcceptance}/>
|
||||
}
|
||||
</AIUsageContext.Provider>
|
||||
</ChapterContext.Provider>
|
||||
</BookContext.Provider>
|
||||
</SessionContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export default function Scribe() {
|
||||
const [locale, setLocale] = useState<'fr' | 'en'>('fr');
|
||||
|
||||
useEffect((): void => {
|
||||
const lang: "fr" | "en" | null = System.getCookie('lang') as "fr" | "en" | null;
|
||||
if (lang) {
|
||||
setLocale(lang);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const messages = messagesMap[locale];
|
||||
|
||||
return (
|
||||
<LangContext.Provider value={{lang: locale, setLang: setLocale}}>
|
||||
<NextIntlClientProvider locale={locale} messages={messages}>
|
||||
<AlertProvider>
|
||||
<ScribeContent/>
|
||||
</AlertProvider>
|
||||
</NextIntlClientProvider>
|
||||
</LangContext.Provider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user