carnet panel
This commit is contained in:
parent
29028325a7
commit
90ead6be7f
@ -140,8 +140,11 @@ export default function CarnetPage() {
|
||||
|
||||
const handleNoteSave = async (note: Note) => {
|
||||
try {
|
||||
const response = await fetch('/api/nextcloud/files', {
|
||||
method: note.id ? 'PUT' : 'POST',
|
||||
const endpoint = note.id ? '/api/nextcloud/files' : '/api/nextcloud/files';
|
||||
const method = note.id ? 'PUT' : 'POST';
|
||||
|
||||
const response = await fetch(endpoint, {
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@ -158,13 +161,16 @@ export default function CarnetPage() {
|
||||
}
|
||||
|
||||
const savedNote = await response.json();
|
||||
setSelectedNote(savedNote);
|
||||
setSelectedNote({
|
||||
...savedNote,
|
||||
content: note.content
|
||||
});
|
||||
|
||||
// Refresh the notes list
|
||||
const notesResponse = await fetch(`/api/nextcloud/files?folder=${selectedFolder}`);
|
||||
if (notesResponse.ok) {
|
||||
const notes = await notesResponse.json();
|
||||
setNotes(notes);
|
||||
const updatedNotes = await notesResponse.json();
|
||||
setNotes(updatedNotes);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving note:', error);
|
||||
@ -254,6 +260,13 @@ export default function CarnetPage() {
|
||||
note={selectedNote}
|
||||
onSave={handleNoteSave}
|
||||
currentFolder={selectedFolder}
|
||||
onRefresh={() => {
|
||||
// Refresh the notes list
|
||||
fetch(`/api/nextcloud/files?folder=${selectedFolder}`)
|
||||
.then(response => response.json())
|
||||
.then(updatedNotes => setNotes(updatedNotes))
|
||||
.catch(error => console.error('Error refreshing notes:', error));
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@ -17,9 +17,10 @@ interface EditorProps {
|
||||
note?: Note | null;
|
||||
onSave?: (note: Note) => void;
|
||||
currentFolder?: string;
|
||||
onRefresh?: () => void;
|
||||
}
|
||||
|
||||
export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'Notes' }) => {
|
||||
export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'Notes', onRefresh }) => {
|
||||
const [title, setTitle] = useState(note?.title || '');
|
||||
const [content, setContent] = useState(note?.content || '');
|
||||
const [isSaving, setIsSaving] = useState(false);
|
||||
@ -95,6 +96,7 @@ export const Editor: React.FC<EditorProps> = ({ note, onSave, currentFolder = 'N
|
||||
...savedNote,
|
||||
content
|
||||
});
|
||||
onRefresh?.();
|
||||
} catch (error) {
|
||||
console.error('Error saving note:', error);
|
||||
// TODO: Show error message to user
|
||||
|
||||
Loading…
Reference in New Issue
Block a user