- Added translation context and provider for managing language state. - Integrated translation functionality into existing components (TaskStatusDropdown, Navigation). - Created LanguageSwitcher component for language selection. - Updated task statuses and navigation labels to use translations. - Added Polish translations for various UI elements, including navigation, tasks, projects, and contracts. - Refactored utility functions to return localized strings for deadlines and date formatting.
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
"use client";
|
|
|
|
import React, { useState } from "react";
|
|
import { useTranslation } from "@/lib/i18n";
|
|
|
|
export default function NoteForm({ projectId }) {
|
|
const { t } = useTranslation();
|
|
const [note, setNote] = useState("");
|
|
const [status, setStatus] = useState(null);
|
|
|
|
async function handleSubmit(e) {
|
|
e.preventDefault();
|
|
|
|
const res = await fetch("/api/notes", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ project_id: projectId, note }),
|
|
});
|
|
|
|
if (res.ok) {
|
|
setNote("");
|
|
setStatus(t("common.addNoteSuccess"));
|
|
window.location.reload();
|
|
} else {
|
|
setStatus(t("common.addNoteError"));
|
|
}
|
|
}
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit} className="space-y-2 mb-4">
|
|
<textarea
|
|
value={note}
|
|
onChange={(e) => setNote(e.target.value)}
|
|
placeholder={t("common.addNotePlaceholder")}
|
|
className="border p-2 w-full"
|
|
rows={3}
|
|
required
|
|
/>
|
|
<button
|
|
type="submit"
|
|
className="bg-blue-600 text-white px-4 py-2 rounded"
|
|
>
|
|
{t("common.addNote")}
|
|
</button>
|
|
{status && <p className="text-sm text-gray-600">{status}</p>}
|
|
</form>
|
|
);
|
|
}
|