i18n: integrate translations into components

- StatusBadge, TaskForm, tasks page use i18n hook
- All 4 language files complete (cs, he, ru, ua)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude CLI Agent
2026-03-29 13:13:34 +00:00
parent fea4d38ce8
commit 235bcab97f
4 changed files with 56 additions and 52 deletions

View File

@@ -4,6 +4,7 @@ import { useEffect, useState, useCallback, useMemo } from "react";
import { useRouter } from "next/navigation";
import { useAuth } from "@/lib/auth";
import { getTasks, getGroups, createTask, updateTask, Task, Group } from "@/lib/api";
import { useTranslation } from "@/lib/i18n";
import TaskCard from "@/components/TaskCard";
import GroupSelector from "@/components/GroupSelector";
import TaskModal from "@/components/TaskModal";
@@ -13,6 +14,7 @@ type StatusFilter = "all" | "pending" | "in_progress" | "done" | "cancelled";
export default function TasksPage() {
const { token } = useAuth();
const { t } = useTranslation();
const router = useRouter();
const [tasks, setTasks] = useState<Task[]>([]);
const [groups, setGroups] = useState<Group[]>([]);
@@ -47,7 +49,7 @@ export default function TasksPage() {
setTasks(tasksRes.data || []);
setGroups(groupsRes.data || []);
} catch (err) {
console.error("Chyba pri nacitani:", err);
console.error("Load error:", err);
} finally {
setLoading(false);
}
@@ -73,7 +75,7 @@ export default function TasksPage() {
// Show overlay
if (newGroupId === null) {
setSwipeOverlay({ name: "Vse", icon: null });
setSwipeOverlay({ name: t("tasks.all"), icon: null });
} else {
const group = groups.find((g) => g.id === newGroupId);
setSwipeOverlay({ name: group?.name || "", icon: group?.icon || null });
@@ -87,7 +89,7 @@ export default function TasksPage() {
setSwipeDirection(null);
}, 600);
},
[groupOrder, currentGroupIndex, groups]
[groupOrder, currentGroupIndex, groups, t]
);
// Swipe handlers for cycling groups
@@ -114,16 +116,16 @@ export default function TasksPage() {
await updateTask(token, taskId, { status: "done" });
loadData();
} catch (err) {
console.error("Chyba pri dokoncovani:", err);
console.error("Complete error:", err);
}
}
const statusOptions: { value: StatusFilter; label: string }[] = [
{ value: "all", label: "Vse" },
{ value: "pending", label: "Ceka" },
{ value: "in_progress", label: "Probiha" },
{ value: "done", label: "Hotovo" },
{ value: "cancelled", label: "Zruseno" },
{ value: "all", label: t("tasks.all") },
{ value: "pending", label: t("tasks.status.pending") },
{ value: "in_progress", label: t("tasks.status.in_progress") },
{ value: "done", label: t("tasks.status.done") },
{ value: "cancelled", label: t("tasks.status.cancelled") },
];
if (!token) return null;
@@ -189,9 +191,9 @@ export default function TasksPage() {
) : tasks.length === 0 ? (
<div className="text-center py-16">
<div className="text-5xl mb-4 opacity-50">&#9744;</div>
<p className="text-muted text-lg font-medium">Zadne ukoly</p>
<p className="text-muted text-lg font-medium">{t("tasks.noTasks")}</p>
<p className="text-muted text-sm mt-1">
Vytvorte prvni ukol pomoci tlacitka +
{t("tasks.createFirst")}
</p>
</div>
) : (
@@ -212,7 +214,7 @@ export default function TasksPage() {
<button
onClick={() => setShowForm(true)}
className="fixed bottom-20 sm:bottom-6 right-4 sm:right-6 w-14 h-14 bg-blue-600 hover:bg-blue-700 active:bg-blue-800 text-white rounded-full shadow-lg hover:shadow-xl active:shadow-md transition-all duration-200 flex items-center justify-center z-40 hover:scale-105 active:scale-95"
aria-label="Pridat ukol"
aria-label={t("tasks.add")}
>
<svg
className="w-7 h-7"