feat: Enhance note creation and project cancellation with user information and translations
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user