feat: Enhance note creation and project cancellation with user information and translations

This commit is contained in:
2025-09-18 11:11:22 +02:00
parent 1a49919000
commit 8964a9b29b
6 changed files with 52 additions and 6 deletions

View File

@@ -3,7 +3,7 @@
import React, { useState } from "react";
import { useTranslation } from "@/lib/i18n";
export default function NoteForm({ projectId }) {
export default function NoteForm({ projectId, onNoteAdded }) {
const { t } = useTranslation();
const [note, setNote] = useState("");
const [status, setStatus] = useState(null);
@@ -18,19 +18,33 @@ export default function NoteForm({ projectId }) {
});
if (res.ok) {
const newNote = await res.json();
setNote("");
setStatus(t("common.addNoteSuccess"));
window.location.reload();
// Call the callback to add the new note to the parent component's state
if (onNoteAdded) {
onNoteAdded(newNote);
}
// Clear status message after 3 seconds
setTimeout(() => setStatus(null), 3000);
} else {
setStatus(t("common.addNoteError"));
}
}
function handleKeyDown(e) {
if (e.ctrlKey && e.key === 'Enter') {
e.preventDefault();
handleSubmit(e);
}
}
return (
<form onSubmit={handleSubmit} className="space-y-2 mb-4">
<textarea
value={note}
onChange={(e) => setNote(e.target.value)}
onKeyDown={handleKeyDown}
placeholder={t("common.addNotePlaceholder")}
className="border p-2 w-full"
rows={3}