commit before hard reset to change connection

This commit is contained in:
2026-02-15 23:15:56 +01:00
parent be5bd2b2bf
commit af9d69cc78
6 changed files with 383 additions and 154 deletions

View File

@@ -291,18 +291,32 @@ export function useProjects(user: UserProfile | null) {
const addChapter = async () => {
if (!currentProjectId) return null;
console.log("[Hooks] addChapter called. Current Project ID:", currentProjectId);
if (!currentProjectId) {
console.error("[Hooks] addChapter failed: No currentProjectId");
alert("Erreur: Impossible d'ajouter un chapitre car aucun projet n'est actif.");
return null;
}
const projectId = parseInt(currentProjectId);
const result = await dataService.createItem('chapters', {
project_id: projectId,
title: "Nouveau Chapitre",
content: "<p>Contenu...</p>",
summary: ""
});
console.log("[Hooks] Creating chapter for project:", projectId);
if (result.status === 'success') {
await fetchProjectDetails(currentProjectId);
return result.id.toString();
try {
const result = await dataService.createItem('chapters', {
project_id: projectId,
title: "Nouveau Chapitre",
content: "<p>Contenu...</p>",
summary: ""
});
console.log("[Hooks] createItem result:", result);
if (result.status === 'success') {
await fetchProjectDetails(currentProjectId);
return result.id.toString();
} else {
console.error("[Hooks] createItem failed status:", result);
}
} catch (e) {
console.error("[Hooks] createItem exception:", e);
}
return null;
};