diff --git a/src/app/project-tasks/page.js b/src/app/project-tasks/page.js index a84af43..502e8c3 100644 --- a/src/app/project-tasks/page.js +++ b/src/app/project-tasks/page.js @@ -1,13 +1,35 @@ import ProjectTasksList from "@/components/ProjectTasksList"; import PageContainer from "@/components/ui/PageContainer"; import PageHeader from "@/components/ui/PageHeader"; +import Button from "@/components/ui/Button"; +import Link from "next/link"; export default function ProjectTasksPage() { return ( + + + } /> diff --git a/src/app/tasks/templates/[id]/edit/page.js b/src/app/tasks/templates/[id]/edit/page.js index d357906..93418b8 100644 --- a/src/app/tasks/templates/[id]/edit/page.js +++ b/src/app/tasks/templates/[id]/edit/page.js @@ -1,9 +1,6 @@ import db from "@/lib/db"; import { notFound } from "next/navigation"; -import Link from "next/link"; -import { Card, CardHeader, CardContent } from "@/components/ui/Card"; -import Button from "@/components/ui/Button"; -import TaskTemplateForm from "@/components/TaskTemplateForm"; +import EditTaskTemplateClient from "@/components/EditTaskTemplateClient"; export default async function EditTaskTemplatePage({ params }) { const { id } = await params; @@ -16,52 +13,5 @@ export default async function EditTaskTemplatePage({ params }) { notFound(); } - return ( -
-
-
- - - {" "} -
-

- Edit Task Template -

-

- Update the details for “{template.name}” -

-
-
- - - -

- Template Details -

-

- Modify the template information below -

-
- - - -
-
-
- ); + return ; } diff --git a/src/app/tasks/templates/new/page.js b/src/app/tasks/templates/new/page.js index 90ba438..6fb5e5c 100644 --- a/src/app/tasks/templates/new/page.js +++ b/src/app/tasks/templates/new/page.js @@ -1,9 +1,13 @@ +"use client"; + import TaskTemplateForm from "@/components/TaskTemplateForm"; +import { useTranslation } from "@/lib/i18n"; export default function NewTaskTemplatePage() { + const { t } = useTranslation(); return (
-

New Task Template

+

{t('taskTemplates.newTemplate')}

); diff --git a/src/app/tasks/templates/page.js b/src/app/tasks/templates/page.js index 3017fdf..1ee3300 100644 --- a/src/app/tasks/templates/page.js +++ b/src/app/tasks/templates/page.js @@ -1,24 +1,78 @@ -import db from "@/lib/db"; +"use client"; + +import { useState, useEffect } from "react"; import Link from "next/link"; import { Card, CardHeader, CardContent } from "@/components/ui/Card"; import Button from "@/components/ui/Button"; import Badge from "@/components/ui/Badge"; import PageContainer from "@/components/ui/PageContainer"; import PageHeader from "@/components/ui/PageHeader"; +import { useTranslation } from "@/lib/i18n"; export default function TaskTemplatesPage() { - const templates = db - .prepare( - ` - SELECT * FROM tasks WHERE is_standard = 1 ORDER BY name ASC - ` - ) - .all(); + const { t } = useTranslation(); + const [templates, setTemplates] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchTemplates = async () => { + try { + const response = await fetch('/api/tasks/templates'); + if (response.ok) { + const data = await response.json(); + setTemplates(data); + } else { + console.error('Failed to fetch templates'); + } + } catch (error) { + console.error('Error fetching templates:', error); + } finally { + setLoading(false); + } + }; + + fetchTemplates(); + }, []); + + if (loading) { + return ( + + + + + } + /> +
+
{t('common.loading')}
+
+
+ ); + } + return ( } @@ -58,13 +112,13 @@ export default function TaskTemplatesPage() {

- No task templates yet + {t('taskTemplates.noTemplates')}

- Create reusable task templates to streamline your workflow + {t('taskTemplates.noTemplatesMessage')}

- + @@ -81,7 +135,7 @@ export default function TaskTemplatesPage() { {template.name} - {template.max_wait_days} days + {template.max_wait_days} {t('common.days')} {template.description && ( @@ -92,7 +146,7 @@ export default function TaskTemplatesPage() {
diff --git a/src/components/EditTaskTemplateClient.js b/src/components/EditTaskTemplateClient.js new file mode 100644 index 0000000..54c6222 --- /dev/null +++ b/src/components/EditTaskTemplateClient.js @@ -0,0 +1,60 @@ +"use client"; + +import Link from "next/link"; +import { Card, CardHeader, CardContent } from "@/components/ui/Card"; +import Button from "@/components/ui/Button"; +import TaskTemplateForm from "@/components/TaskTemplateForm"; +import { useTranslation } from "@/lib/i18n"; + +export default function EditTaskTemplateClient({ template }) { + const { t } = useTranslation(); + + return ( +
+
+
+ + + {" "} +
+

+ {t('taskTemplates.editTemplate')} +

+

+ {t('taskTemplates.subtitle')} “{template.name}” +

+
+
+ + + +

+ {t('taskTemplates.templateName')} +

+

+ {t('taskTemplates.subtitle')} +

+
+ + + +
+
+
+ ); +} \ No newline at end of file diff --git a/src/components/TaskTemplateForm.js b/src/components/TaskTemplateForm.js index 4968ecd..3f3b75d 100644 --- a/src/components/TaskTemplateForm.js +++ b/src/components/TaskTemplateForm.js @@ -4,11 +4,13 @@ import { useState, useEffect } from "react"; import { useRouter } from "next/navigation"; import Button from "./ui/Button"; import { Input } from "./ui/Input"; +import { useTranslation } from "@/lib/i18n"; export default function TaskTemplateForm({ templateId = null, initialData = null, }) { + const { t } = useTranslation(); const [name, setName] = useState(""); const [max_wait_days, setRequiredWaitDays] = useState(""); const [description, setDescription] = useState(""); @@ -52,11 +54,11 @@ export default function TaskTemplateForm({ const error = await res.json(); alert( error.error || - `Failed to ${isEditing ? "update" : "create"} task template.` + `${t('common.error')} ${isEditing ? t('taskTemplates.editTemplate') : t('taskTemplates.newTemplate')}` ); } } catch (error) { - alert(`Error ${isEditing ? "updating" : "creating"} task template.`); + alert(`${t('common.error')} ${isEditing ? t('taskTemplates.editTemplate') : t('taskTemplates.newTemplate')}`); } finally { setLoading(false); } @@ -65,41 +67,41 @@ export default function TaskTemplateForm({
setName(e.target.value)} - placeholder="Enter template name" + placeholder={t('taskTemplates.templateName')} required />
setRequiredWaitDays(e.target.value)} - placeholder="Enter maximum wait days" + placeholder={t('taskTemplates.estimatedDuration')} min="0" />

- Maximum number of days this task can wait before it needs attention + {t('taskTemplates.estimatedDuration')}