commit before hard reset to change connection
This commit is contained in:
34
hooks.ts
34
hooks.ts
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user