feat: implement main application dashboard and mobile note detail page

This commit is contained in:
Michael committed 2025-12-12 11:31:47 +01:00
1 parent 970a9d6de4
commit 35ecd9a8bb
2 files changed
+8 -34

No files matched your search

+7 -33
View File
@@ -35,8 +35,6 @@ import { AddUserModal } from "@/components/modals/AddUserModal";
import { compressImage, formatFileSize } from "@/utils/imageCompression"; import { compressImage, formatFileSize } from "@/utils/imageCompression";
import { ModeToggle } from "@/components/mode-toggle"; import { ModeToggle } from "@/components/mode-toggle";
import { downloadNoteAsMarkdown, downloadAllNotesAsMarkdown, downloadTodosAsMarkdown } from "@/utils/markdownExport"; import { downloadNoteAsMarkdown, downloadAllNotesAsMarkdown, downloadTodosAsMarkdown } from "@/utils/markdownExport";
import { TemplateSelector } from "@/components/TemplateSelector";
import type { NoteTemplate } from "@/utils/noteTemplates";
import { AdvancedSearch, type SearchFilters, type TagOption } from "@/components/AdvancedSearch"; import { AdvancedSearch, type SearchFilters, type TagOption } from "@/components/AdvancedSearch";
import { PomodoroModal } from "@/components/PomodoroModal"; import { PomodoroModal } from "@/components/PomodoroModal";
import { PomodoroTimer } from "@/components/PomodoroTimer"; import { PomodoroTimer } from "@/components/PomodoroTimer";
@@ -188,7 +186,6 @@ const Index = () => {
const [addUserModal, setAddUserModal] = useState(false); const [addUserModal, setAddUserModal] = useState(false);
const [deleteUserModal, setDeleteUserModal] = useState<{ open: boolean, userId?: number }>({ open: false }); const [deleteUserModal, setDeleteUserModal] = useState<{ open: boolean, userId?: number }>({ open: false });
const [changePasswordModal, setChangePasswordModal] = useState<{ open: boolean, userId?: number }>({ open: false }); const [changePasswordModal, setChangePasswordModal] = useState<{ open: boolean, userId?: number }>({ open: false });
const [templateSelectorOpen, setTemplateSelectorOpen] = useState(false);
const [addNoteTodoModal, setAddNoteTodoModal] = useState(false); const [addNoteTodoModal, setAddNoteTodoModal] = useState(false);
const [addTagModal, setAddTagModal] = useState(false); const [addTagModal, setAddTagModal] = useState(false);
const [selectedImage, setSelectedImage] = useState<string | null>(null); const [selectedImage, setSelectedImage] = useState<string | null>(null);
@@ -487,32 +484,13 @@ const Index = () => {
navigate("/login"); navigate("/login");
}; };
const handleCreateNote = () => { const handleCreateNote = async () => {
setTemplateSelectorOpen(true);
};
const handleCreateNoteFromTemplate = async (template: NoteTemplate) => {
try { try {
const title = template.name === "Note vide" ? "Nouvelle note" : template.name; const newNote = await NotesService.createNote("Nouvelle note", "");
const newNote = await NotesService.createNote(title, template.content);
if (newNote) { if (newNote) {
// Add todos if template has any setNotes([newNote, ...notes]);
if (template.todos && template.todos.length > 0) { setOpenNote(newNote);
for (const todo of template.todos) { showSuccess("Note créée");
await NotesService.addTodo(newNote.id!, todo.text);
}
// Reload note to get the todos
const notes = await NotesService.getNotes();
const updatedNote = notes.find(n => n.id === newNote.id);
if (updatedNote) {
setNotes([updatedNote, ...notes.filter(n => n.id !== newNote.id)]);
setOpenNote(updatedNote);
}
} else {
setNotes([newNote, ...notes]);
setOpenNote(newNote);
}
showSuccess("Note créée depuis le template");
} }
} catch (error) { } catch (error) {
showError("Erreur lors de la création de la note"); showError("Erreur lors de la création de la note");
@@ -1558,7 +1536,7 @@ const Index = () => {
notes={filteredNotes} notes={filteredNotes}
onNoteClick={handleOpenNote} onNoteClick={handleOpenNote}
onCreateNote={(columnId) => { onCreateNote={(columnId) => {
setTemplateSelectorOpen(true); handleCreateNote();
// TODO: Set initial tag based on columnId // TODO: Set initial tag based on columnId
}} }}
onMoveNote={async (noteId, newStatus) => { onMoveNote={async (noteId, newStatus) => {
@@ -2634,11 +2612,7 @@ const Index = () => {
/> />
{/* Template Selector */} {/* Template Selector */}
<TemplateSelector
open={templateSelectorOpen}
onOpenChange={setTemplateSelectorOpen}
onSelectTemplate={handleCreateNoteFromTemplate}
/>
{/* Add Event Modal */} {/* Add Event Modal */}
<Dialog open={addEventModal} onOpenChange={setAddEventModal}> <Dialog open={addEventModal} onOpenChange={setAddEventModal}>
+1 -1
View File
@@ -64,8 +64,8 @@ export default function NoteDetailPage() {
if (!note) return; if (!note) return;
try { try {
const updated = { ...note, ...updates }; const updated = { ...note, ...updates };
await NotesService.updateNote(updated);
setNote(updated); setNote(updated);
await NotesService.updateNote(updated);
} catch (error) { } catch (error) {
showError("Erreur lors de la sauvegarde"); showError("Erreur lors de la sauvegarde");
} }