correction bible du mande (store update temps reel)

This commit is contained in:
2026-02-27 23:23:43 +01:00
parent 23560ac9c3
commit 5268a7dd68
40 changed files with 1303 additions and 489 deletions

View File

@@ -30,6 +30,7 @@ export default function ProjectLayout({ children }: { children: React.ReactNode
const {
projects, setCurrentProjectId,
updateProject, updateChapter, addChapter,
createEntity, updateEntity, deleteEntity, deleteProject
} = useProjects(user);
const { chatHistory, isGenerating, sendMessage } = useChat();
@@ -98,6 +99,10 @@ export default function ProjectLayout({ children }: { children: React.ReactNode
setCurrentChapterId,
updateProject: (updates) => updateProject(projectId, updates),
updateChapter: (chapterId, data) => updateChapter(projectId, chapterId, data),
createEntity: (type, data) => createEntity(projectId, type, data),
updateEntity: (entityId, data) => updateEntity(projectId, entityId, data),
deleteEntity: (entityId) => deleteEntity(projectId, entityId),
deleteProject: () => deleteProject(projectId),
incrementUsage,
}}>
<EditorShell

View File

@@ -2,14 +2,10 @@
import BookSettingsComponent from '@/components/BookSettings';
import { useProjectContext } from '@/providers/ProjectProvider';
import { useAuthContext } from '@/providers/AuthProvider';
import { useProjects } from '@/hooks/useProjects';
import { useRouter } from 'next/navigation';
export default function SettingsPage() {
const { project, projectId, updateProject } = useProjectContext();
const { user } = useAuthContext();
const { deleteProject } = useProjects(user);
const { project, updateProject, deleteProject } = useProjectContext();
const router = useRouter();
return (
@@ -17,7 +13,7 @@ export default function SettingsPage() {
project={project}
onUpdate={(updates) => updateProject(updates)}
onDeleteProject={async () => {
await deleteProject(projectId);
await deleteProject();
router.push('/dashboard');
}}
/>

View File

@@ -2,22 +2,18 @@
import WorldBuilder from '@/components/WorldBuilder';
import { useProjectContext } from '@/providers/ProjectProvider';
import { useProjects } from '@/hooks/useProjects';
import { useAuthContext } from '@/providers/AuthProvider';
export default function WorldPage() {
const { project, projectId, updateProject } = useProjectContext();
const { user } = useAuthContext();
const { createEntity, updateEntity, deleteEntity } = useProjects(user);
const { project, updateProject, createEntity, updateEntity, deleteEntity } = useProjectContext();
return (
<WorldBuilder
entities={project.entities || []}
onCreate={async (entityData) => {
return await createEntity(projectId, entityData.type, entityData);
return await createEntity(entityData.type, entityData);
}}
onUpdate={(entityId, updates) => updateEntity(projectId, entityId, updates)}
onDelete={(entityId) => deleteEntity(projectId, entityId)}
onUpdate={(entityId, updates) => updateEntity(entityId, updates)}
onDelete={(entityId) => deleteEntity(entityId)}
templates={project.templates || []}
onUpdateTemplates={(t) => updateProject({ templates: t })}
initialSelectedId={null}

View File

@@ -1,7 +1,7 @@
'use client';
import React, { createContext, useContext } from 'react';
import { BookProject, UserProfile } from '@/lib/types';
import { BookProject, UserProfile, Entity, EntityType } from '@/lib/types';
interface ProjectContextType {
project: BookProject;
@@ -11,6 +11,10 @@ interface ProjectContextType {
setCurrentChapterId: (id: string) => void;
updateProject: (updates: Partial<BookProject>) => void;
updateChapter: (chapterId: string, data: any) => void;
createEntity: (type: EntityType, initialData?: Partial<Entity>) => Promise<string>;
updateEntity: (entityId: string, data: Partial<Entity>) => Promise<void>;
deleteEntity: (entityId: string) => Promise<void>;
deleteProject: () => Promise<void>;
incrementUsage: () => void;
}