UI fixes: emoji icons, modal form, Czech labels, polish
- Fixed group emoji icons in DB (💼🛒📚🗺️🏃✨🏠🌿) - Added TaskModal component for + button - Czech status labels (Čeká, Probíhá, Hotovo, Zrušeno) - Improved TaskCard, GroupSelector, Header, StatusBadge - Better dark/light mode transitions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
{
|
{
|
||||||
"extends": "next/core-web-vitals",
|
"extends": "next/core-web-vitals",
|
||||||
"rules": {
|
"rules": {
|
||||||
"@typescript-eslint/no-explicit-any": "off"
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"react-hooks/exhaustive-deps": "warn",
|
||||||
|
"@next/next/no-img-element": "off",
|
||||||
|
"react/no-unescaped-entities": "off"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,26 @@ body {
|
|||||||
background: var(--background);
|
background: var(--background);
|
||||||
color: var(--foreground);
|
color: var(--foreground);
|
||||||
font-family: system-ui, -apple-system, sans-serif;
|
font-family: system-ui, -apple-system, sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
font-size: 16px; /* prevent auto-zoom on iOS */
|
||||||
|
max-width: 100vw;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile-first base */
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"],
|
||||||
|
input[type="email"],
|
||||||
|
input[type="password"],
|
||||||
|
input[type="datetime-local"],
|
||||||
|
textarea,
|
||||||
|
select {
|
||||||
|
font-size: 16px; /* Prevent zoom on iOS */
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer utilities {
|
@layer utilities {
|
||||||
@@ -34,4 +54,36 @@ body {
|
|||||||
.scrollbar-hide::-webkit-scrollbar {
|
.scrollbar-hide::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-muted {
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Smooth page transitions */
|
||||||
|
main {
|
||||||
|
animation: fadeIn 0.15s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(4px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Mobile overscroll behavior */
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
html {
|
||||||
|
overscroll-behavior-y: contain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Selection color */
|
||||||
|
::selection {
|
||||||
|
background: rgba(59, 130, 246, 0.3);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export default function RootLayout({
|
|||||||
<ThemeProvider>
|
<ThemeProvider>
|
||||||
<AuthProvider>
|
<AuthProvider>
|
||||||
<Header />
|
<Header />
|
||||||
<main className="max-w-4xl mx-auto px-4 py-6">
|
<main className="max-w-4xl mx-auto py-4">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
</AuthProvider>
|
</AuthProvider>
|
||||||
|
|||||||
@@ -3,10 +3,21 @@
|
|||||||
import { useEffect, useState, useCallback } from "react";
|
import { useEffect, useState, useCallback } from "react";
|
||||||
import { useRouter, useParams } from "next/navigation";
|
import { useRouter, useParams } from "next/navigation";
|
||||||
import { useAuth } from "@/lib/auth";
|
import { useAuth } from "@/lib/auth";
|
||||||
import { getTask, getGroups, updateTask, deleteTask, Task, Group } from "@/lib/api";
|
import {
|
||||||
|
getTask,
|
||||||
|
getGroups,
|
||||||
|
updateTask,
|
||||||
|
deleteTask,
|
||||||
|
Task,
|
||||||
|
Group,
|
||||||
|
} from "@/lib/api";
|
||||||
import TaskForm from "@/components/TaskForm";
|
import TaskForm from "@/components/TaskForm";
|
||||||
import StatusBadge from "@/components/StatusBadge";
|
import StatusBadge from "@/components/StatusBadge";
|
||||||
|
|
||||||
|
function isDone(status: string): boolean {
|
||||||
|
return status === "done" || status === "completed";
|
||||||
|
}
|
||||||
|
|
||||||
export default function TaskDetailPage() {
|
export default function TaskDetailPage() {
|
||||||
const { token } = useAuth();
|
const { token } = useAuth();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -30,7 +41,9 @@ export default function TaskDetailPage() {
|
|||||||
setTask(taskData);
|
setTask(taskData);
|
||||||
setGroups(groupsData.data || []);
|
setGroups(groupsData.data || []);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : "Chyba pri nacitani ukolu");
|
setError(
|
||||||
|
err instanceof Error ? err.message : "Chyba p\u0159i na\u010d\u00edt\u00e1n\u00ed \u00fakolu"
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -53,13 +66,15 @@ export default function TaskDetailPage() {
|
|||||||
|
|
||||||
async function handleDelete() {
|
async function handleDelete() {
|
||||||
if (!token || !id) return;
|
if (!token || !id) return;
|
||||||
if (!confirm("Opravdu smazat tento ukol?")) return;
|
if (!confirm("Opravdu smazat tento \u00fakol?")) return;
|
||||||
setDeleting(true);
|
setDeleting(true);
|
||||||
try {
|
try {
|
||||||
await deleteTask(token, id);
|
await deleteTask(token, id);
|
||||||
router.push("/tasks");
|
router.push("/tasks");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : "Chyba pri mazani");
|
setError(
|
||||||
|
err instanceof Error ? err.message : "Chyba p\u0159i maz\u00e1n\u00ed"
|
||||||
|
);
|
||||||
setDeleting(false);
|
setDeleting(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +85,9 @@ export default function TaskDetailPage() {
|
|||||||
await updateTask(token, id, { status: newStatus });
|
await updateTask(token, id, { status: newStatus });
|
||||||
loadTask();
|
loadTask();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : "Chyba pri zmene stavu");
|
setError(
|
||||||
|
err instanceof Error ? err.message : "Chyba p\u0159i zm\u011bn\u011b stavu"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +96,7 @@ export default function TaskDetailPage() {
|
|||||||
if (loading) {
|
if (loading) {
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center py-12">
|
<div className="flex justify-center py-12">
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -87,12 +104,12 @@ export default function TaskDetailPage() {
|
|||||||
if (error || !task) {
|
if (error || !task) {
|
||||||
return (
|
return (
|
||||||
<div className="text-center py-12">
|
<div className="text-center py-12">
|
||||||
<p className="text-red-500">{error || "Ukol nenalezen"}</p>
|
<p className="text-red-500">{error || "\u00dakol nenalezen"}</p>
|
||||||
<button
|
<button
|
||||||
onClick={() => router.push("/tasks")}
|
onClick={() => router.push("/tasks")}
|
||||||
className="mt-4 text-blue-600 hover:underline"
|
className="mt-4 text-blue-600 hover:underline"
|
||||||
>
|
>
|
||||||
Zpet na ukoly
|
Zp\u011bt na \u00fakoly
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -101,25 +118,28 @@ export default function TaskDetailPage() {
|
|||||||
if (editing) {
|
if (editing) {
|
||||||
return (
|
return (
|
||||||
<div className="max-w-lg mx-auto">
|
<div className="max-w-lg mx-auto">
|
||||||
<h1 className="text-xl font-bold mb-4">Upravit ukol</h1>
|
<h1 className="text-xl font-bold mb-4">Upravit \u00fakol</h1>
|
||||||
<TaskForm
|
<TaskForm
|
||||||
groups={groups}
|
groups={groups}
|
||||||
initial={task}
|
initial={task}
|
||||||
onSubmit={handleUpdate}
|
onSubmit={handleUpdate}
|
||||||
onCancel={() => setEditing(false)}
|
onCancel={() => setEditing(false)}
|
||||||
submitLabel="Ulozit zmeny"
|
submitLabel="Ulo\u017eit zm\u011bny"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PRIORITY_LABELS: Record<string, string> = {
|
const PRIORITY_LABELS: Record<string, { label: string; dot: string }> = {
|
||||||
low: "Nizka",
|
low: { label: "N\u00edzk\u00e1", dot: "\ud83d\udfe2" },
|
||||||
medium: "Stredni",
|
medium: { label: "St\u0159edn\u00ed", dot: "\ud83d\udfe1" },
|
||||||
high: "Vysoka",
|
high: { label: "Vysok\u00e1", dot: "\ud83d\udfe0" },
|
||||||
urgent: "Urgentni",
|
urgent: { label: "Urgentn\u00ed", dot: "\ud83d\udd34" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const pri = PRIORITY_LABELS[task.priority] || PRIORITY_LABELS.medium;
|
||||||
|
const taskDone = isDone(task.status);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-lg mx-auto space-y-6">
|
<div className="max-w-lg mx-auto space-y-6">
|
||||||
{/* Back button */}
|
{/* Back button */}
|
||||||
@@ -127,55 +147,89 @@ export default function TaskDetailPage() {
|
|||||||
onClick={() => router.push("/tasks")}
|
onClick={() => router.push("/tasks")}
|
||||||
className="text-sm text-muted hover:text-foreground flex items-center gap-1"
|
className="text-sm text-muted hover:text-foreground flex items-center gap-1"
|
||||||
>
|
>
|
||||||
<svg className="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M15 19l-7-7 7-7" />
|
className="w-4 h-4"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke="currentColor"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth={2}
|
||||||
|
d="M15 19l-7-7 7-7"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
Zpet
|
Zp\u011bt
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{/* Task detail card */}
|
{/* Task detail card */}
|
||||||
<div className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-2xl p-6">
|
<div className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-2xl p-6">
|
||||||
<div className="flex items-start justify-between gap-4 mb-4">
|
<div className="flex items-start justify-between gap-4 mb-4">
|
||||||
<h1 className={`text-xl font-bold ${task.status === "done" ? "line-through text-muted" : ""}`}>
|
<div className="flex items-start gap-3">
|
||||||
|
{task.group_icon && (
|
||||||
|
<span className="text-2xl">{task.group_icon}</span>
|
||||||
|
)}
|
||||||
|
<h1
|
||||||
|
className={`text-xl font-bold ${
|
||||||
|
taskDone ? "line-through text-muted" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
{task.title}
|
{task.title}
|
||||||
</h1>
|
</h1>
|
||||||
|
</div>
|
||||||
<StatusBadge status={task.status} size="md" />
|
<StatusBadge status={task.status} size="md" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{task.description && (
|
{task.description && (
|
||||||
<p className="text-muted mb-4 whitespace-pre-wrap">{task.description}</p>
|
<p className="text-muted mb-4 whitespace-pre-wrap leading-relaxed">
|
||||||
|
{task.description}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-3 text-sm">
|
<div className="grid grid-cols-2 gap-3 text-sm">
|
||||||
<div>
|
<div>
|
||||||
<span className="text-muted">Priorita:</span>
|
<span className="text-muted">Priorita:</span>
|
||||||
<span className="ml-2 font-medium">{PRIORITY_LABELS[task.priority]}</span>
|
<span className="ml-2 font-medium">
|
||||||
|
{pri.dot} {pri.label}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{task.group_name && (
|
{task.group_name && (
|
||||||
<div>
|
<div>
|
||||||
<span className="text-muted">Skupina:</span>
|
<span className="text-muted">Skupina:</span>
|
||||||
<span
|
<span
|
||||||
className="ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium text-white"
|
className="ml-2 inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium text-white"
|
||||||
style={{ backgroundColor: task.group_color || "#6b7280" }}
|
style={{
|
||||||
|
backgroundColor: task.group_color || "#6b7280",
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
|
{task.group_icon && (
|
||||||
|
<span className="mr-1">{task.group_icon}</span>
|
||||||
|
)}
|
||||||
{task.group_name}
|
{task.group_name}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{task.due_at && (
|
{task.due_at && (
|
||||||
<div>
|
<div>
|
||||||
<span className="text-muted">Termin:</span>
|
<span className="text-muted">Term\u00edn:</span>
|
||||||
<span className="ml-2">{new Date(task.due_at).toLocaleString("cs-CZ")}</span>
|
<span className="ml-2">
|
||||||
|
{new Date(task.due_at).toLocaleString("cs-CZ")}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div>
|
<div>
|
||||||
<span className="text-muted">Vytvoreno:</span>
|
<span className="text-muted">Vytvo\u0159eno:</span>
|
||||||
<span className="ml-2">{new Date(task.created_at).toLocaleString("cs-CZ")}</span>
|
<span className="ml-2">
|
||||||
|
{new Date(task.created_at).toLocaleString("cs-CZ")}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{task.completed_at && (
|
{task.completed_at && (
|
||||||
<div>
|
<div>
|
||||||
<span className="text-muted">Dokonceno:</span>
|
<span className="text-muted">Dokon\u010deno:</span>
|
||||||
<span className="ml-2">{new Date(task.completed_at).toLocaleString("cs-CZ")}</span>
|
<span className="ml-2">
|
||||||
|
{new Date(task.completed_at).toLocaleString("cs-CZ")}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -183,12 +237,12 @@ export default function TaskDetailPage() {
|
|||||||
|
|
||||||
{/* Quick status buttons */}
|
{/* Quick status buttons */}
|
||||||
<div className="flex gap-2 flex-wrap">
|
<div className="flex gap-2 flex-wrap">
|
||||||
{task.status !== "done" && (
|
{!taskDone && (
|
||||||
<button
|
<button
|
||||||
onClick={() => handleQuickStatus("done")}
|
onClick={() => handleQuickStatus("done")}
|
||||||
className="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium transition-colors"
|
className="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg text-sm font-medium transition-colors"
|
||||||
>
|
>
|
||||||
Oznacit jako hotove
|
Ozna\u010dit jako hotov\u00e9
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{task.status === "pending" && (
|
{task.status === "pending" && (
|
||||||
@@ -196,15 +250,15 @@ export default function TaskDetailPage() {
|
|||||||
onClick={() => handleQuickStatus("in_progress")}
|
onClick={() => handleQuickStatus("in_progress")}
|
||||||
className="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition-colors"
|
className="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg text-sm font-medium transition-colors"
|
||||||
>
|
>
|
||||||
Zahajit
|
Zah\u00e1jit
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{task.status === "done" && (
|
{taskDone && (
|
||||||
<button
|
<button
|
||||||
onClick={() => handleQuickStatus("pending")}
|
onClick={() => handleQuickStatus("pending")}
|
||||||
className="px-4 py-2 bg-yellow-600 hover:bg-yellow-700 text-white rounded-lg text-sm font-medium transition-colors"
|
className="px-4 py-2 bg-yellow-600 hover:bg-yellow-700 text-white rounded-lg text-sm font-medium transition-colors"
|
||||||
>
|
>
|
||||||
Znovu otevrit
|
Znovu otev\u0159\u00edt
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -222,7 +276,7 @@ export default function TaskDetailPage() {
|
|||||||
disabled={deleting}
|
disabled={deleting}
|
||||||
className="px-6 py-2.5 border border-red-300 dark:border-red-800 text-red-600 dark:text-red-400 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors font-medium disabled:opacity-50"
|
className="px-6 py-2.5 border border-red-300 dark:border-red-800 text-red-600 dark:text-red-400 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors font-medium disabled:opacity-50"
|
||||||
>
|
>
|
||||||
{deleting ? "Mazu..." : "Smazat"}
|
{deleting ? "Ma\u017eu..." : "Smazat"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useAuth } from "@/lib/auth";
|
|||||||
import { getTasks, getGroups, createTask, Task, Group } from "@/lib/api";
|
import { getTasks, getGroups, createTask, Task, Group } from "@/lib/api";
|
||||||
import TaskCard from "@/components/TaskCard";
|
import TaskCard from "@/components/TaskCard";
|
||||||
import GroupSelector from "@/components/GroupSelector";
|
import GroupSelector from "@/components/GroupSelector";
|
||||||
import TaskForm from "@/components/TaskForm";
|
import TaskModal from "@/components/TaskModal";
|
||||||
|
|
||||||
type StatusFilter = "all" | "pending" | "in_progress" | "done" | "cancelled";
|
type StatusFilter = "all" | "pending" | "in_progress" | "done" | "cancelled";
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export default function TasksPage() {
|
|||||||
setTasks(tasksRes.data || []);
|
setTasks(tasksRes.data || []);
|
||||||
setGroups(groupsRes.data || []);
|
setGroups(groupsRes.data || []);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Chyba pri nacitani:", err);
|
console.error("Chyba p\u0159i na\u010d\u00edt\u00e1n\u00ed:", err);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -57,19 +57,23 @@ export default function TasksPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const statusOptions: { value: StatusFilter; label: string }[] = [
|
const statusOptions: { value: StatusFilter; label: string }[] = [
|
||||||
{ value: "all", label: "Vse" },
|
{ value: "all", label: "V\u0161e" },
|
||||||
{ value: "pending", label: "Ceka" },
|
{ value: "pending", label: "\u010Cek\u00e1" },
|
||||||
{ value: "in_progress", label: "Probiha" },
|
{ value: "in_progress", label: "Prob\u00edh\u00e1" },
|
||||||
{ value: "done", label: "Hotovo" },
|
{ value: "done", label: "Hotovo" },
|
||||||
{ value: "cancelled", label: "Zruseno" },
|
{ value: "cancelled", label: "Zru\u0161eno" },
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!token) return null;
|
if (!token) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-4">
|
<div className="space-y-4 pb-24">
|
||||||
{/* Group tabs */}
|
{/* Group tabs */}
|
||||||
<GroupSelector groups={groups} selected={selectedGroup} onSelect={setSelectedGroup} />
|
<GroupSelector
|
||||||
|
groups={groups}
|
||||||
|
selected={selectedGroup}
|
||||||
|
onSelect={setSelectedGroup}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* Status filter */}
|
{/* Status filter */}
|
||||||
<div className="flex gap-1.5 overflow-x-auto scrollbar-hide pb-1">
|
<div className="flex gap-1.5 overflow-x-auto scrollbar-hide pb-1">
|
||||||
@@ -77,7 +81,7 @@ export default function TasksPage() {
|
|||||||
<button
|
<button
|
||||||
key={opt.value}
|
key={opt.value}
|
||||||
onClick={() => setStatusFilter(opt.value)}
|
onClick={() => setStatusFilter(opt.value)}
|
||||||
className={`flex-shrink-0 px-3 py-1.5 rounded-lg text-xs font-medium transition-all ${
|
className={`flex-shrink-0 px-3 py-1.5 rounded-lg text-xs font-medium transition-all min-h-[36px] ${
|
||||||
statusFilter === opt.value
|
statusFilter === opt.value
|
||||||
? "bg-gray-800 text-white dark:bg-white dark:text-gray-900"
|
? "bg-gray-800 text-white dark:bg-white dark:text-gray-900"
|
||||||
: "bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"
|
: "bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"
|
||||||
@@ -88,29 +92,18 @@ export default function TasksPage() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Task creation form */}
|
|
||||||
{showForm && (
|
|
||||||
<div className="bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-2xl p-5">
|
|
||||||
<h2 className="text-lg font-semibold mb-4">Novy ukol</h2>
|
|
||||||
<TaskForm
|
|
||||||
groups={groups}
|
|
||||||
onSubmit={handleCreateTask}
|
|
||||||
onCancel={() => setShowForm(false)}
|
|
||||||
submitLabel="Vytvorit"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* Task list */}
|
{/* Task list */}
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="flex justify-center py-12">
|
<div className="flex justify-center py-12">
|
||||||
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"></div>
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" />
|
||||||
</div>
|
</div>
|
||||||
) : tasks.length === 0 ? (
|
) : tasks.length === 0 ? (
|
||||||
<div className="text-center py-16">
|
<div className="text-center py-16">
|
||||||
<div className="text-4xl mb-3">☐</div>
|
<div className="text-5xl mb-4 opacity-50">☐</div>
|
||||||
<p className="text-muted text-lg">Zadne ukoly</p>
|
<p className="text-muted text-lg font-medium">\u017d\u00e1dn\u00e9 \u00fakoly</p>
|
||||||
<p className="text-muted text-sm mt-1">Vytvorte prvni ukol pomoci tlacitka +</p>
|
<p className="text-muted text-sm mt-1">
|
||||||
|
Vytvo\u0159te prvn\u00ed \u00fakol pomoc\u00ed tla\u010d\u00edtka +
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
@@ -120,15 +113,34 @@ export default function TasksPage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Floating add button */}
|
{/* Floating action button */}
|
||||||
{!showForm && (
|
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowForm(true)}
|
onClick={() => setShowForm(true)}
|
||||||
className="fixed bottom-6 right-6 w-14 h-14 bg-blue-600 hover:bg-blue-700 text-white rounded-full shadow-lg hover:shadow-xl transition-all flex items-center justify-center text-2xl font-light"
|
className="fixed bottom-6 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="P\u0159idat \u00fakol"
|
||||||
>
|
>
|
||||||
+
|
<svg
|
||||||
|
className="w-7 h-7"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth={2.5}
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
d="M12 4v16m8-8H4"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
{/* Add task modal */}
|
||||||
|
{showForm && (
|
||||||
|
<TaskModal
|
||||||
|
groups={groups}
|
||||||
|
onSubmit={handleCreateTask}
|
||||||
|
onClose={() => setShowForm(false)}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,34 +8,43 @@ interface GroupSelectorProps {
|
|||||||
onSelect: (id: string | null) => void;
|
onSelect: (id: string | null) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function GroupSelector({ groups, selected, onSelect }: GroupSelectorProps) {
|
export default function GroupSelector({
|
||||||
|
groups,
|
||||||
|
selected,
|
||||||
|
onSelect,
|
||||||
|
}: GroupSelectorProps) {
|
||||||
return (
|
return (
|
||||||
<div className="flex gap-2 overflow-x-auto scrollbar-hide py-2 px-1">
|
<div
|
||||||
|
className="flex gap-2 overflow-x-auto scrollbar-hide px-4 py-3"
|
||||||
|
style={{ WebkitOverflowScrolling: "touch" } as React.CSSProperties}
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
onClick={() => onSelect(null)}
|
onClick={() => onSelect(null)}
|
||||||
className={`flex-shrink-0 px-4 py-2 rounded-full text-sm font-medium transition-all ${
|
className={`flex-shrink-0 px-4 py-2 rounded-full text-sm font-medium transition-all min-h-[36px] whitespace-nowrap ${
|
||||||
selected === null
|
selected === null
|
||||||
? "bg-gray-800 text-white dark:bg-white dark:text-gray-900"
|
? "bg-gray-800 text-white dark:bg-white dark:text-gray-900 shadow-md"
|
||||||
: "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"
|
: "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
Vse
|
V\u0161e
|
||||||
</button>
|
</button>
|
||||||
{groups.map((g) => (
|
{groups.map((g) => (
|
||||||
<button
|
<button
|
||||||
key={g.id}
|
key={g.id}
|
||||||
onClick={() => onSelect(g.id)}
|
onClick={() => onSelect(g.id)}
|
||||||
className={`flex-shrink-0 px-4 py-2 rounded-full text-sm font-medium transition-all ${
|
className={`flex-shrink-0 px-4 py-2 rounded-full text-sm font-medium transition-all min-h-[36px] flex items-center gap-1.5 whitespace-nowrap ${
|
||||||
selected === g.id
|
selected === g.id
|
||||||
? "text-white shadow-md"
|
? "text-white shadow-md"
|
||||||
: "text-gray-600 dark:text-gray-400 hover:opacity-80"
|
: "hover:opacity-80"
|
||||||
}`}
|
}`}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: selected === g.id ? g.color : undefined,
|
backgroundColor: selected === g.id ? g.color : undefined,
|
||||||
border: selected !== g.id ? `2px solid ${g.color}` : undefined,
|
border: selected !== g.id ? `2px solid ${g.color}` : undefined,
|
||||||
|
color: selected !== g.id ? g.color : undefined,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{g.icon ? `${g.icon} ` : ""}{g.name}
|
{g.icon && <span className="text-base">{g.icon}</span>}
|
||||||
|
<span>{g.name}</span>
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,43 +18,66 @@ export default function Header() {
|
|||||||
return (
|
return (
|
||||||
<header className="sticky top-0 z-50 bg-white/80 dark:bg-gray-950/80 backdrop-blur-md border-b border-gray-200 dark:border-gray-800">
|
<header className="sticky top-0 z-50 bg-white/80 dark:bg-gray-950/80 backdrop-blur-md border-b border-gray-200 dark:border-gray-800">
|
||||||
<div className="max-w-4xl mx-auto px-4 h-14 flex items-center justify-between">
|
<div className="max-w-4xl mx-auto px-4 h-14 flex items-center justify-between">
|
||||||
<Link href="/tasks" className="text-lg font-bold tracking-tight">
|
<Link href="/tasks" className="flex items-center gap-2">
|
||||||
Task Team
|
<div className="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center">
|
||||||
|
<svg className="w-4 h-4 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2.5}>
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<span className="text-lg font-bold tracking-tight">Task Team</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-2">
|
||||||
|
{/* Theme toggle */}
|
||||||
<button
|
<button
|
||||||
onClick={toggleTheme}
|
onClick={toggleTheme}
|
||||||
className="p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors"
|
className="p-2.5 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center"
|
||||||
aria-label="Prepnout tema"
|
aria-label="P\u0159epnout t\u00e9ma"
|
||||||
>
|
>
|
||||||
{theme === "dark" ? (
|
{theme === "dark" ? (
|
||||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" />
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth={2}
|
||||||
|
d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
) : (
|
) : (
|
||||||
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
|
<path
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
strokeWidth={2}
|
||||||
|
d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
)}
|
)}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{token && user ? (
|
{token && user ? (
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="text-sm text-muted hidden sm:inline">{user.name || user.email}</span>
|
<div className="hidden sm:flex items-center gap-2">
|
||||||
|
<div className="w-7 h-7 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 rounded-full flex items-center justify-center text-xs font-bold">
|
||||||
|
{(user.name || user.email || "?").charAt(0).toUpperCase()}
|
||||||
|
</div>
|
||||||
|
<span className="text-sm text-muted max-w-[120px] truncate">
|
||||||
|
{user.name || user.email}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={handleLogout}
|
onClick={handleLogout}
|
||||||
className="text-sm px-3 py-1.5 rounded-lg border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"
|
className="text-sm px-3 py-1.5 rounded-lg border border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors min-h-[44px] flex items-center"
|
||||||
>
|
>
|
||||||
Odhlasit
|
Odhl\u00e1sit
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Link
|
<Link
|
||||||
href="/login"
|
href="/login"
|
||||||
className="text-sm px-3 py-1.5 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors"
|
className="text-sm px-4 py-2 rounded-lg bg-blue-600 text-white hover:bg-blue-700 transition-colors min-h-[44px] flex items-center"
|
||||||
>
|
>
|
||||||
Prihlasit
|
P\u0159ihl\u00e1sit
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,11 +5,37 @@ interface StatusBadgeProps {
|
|||||||
size?: "sm" | "md";
|
size?: "sm" | "md";
|
||||||
}
|
}
|
||||||
|
|
||||||
const STATUS_MAP: Record<string, { label: string; bg: string; text: string }> = {
|
const STATUS_MAP: Record<string, { label: string; bg: string; text: string; dot: string }> = {
|
||||||
pending: { label: "Ceka", bg: "bg-yellow-100 dark:bg-yellow-900/30", text: "text-yellow-800 dark:text-yellow-300" },
|
pending: {
|
||||||
in_progress: { label: "Probiha", bg: "bg-blue-100 dark:bg-blue-900/30", text: "text-blue-800 dark:text-blue-300" },
|
label: "\u010Cek\u00e1",
|
||||||
done: { label: "Hotovo", bg: "bg-green-100 dark:bg-green-900/30", text: "text-green-800 dark:text-green-300" },
|
bg: "bg-yellow-100 dark:bg-yellow-900/30",
|
||||||
cancelled: { label: "Zruseno", bg: "bg-gray-100 dark:bg-gray-800/30", text: "text-gray-600 dark:text-gray-400" },
|
text: "text-yellow-800 dark:text-yellow-300",
|
||||||
|
dot: "bg-yellow-500",
|
||||||
|
},
|
||||||
|
in_progress: {
|
||||||
|
label: "Prob\u00edh\u00e1",
|
||||||
|
bg: "bg-blue-100 dark:bg-blue-900/30",
|
||||||
|
text: "text-blue-800 dark:text-blue-300",
|
||||||
|
dot: "bg-blue-500",
|
||||||
|
},
|
||||||
|
done: {
|
||||||
|
label: "Hotovo",
|
||||||
|
bg: "bg-green-100 dark:bg-green-900/30",
|
||||||
|
text: "text-green-800 dark:text-green-300",
|
||||||
|
dot: "bg-green-500",
|
||||||
|
},
|
||||||
|
completed: {
|
||||||
|
label: "Hotovo",
|
||||||
|
bg: "bg-green-100 dark:bg-green-900/30",
|
||||||
|
text: "text-green-800 dark:text-green-300",
|
||||||
|
dot: "bg-green-500",
|
||||||
|
},
|
||||||
|
cancelled: {
|
||||||
|
label: "Zru\u0161eno",
|
||||||
|
bg: "bg-gray-100 dark:bg-gray-800/30",
|
||||||
|
text: "text-gray-600 dark:text-gray-400",
|
||||||
|
dot: "bg-gray-400",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function StatusBadge({ status, size = "sm" }: StatusBadgeProps) {
|
export default function StatusBadge({ status, size = "sm" }: StatusBadgeProps) {
|
||||||
@@ -17,7 +43,10 @@ export default function StatusBadge({ status, size = "sm" }: StatusBadgeProps) {
|
|||||||
const sizeClass = size === "sm" ? "px-2 py-0.5 text-xs" : "px-3 py-1 text-sm";
|
const sizeClass = size === "sm" ? "px-2 py-0.5 text-xs" : "px-3 py-1 text-sm";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={`inline-flex items-center rounded-full font-medium ${s.bg} ${s.text} ${sizeClass}`}>
|
<span
|
||||||
|
className={`inline-flex items-center gap-1.5 rounded-full font-medium ${s.bg} ${s.text} ${sizeClass}`}
|
||||||
|
>
|
||||||
|
<span className={`w-1.5 h-1.5 rounded-full ${s.dot}`} />
|
||||||
{s.label}
|
{s.label}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -8,54 +8,86 @@ interface TaskCardProps {
|
|||||||
task: Task;
|
task: Task;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PRIORITY_INDICATOR: Record<string, string> = {
|
const PRIORITY_DOT: Record<string, string> = {
|
||||||
urgent: "border-l-red-500",
|
urgent: "\ud83d\udd34",
|
||||||
high: "border-l-orange-500",
|
high: "\ud83d\udfe0",
|
||||||
medium: "border-l-yellow-500",
|
medium: "\ud83d\udfe1",
|
||||||
low: "border-l-green-500",
|
low: "\ud83d\udfe2",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function isDone(status: string): boolean {
|
||||||
|
return status === "done" || status === "completed";
|
||||||
|
}
|
||||||
|
|
||||||
export default function TaskCard({ task }: TaskCardProps) {
|
export default function TaskCard({ task }: TaskCardProps) {
|
||||||
const priorityClass = PRIORITY_INDICATOR[task.priority] || PRIORITY_INDICATOR.medium;
|
const dot = PRIORITY_DOT[task.priority] || PRIORITY_DOT.medium;
|
||||||
|
const groupColor = task.group_color || "#6b7280";
|
||||||
|
const taskDone = isDone(task.status);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Link href={`/tasks/${task.id}`}>
|
<Link href={`/tasks/${task.id}`} className="block group">
|
||||||
|
<div className="relative bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl overflow-hidden hover:shadow-lg transition-all duration-200 active:scale-[0.98]">
|
||||||
|
{/* Color bar on left */}
|
||||||
<div
|
<div
|
||||||
className={`bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 border-l-4 ${priorityClass} rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer`}
|
className="absolute left-0 top-0 bottom-0 w-1 rounded-l-xl"
|
||||||
>
|
style={{ backgroundColor: groupColor }}
|
||||||
<div className="flex items-start justify-between gap-3">
|
/>
|
||||||
|
|
||||||
|
<div className="pl-4 pr-4 py-3.5">
|
||||||
|
<div className="flex items-start gap-3">
|
||||||
|
{/* Group icon */}
|
||||||
|
{task.group_icon && (
|
||||||
|
<span className="text-xl flex-shrink-0 mt-0.5">{task.group_icon}</span>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Content */}
|
||||||
<div className="flex-1 min-w-0">
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="flex items-start justify-between gap-2">
|
||||||
<h3
|
<h3
|
||||||
className={`font-medium truncate ${
|
className={`font-semibold text-[15px] leading-snug ${
|
||||||
task.status === "done" ? "line-through text-muted" : ""
|
taskDone ? "line-through text-muted" : ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{task.title}
|
{task.title}
|
||||||
</h3>
|
</h3>
|
||||||
|
<span className="flex-shrink-0 text-sm" title={task.priority}>
|
||||||
|
{dot}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
{task.description && (
|
{task.description && (
|
||||||
<p className="text-sm text-muted mt-1 line-clamp-2">{task.description}</p>
|
<p className="text-sm text-muted mt-1 line-clamp-2 leading-relaxed">
|
||||||
|
{task.description}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
<div className="flex items-center gap-2 mt-2 flex-wrap">
|
|
||||||
|
<div className="flex items-center gap-2 mt-2.5 flex-wrap">
|
||||||
<StatusBadge status={task.status} />
|
<StatusBadge status={task.status} />
|
||||||
{task.group_name && (
|
{task.group_name && (
|
||||||
<span
|
<span
|
||||||
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium text-white"
|
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium text-white"
|
||||||
style={{ backgroundColor: task.group_color || "#6b7280" }}
|
style={{ backgroundColor: groupColor }}
|
||||||
>
|
>
|
||||||
{task.group_name}
|
{task.group_name}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{task.due_at && (
|
{task.due_at && (
|
||||||
<span className="text-xs text-muted">
|
<span className="text-xs text-muted flex items-center gap-1">
|
||||||
|
<svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||||
|
</svg>
|
||||||
{new Date(task.due_at).toLocaleDateString("cs-CZ")}
|
{new Date(task.due_at).toLocaleDateString("cs-CZ")}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex-shrink-0">
|
</div>
|
||||||
<span className="text-xs text-muted">
|
|
||||||
{task.priority === "urgent" ? "!!!" : task.priority === "high" ? "!!" : task.priority === "medium" ? "!" : ""}
|
{/* Swipe hint on mobile */}
|
||||||
</span>
|
<div className="absolute right-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-30 transition-opacity sm:hidden">
|
||||||
|
<svg className="w-4 h-4 text-muted" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||||
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 5l7 7-7 7" />
|
||||||
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,33 +12,41 @@ interface TaskFormProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const STATUSES = [
|
const STATUSES = [
|
||||||
{ value: "pending", label: "Ceka" },
|
{ value: "pending", label: "\u010Cek\u00e1" },
|
||||||
{ value: "in_progress", label: "Probiha" },
|
{ value: "in_progress", label: "Prob\u00edh\u00e1" },
|
||||||
{ value: "done", label: "Hotovo" },
|
{ value: "done", label: "Hotovo" },
|
||||||
{ value: "cancelled", label: "Zruseno" },
|
{ value: "cancelled", label: "Zru\u0161eno" },
|
||||||
];
|
];
|
||||||
|
|
||||||
const PRIORITIES = [
|
const PRIORITIES = [
|
||||||
{ value: "low", label: "Nizka" },
|
{ value: "low", label: "N\u00edzk\u00e1" },
|
||||||
{ value: "medium", label: "Stredni" },
|
{ value: "medium", label: "St\u0159edn\u00ed" },
|
||||||
{ value: "high", label: "Vysoka" },
|
{ value: "high", label: "Vysok\u00e1" },
|
||||||
{ value: "urgent", label: "Urgentni" },
|
{ value: "urgent", label: "Urgentn\u00ed" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLabel = "Ulozit" }: TaskFormProps) {
|
export default function TaskForm({
|
||||||
|
groups,
|
||||||
|
initial,
|
||||||
|
onSubmit,
|
||||||
|
onCancel,
|
||||||
|
submitLabel = "Ulo\u017eit",
|
||||||
|
}: TaskFormProps) {
|
||||||
const [title, setTitle] = useState(initial?.title || "");
|
const [title, setTitle] = useState(initial?.title || "");
|
||||||
const [description, setDescription] = useState(initial?.description || "");
|
const [description, setDescription] = useState(initial?.description || "");
|
||||||
const [status, setStatus] = useState(initial?.status || "pending");
|
const [status, setStatus] = useState(initial?.status || "pending");
|
||||||
const [priority, setPriority] = useState(initial?.priority || "medium");
|
const [priority, setPriority] = useState(initial?.priority || "medium");
|
||||||
const [groupId, setGroupId] = useState(initial?.group_id || "");
|
const [groupId, setGroupId] = useState(initial?.group_id || "");
|
||||||
const [dueAt, setDueAt] = useState(initial?.due_at ? initial.due_at.slice(0, 16) : "");
|
const [dueAt, setDueAt] = useState(
|
||||||
|
initial?.due_at ? initial.due_at.slice(0, 16) : ""
|
||||||
|
);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
|
|
||||||
async function handleSubmit(e: React.FormEvent) {
|
async function handleSubmit(e: React.FormEvent) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!title.trim()) {
|
if (!title.trim()) {
|
||||||
setError("Nazev je povinny");
|
setError("N\u00e1zev je povinn\u00fd");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -53,7 +61,9 @@ export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLa
|
|||||||
due_at: dueAt ? new Date(dueAt).toISOString() : null,
|
due_at: dueAt ? new Date(dueAt).toISOString() : null,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : "Chyba pri ukladani");
|
setError(
|
||||||
|
err instanceof Error ? err.message : "Chyba p\u0159i ukl\u00e1d\u00e1n\u00ed"
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
@@ -68,13 +78,13 @@ export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLa
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1">Nazev *</label>
|
<label className="block text-sm font-medium mb-1">N\u00e1zev *</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={title}
|
value={title}
|
||||||
onChange={(e) => setTitle(e.target.value)}
|
onChange={(e) => setTitle(e.target.value)}
|
||||||
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none"
|
className="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none transition-shadow"
|
||||||
placeholder="Co je treba udelat..."
|
placeholder="Co je t\u0159eba ud\u011blat..."
|
||||||
autoFocus
|
autoFocus
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -85,7 +95,7 @@ export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLa
|
|||||||
value={description}
|
value={description}
|
||||||
onChange={(e) => setDescription(e.target.value)}
|
onChange={(e) => setDescription(e.target.value)}
|
||||||
rows={3}
|
rows={3}
|
||||||
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none resize-none"
|
className="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 focus:border-transparent outline-none resize-none transition-shadow"
|
||||||
placeholder="Podrobnosti..."
|
placeholder="Podrobnosti..."
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -95,11 +105,21 @@ export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLa
|
|||||||
<label className="block text-sm font-medium mb-1">Stav</label>
|
<label className="block text-sm font-medium mb-1">Stav</label>
|
||||||
<select
|
<select
|
||||||
value={status}
|
value={status}
|
||||||
onChange={(e) => setStatus(e.target.value as "pending" | "in_progress" | "done" | "cancelled")}
|
onChange={(e) =>
|
||||||
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none"
|
setStatus(
|
||||||
|
e.target.value as
|
||||||
|
| "pending"
|
||||||
|
| "in_progress"
|
||||||
|
| "done"
|
||||||
|
| "cancelled"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none min-h-[44px]"
|
||||||
>
|
>
|
||||||
{STATUSES.map((s) => (
|
{STATUSES.map((s) => (
|
||||||
<option key={s.value} value={s.value}>{s.label}</option>
|
<option key={s.value} value={s.value}>
|
||||||
|
{s.label}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -109,10 +129,12 @@ export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLa
|
|||||||
<select
|
<select
|
||||||
value={priority}
|
value={priority}
|
||||||
onChange={(e) => setPriority(e.target.value as any)}
|
onChange={(e) => setPriority(e.target.value as any)}
|
||||||
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none"
|
className="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none min-h-[44px]"
|
||||||
>
|
>
|
||||||
{PRIORITIES.map((p) => (
|
{PRIORITIES.map((p) => (
|
||||||
<option key={p.value} value={p.value}>{p.label}</option>
|
<option key={p.value} value={p.value}>
|
||||||
|
{p.label}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -124,22 +146,24 @@ export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLa
|
|||||||
<select
|
<select
|
||||||
value={groupId}
|
value={groupId}
|
||||||
onChange={(e) => setGroupId(e.target.value as any)}
|
onChange={(e) => setGroupId(e.target.value as any)}
|
||||||
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none"
|
className="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none min-h-[44px]"
|
||||||
>
|
>
|
||||||
<option value="">-- Bez skupiny --</option>
|
<option value="">-- Bez skupiny --</option>
|
||||||
{groups.map((g) => (
|
{groups.map((g) => (
|
||||||
<option key={g.id} value={g.id}>{g.name}</option>
|
<option key={g.id} value={g.id}>
|
||||||
|
{g.icon ? `${g.icon} ` : ""}{g.name}
|
||||||
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1">Termin</label>
|
<label className="block text-sm font-medium mb-1">Term\u00edn</label>
|
||||||
<input
|
<input
|
||||||
type="datetime-local"
|
type="datetime-local"
|
||||||
value={dueAt}
|
value={dueAt}
|
||||||
onChange={(e) => setDueAt(e.target.value)}
|
onChange={(e) => setDueAt(e.target.value)}
|
||||||
className="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none"
|
className="w-full px-3 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 focus:ring-2 focus:ring-blue-500 outline-none min-h-[44px]"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -148,16 +172,16 @@ export default function TaskForm({ groups, initial, onSubmit, onCancel, submitLa
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
className="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2.5 px-4 rounded-lg transition-colors disabled:opacity-50"
|
className="flex-1 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2.5 px-4 rounded-lg transition-colors disabled:opacity-50 min-h-[44px]"
|
||||||
>
|
>
|
||||||
{loading ? "Ukladam..." : submitLabel}
|
{loading ? "Ukl\u00e1d\u00e1m..." : submitLabel}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onCancel}
|
onClick={onCancel}
|
||||||
className="px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors"
|
className="px-4 py-2.5 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors min-h-[44px]"
|
||||||
>
|
>
|
||||||
Zrusit
|
Zru\u0161it
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
98
apps/tasks/components/TaskModal.tsx
Normal file
98
apps/tasks/components/TaskModal.tsx
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState, useCallback } from "react";
|
||||||
|
import { Group, Task } from "@/lib/api";
|
||||||
|
import TaskForm from "@/components/TaskForm";
|
||||||
|
|
||||||
|
interface TaskModalProps {
|
||||||
|
groups: Group[];
|
||||||
|
onSubmit: (data: Partial<Task>) => Promise<void>;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function TaskModal({ groups, onSubmit, onClose }: TaskModalProps) {
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
|
||||||
|
const handleClose = useCallback(() => {
|
||||||
|
setVisible(false);
|
||||||
|
setTimeout(onClose, 200);
|
||||||
|
}, [onClose]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Trigger enter animation on next frame
|
||||||
|
requestAnimationFrame(() => setVisible(true));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function handleKeyDown(e: KeyboardEvent) {
|
||||||
|
if (e.key === "Escape") handleClose();
|
||||||
|
}
|
||||||
|
document.addEventListener("keydown", handleKeyDown);
|
||||||
|
// Prevent body scroll
|
||||||
|
document.body.style.overflow = "hidden";
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("keydown", handleKeyDown);
|
||||||
|
document.body.style.overflow = "";
|
||||||
|
};
|
||||||
|
}, [handleClose]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="fixed inset-0 z-50 flex items-end sm:items-center justify-center"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label="Nov\u00fd \u00fakol"
|
||||||
|
>
|
||||||
|
{/* Backdrop */}
|
||||||
|
<div
|
||||||
|
className={`absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity duration-200 ${
|
||||||
|
visible ? "opacity-100" : "opacity-0"
|
||||||
|
}`}
|
||||||
|
onClick={handleClose}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* Modal panel with slide-up animation */}
|
||||||
|
<div
|
||||||
|
className={`relative w-full sm:max-w-lg bg-white dark:bg-gray-900 rounded-t-2xl sm:rounded-2xl shadow-2xl p-6 transition-all duration-200 ease-out ${
|
||||||
|
visible
|
||||||
|
? "translate-y-0 opacity-100"
|
||||||
|
: "translate-y-8 opacity-0"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{/* Drag handle for mobile */}
|
||||||
|
<div className="flex justify-center mb-3 sm:hidden">
|
||||||
|
<div className="w-10 h-1 bg-gray-300 dark:bg-gray-600 rounded-full" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center justify-between mb-5">
|
||||||
|
<h2 className="text-lg font-semibold">Nov\u00fd \u00fakol</h2>
|
||||||
|
<button
|
||||||
|
onClick={handleClose}
|
||||||
|
className="p-2 rounded-lg text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors min-w-[44px] min-h-[44px] flex items-center justify-center"
|
||||||
|
aria-label="Zav\u0159\u00edt"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
className="h-5 w-5"
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fillRule="evenodd"
|
||||||
|
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
||||||
|
clipRule="evenodd"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TaskForm
|
||||||
|
groups={groups}
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
onCancel={handleClose}
|
||||||
|
submitLabel="Vytvo\u0159it"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user