criar task
This commit is contained in:
parent
2bb1ec97a9
commit
3312f2276c
18 changed files with 747 additions and 982 deletions
|
|
@ -16,7 +16,6 @@ export default defineConfig([
|
|||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<html lang="pt-BR">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;600&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>frontend</title>
|
||||
<title>Bee Task</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
|
|
|||
1092
frontend/package-lock.json
generated
1092
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -10,23 +10,26 @@
|
|||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.4"
|
||||
"@tailwindcss/vite": "^4.2.4",
|
||||
"react": "^19.2.5",
|
||||
"react-dom": "^19.2.5",
|
||||
"react-router-dom": "^7.9.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.4",
|
||||
"@tailwindcss/vite": "^4.2.2",
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@types/node": "^24.12.2",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"autoprefixer": "^10.5.0",
|
||||
"eslint": "^10.2.1",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"globals": "^17.4.0",
|
||||
"tailwindcss": "^4.2.2",
|
||||
"globals": "^17.5.0",
|
||||
"postcss": "^8.5.12",
|
||||
"tailwindcss": "^4.2.4",
|
||||
"typescript": "~6.0.2",
|
||||
"typescript-eslint": "^8.58.0",
|
||||
"vite": "^8.0.4"
|
||||
"typescript-eslint": "^8.58.2",
|
||||
"vite": "^8.0.10"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||
</symbol>
|
||||
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||
</symbol>
|
||||
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||
</symbol>
|
||||
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||
</symbol>
|
||||
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 4.9 KiB |
|
|
@ -1,121 +1,9 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
import { createTask, listTasks, updateTaskStatus } from './api'
|
||||
import { CreateTaskForm } from './components/CreateTaskForm'
|
||||
import { TaskItem } from './components/TaskItem'
|
||||
import type { Task, TaskStatus } from './types'
|
||||
import { RouterProvider } from 'react-router-dom'
|
||||
|
||||
import { router } from './router'
|
||||
|
||||
function App() {
|
||||
const [tasks, setTasks] = useState<Task[]>([])
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [updatingTaskIds, setUpdatingTaskIds] = useState<string[]>([])
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
async function loadTasks() {
|
||||
try {
|
||||
setIsLoading(true)
|
||||
const data = await listTasks()
|
||||
setTasks(data)
|
||||
} catch (loadError) {
|
||||
setError(loadError instanceof Error ? loadError.message : 'Could not load tasks.')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
void loadTasks()
|
||||
}, [])
|
||||
|
||||
async function handleCreateTask(input: { name: string; description: string }) {
|
||||
try {
|
||||
setIsSubmitting(true)
|
||||
setError(null)
|
||||
const createdTask = await createTask(input)
|
||||
setTasks((current) => [createdTask, ...current])
|
||||
} catch (submitError) {
|
||||
setError(submitError instanceof Error ? submitError.message : 'Could not create task.')
|
||||
throw submitError
|
||||
} finally {
|
||||
setIsSubmitting(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleStatusChange(taskId: string, status: TaskStatus) {
|
||||
try {
|
||||
setError(null)
|
||||
setUpdatingTaskIds((current) => [...current, taskId])
|
||||
const updatedTask = await updateTaskStatus(taskId, status)
|
||||
|
||||
setTasks((current) =>
|
||||
current.map((task) => (task.id === updatedTask.id ? updatedTask : task)),
|
||||
)
|
||||
} catch (updateError) {
|
||||
setError(updateError instanceof Error ? updateError.message : 'Could not update the task.')
|
||||
} finally {
|
||||
setUpdatingTaskIds((current) => current.filter((id) => id !== taskId))
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="min-h-screen bg-[radial-gradient(circle_at_top,_rgba(125,211,252,0.35),_transparent_35%),linear-gradient(180deg,_#f8fafc_0%,_#e2e8f0_100%)] px-4 py-10 text-slate-800">
|
||||
<div className="mx-auto grid max-w-6xl gap-6 lg:grid-cols-[420px_minmax(0,1fr)]">
|
||||
<section className="space-y-6">
|
||||
<div className="rounded-[2rem] border border-white/70 bg-white/70 p-6 shadow-[0_24px_80px_rgba(15,23,42,0.08)] backdrop-blur">
|
||||
<p className="text-sm uppercase tracking-[0.3em] text-slate-500">TimeTrack MVP</p>
|
||||
<h1 className="mt-4 max-w-sm text-5xl font-semibold tracking-[-0.04em] text-slate-950">
|
||||
Task management in one simple slice.
|
||||
</h1>
|
||||
<p className="mt-4 text-base leading-7 text-slate-600">
|
||||
Create tasks, move them through progress, and keep the flow visible while the wider
|
||||
platform is still being built.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<CreateTaskForm isSubmitting={isSubmitting} onSubmit={handleCreateTask} />
|
||||
</section>
|
||||
|
||||
<section className="rounded-[2.5rem] border border-white/70 bg-white/65 p-6 shadow-[0_24px_80px_rgba(15,23,42,0.08)] backdrop-blur">
|
||||
<div className="flex flex-col gap-3 border-b border-slate-200 pb-5 sm:flex-row sm:items-end sm:justify-between">
|
||||
<div>
|
||||
<p className="text-sm uppercase tracking-[0.3em] text-slate-500">Task list</p>
|
||||
<h2 className="mt-2 text-3xl font-semibold tracking-[-0.04em] text-slate-950">
|
||||
Current work
|
||||
</h2>
|
||||
</div>
|
||||
<p className="text-sm text-slate-500">{tasks.length} tasks loaded</p>
|
||||
</div>
|
||||
|
||||
{error ? (
|
||||
<div className="mt-5 rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700">
|
||||
{error}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isLoading ? (
|
||||
<div className="mt-6 rounded-[2rem] border border-dashed border-slate-300 px-6 py-12 text-center text-slate-500">
|
||||
Loading tasks...
|
||||
</div>
|
||||
) : tasks.length === 0 ? (
|
||||
<div className="mt-6 rounded-[2rem] border border-dashed border-slate-300 px-6 py-12 text-center text-slate-500">
|
||||
No tasks yet. Create the first one from the panel on the left.
|
||||
</div>
|
||||
) : (
|
||||
<div className="mt-6 grid gap-4">
|
||||
{tasks.map((task) => (
|
||||
<TaskItem
|
||||
key={task.id}
|
||||
task={task}
|
||||
isUpdating={updatingTaskIds.includes(task.id)}
|
||||
onStatusChange={handleStatusChange}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
return <RouterProvider router={router} />
|
||||
}
|
||||
|
||||
export default App
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
import type { Task, TaskStatus } from './types'
|
||||
|
||||
const API_BASE_URL = import.meta.env.VITE_API_URL ?? '/api'
|
||||
|
||||
async function request<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(init?.headers ?? {}),
|
||||
},
|
||||
...init,
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const fallbackMessage = 'Something went wrong while talking to the API.'
|
||||
let message = fallbackMessage
|
||||
|
||||
try {
|
||||
const error = (await response.json()) as { message?: string }
|
||||
message = error.message ?? fallbackMessage
|
||||
} catch {
|
||||
message = fallbackMessage
|
||||
}
|
||||
|
||||
throw new Error(message)
|
||||
}
|
||||
|
||||
return (await response.json()) as T
|
||||
}
|
||||
|
||||
export function listTasks(): Promise<Task[]> {
|
||||
return request<Task[]>('/tasks')
|
||||
}
|
||||
|
||||
export function createTask(input: { name: string; description?: string }): Promise<Task> {
|
||||
return request<Task>('/tasks', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(input),
|
||||
})
|
||||
}
|
||||
|
||||
export function updateTaskStatus(taskId: string, status: TaskStatus): Promise<Task> {
|
||||
return request<Task>(`/tasks/${taskId}/status`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ status }),
|
||||
})
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
import { type FormEvent, useState } from 'react'
|
||||
|
||||
interface CreateTaskFormProps {
|
||||
isSubmitting: boolean
|
||||
onSubmit: (input: { name: string; description: string }) => Promise<void>
|
||||
}
|
||||
|
||||
export function CreateTaskForm({ isSubmitting, onSubmit }: CreateTaskFormProps) {
|
||||
const [name, setName] = useState('')
|
||||
const [description, setDescription] = useState('')
|
||||
|
||||
async function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault()
|
||||
await onSubmit({ name, description })
|
||||
setName('')
|
||||
setDescription('')
|
||||
}
|
||||
|
||||
return (
|
||||
<form
|
||||
className="rounded-[2rem] border border-slate-900/10 bg-slate-950 p-6 text-white shadow-[0_24px_80px_rgba(15,23,42,0.24)]"
|
||||
onSubmit={handleSubmit}
|
||||
>
|
||||
<div className="mb-6">
|
||||
<p className="text-sm uppercase tracking-[0.25em] text-sky-200">Create task</p>
|
||||
<h2 className="mt-3 text-3xl font-semibold">Capture work while it is fresh.</h2>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<label className="block text-sm text-slate-200">
|
||||
<span className="mb-2 block font-medium">Name</span>
|
||||
<input
|
||||
className="w-full rounded-2xl border border-white/10 bg-white/10 px-4 py-3 text-white outline-none transition placeholder:text-slate-400 focus:border-sky-300"
|
||||
placeholder="Prepare sprint review"
|
||||
value={name}
|
||||
onChange={(event) => setName(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="block text-sm text-slate-200">
|
||||
<span className="mb-2 block font-medium">Description</span>
|
||||
<textarea
|
||||
className="min-h-28 w-full rounded-2xl border border-white/10 bg-white/10 px-4 py-3 text-white outline-none transition placeholder:text-slate-400 focus:border-sky-300"
|
||||
placeholder="Optional context for this task"
|
||||
value={description}
|
||||
onChange={(event) => setDescription(event.target.value)}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isSubmitting}
|
||||
className="mt-6 inline-flex items-center rounded-full bg-sky-300 px-5 py-3 text-sm font-semibold text-slate-950 transition hover:bg-sky-200 disabled:cursor-not-allowed disabled:opacity-70"
|
||||
>
|
||||
{isSubmitting ? 'Saving...' : 'Create task'}
|
||||
</button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
import type { Task, TaskStatus } from '../types'
|
||||
|
||||
const STATUS_LABELS: Record<TaskStatus, string> = {
|
||||
OPEN: 'Open',
|
||||
IN_PROGRESS: 'In progress',
|
||||
DONE: 'Done',
|
||||
}
|
||||
|
||||
const STATUS_STYLES: Record<TaskStatus, string> = {
|
||||
OPEN: 'bg-white/70 text-slate-700 ring-slate-200',
|
||||
IN_PROGRESS: 'bg-amber-100 text-amber-900 ring-amber-200',
|
||||
DONE: 'bg-emerald-100 text-emerald-900 ring-emerald-200',
|
||||
}
|
||||
|
||||
interface TaskItemProps {
|
||||
task: Task
|
||||
isUpdating: boolean
|
||||
onStatusChange: (taskId: string, status: TaskStatus) => void
|
||||
}
|
||||
|
||||
export function TaskItem({ task, isUpdating, onStatusChange }: TaskItemProps) {
|
||||
return (
|
||||
<article className="rounded-[2rem] border border-white/60 bg-white/75 p-5 shadow-[0_20px_60px_rgba(15,23,42,0.08)] backdrop-blur">
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="space-y-2">
|
||||
<span
|
||||
className={`inline-flex rounded-full px-3 py-1 text-xs font-semibold uppercase tracking-[0.2em] ring-1 ${STATUS_STYLES[task.status]}`}
|
||||
>
|
||||
{STATUS_LABELS[task.status]}
|
||||
</span>
|
||||
<h3 className="text-xl font-semibold text-slate-900">{task.name}</h3>
|
||||
</div>
|
||||
<label className="min-w-32 text-sm font-medium text-slate-600">
|
||||
<span className="mb-2 block">Status</span>
|
||||
<select
|
||||
className="w-full rounded-2xl border border-slate-200 bg-white px-3 py-2 text-slate-900 outline-none transition focus:border-slate-400"
|
||||
value={task.status}
|
||||
onChange={(event) => onStatusChange(task.id, event.target.value as TaskStatus)}
|
||||
disabled={isUpdating}
|
||||
>
|
||||
<option value="OPEN">Open</option>
|
||||
<option value="IN_PROGRESS">In progress</option>
|
||||
<option value="DONE">Done</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<p className="mt-4 min-h-12 text-sm leading-6 text-slate-600">
|
||||
{task.description || 'No description provided.'}
|
||||
</p>
|
||||
|
||||
<p className="mt-4 text-xs uppercase tracking-[0.2em] text-slate-400">
|
||||
Created {new Date(task.createdAt).toLocaleString()}
|
||||
</p>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
|
|
@ -1,9 +1,31 @@
|
|||
@import "tailwindcss";
|
||||
@import 'tailwindcss';
|
||||
|
||||
@theme {
|
||||
--font-sans: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
|
||||
--font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
||||
|
||||
--color-app-bg: #f5f1e8;
|
||||
--color-app-bg-strong: #ebe4d7;
|
||||
--color-surface: #fffdf8;
|
||||
--color-surface-muted: #f6efe2;
|
||||
--color-border-soft: #e7dcc9;
|
||||
--color-border-strong: #cdbba0;
|
||||
--color-text-main: #1f2937;
|
||||
--color-text-muted: #6b7280;
|
||||
--color-brand: #0f766e;
|
||||
--color-brand-strong: #115e59;
|
||||
--color-brand-soft: #ccfbf1;
|
||||
--color-accent: #d97706;
|
||||
--color-accent-soft: #ffedd5;
|
||||
|
||||
--shadow-panel:
|
||||
0 22px 60px rgba(79, 62, 35, 0.08), 0 6px 18px rgba(79, 62, 35, 0.06);
|
||||
}
|
||||
|
||||
:root {
|
||||
font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
|
||||
color: #0f172a;
|
||||
background: #e2e8f0;
|
||||
color: var(--color-text-main);
|
||||
background-color: var(--color-app-bg);
|
||||
font-family: var(--font-sans);
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
|
@ -17,10 +39,13 @@
|
|||
html,
|
||||
body,
|
||||
#root {
|
||||
margin: 0;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
min-height: 100vh;
|
||||
margin: 0;
|
||||
background:
|
||||
radial-gradient(circle at top left, rgba(217, 119, 6, 0.12), transparent 28%),
|
||||
radial-gradient(circle at top right, rgba(15, 118, 110, 0.14), transparent 24%),
|
||||
linear-gradient(180deg, var(--color-app-bg) 0%, #f8f5ef 100%);
|
||||
}
|
||||
|
|
|
|||
31
frontend/src/lib/api.ts
Normal file
31
frontend/src/lib/api.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
const API_BASE_URL = (import.meta.env.VITE_API_URL as string | undefined) ?? '/api'
|
||||
|
||||
function buildUrl(path: string) {
|
||||
return `${API_BASE_URL}${path}`
|
||||
}
|
||||
|
||||
type RequestOptions = Omit<RequestInit, 'body'> & {
|
||||
body?: BodyInit | Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export async function apiFetch<T>(path: string, options: RequestOptions = {}) {
|
||||
const { body, headers, ...rest } = options
|
||||
|
||||
const response = await fetch(buildUrl(path), {
|
||||
...rest,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...headers,
|
||||
},
|
||||
body: body && typeof body === 'object' && !(body instanceof FormData)
|
||||
? JSON.stringify(body)
|
||||
: body,
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const message = await response.text()
|
||||
throw new Error(message || 'Nao foi possivel concluir a requisicao.')
|
||||
}
|
||||
|
||||
return (await response.json()) as T
|
||||
}
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
|
||||
import App from './App'
|
||||
import './index.css'
|
||||
import App from './App.tsx'
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
|
|
|
|||
172
frontend/src/pages/CreateTaskPage.tsx
Normal file
172
frontend/src/pages/CreateTaskPage.tsx
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
import { useState } from "react";
|
||||
import type { ChangeEvent, FormEvent } from "react";
|
||||
|
||||
import { apiFetch } from "../lib/api";
|
||||
import { TASK_STATUS_OPTIONS } from "../types/task";
|
||||
import type {
|
||||
CreateTaskPayload,
|
||||
TaskResponse,
|
||||
TaskStatus,
|
||||
} from "../types/task";
|
||||
|
||||
type FormState = CreateTaskPayload;
|
||||
|
||||
const initialFormState: FormState = {
|
||||
title: "",
|
||||
description: "",
|
||||
status: "NOT_STARTED",
|
||||
project: "",
|
||||
};
|
||||
|
||||
const statusLabels: Record<TaskStatus, string> = {
|
||||
NOT_STARTED: "Nao iniciada",
|
||||
IN_PROGRESS: "Em andamento",
|
||||
COMPLETED: "Concluida",
|
||||
CANCELED: "Cancelada",
|
||||
};
|
||||
|
||||
export function CreateTaskPage() {
|
||||
const [form, setForm] = useState<FormState>(initialFormState);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
const [createdTask, setCreatedTask] = useState<TaskResponse | null>(null);
|
||||
|
||||
function updateField(
|
||||
event: ChangeEvent<
|
||||
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
|
||||
>,
|
||||
) {
|
||||
const { name, value } = event.target;
|
||||
setForm((current) => ({
|
||||
...current,
|
||||
[name]: value,
|
||||
}));
|
||||
}
|
||||
|
||||
async function handleSubmit(event: FormEvent<HTMLFormElement>) {
|
||||
event.preventDefault();
|
||||
setErrorMessage(null);
|
||||
setIsSubmitting(true);
|
||||
|
||||
try {
|
||||
const payload: CreateTaskPayload = {
|
||||
title: form.title.trim(),
|
||||
description: form.description.trim(),
|
||||
status: form.status,
|
||||
project: form.project.trim(),
|
||||
};
|
||||
|
||||
const response = await apiFetch<TaskResponse>("/tasks", {
|
||||
method: "POST",
|
||||
body: payload,
|
||||
});
|
||||
|
||||
setCreatedTask(response);
|
||||
setForm(initialFormState);
|
||||
} catch (error) {
|
||||
setErrorMessage(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "Nao foi possivel criar a task.",
|
||||
);
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="px-6 py-10 text-text-main">
|
||||
<section className="rounded-[2rem] border border-border-soft bg-surface p-8 shadow-[var(--shadow-panel)]">
|
||||
<div className="max-w-2xl">
|
||||
<div className="inline-flex items-center gap-3 rounded-full border border-border-soft bg-surface-muted px-4 py-2 text-sm font-semibold text-brand-strong">
|
||||
<span className="h-2.5 w-2.5 rounded-full bg-brand" />
|
||||
Criar task
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form className="mt-10 space-y-6" onSubmit={handleSubmit}>
|
||||
<div className="grid gap-6 md:grid-cols-2">
|
||||
<label className="block">
|
||||
<span className="mb-2 block text-sm font-semibold text-text-main">
|
||||
Titulo
|
||||
</span>
|
||||
<input
|
||||
required
|
||||
name="title"
|
||||
value={form.title}
|
||||
onChange={updateField}
|
||||
placeholder="Ex.: Preparar retrospectiva da sprint"
|
||||
className="h-13 w-full rounded-2xl border border-border-soft bg-white px-4 text-base outline-none transition focus:border-brand focus:ring-4 focus:ring-brand/10"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="block">
|
||||
<span className="mb-2 block text-sm font-semibold text-text-main">
|
||||
Projeto
|
||||
</span>
|
||||
<input
|
||||
name="project"
|
||||
value={form.project}
|
||||
onChange={updateField}
|
||||
placeholder="Ex.: Bee Task Web"
|
||||
className="h-13 w-full rounded-2xl border border-border-soft bg-white px-4 text-base outline-none transition focus:border-brand focus:ring-4 focus:ring-brand/10"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label className="block">
|
||||
<span className="mb-2 block text-sm font-semibold text-text-main">
|
||||
Descricao
|
||||
</span>
|
||||
<textarea
|
||||
name="description"
|
||||
value={form.description}
|
||||
onChange={updateField}
|
||||
rows={6}
|
||||
placeholder="Adicione contexto, criterio de pronto ou observacoes importantes."
|
||||
className="w-full rounded-3xl border border-border-soft bg-white px-4 py-4 text-base outline-none transition focus:border-brand focus:ring-4 focus:ring-brand/10"
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label className="block max-w-xs">
|
||||
<span className="mb-2 block text-sm font-semibold text-text-main">
|
||||
Status inicial
|
||||
</span>
|
||||
<select
|
||||
name="status"
|
||||
value={form.status}
|
||||
onChange={updateField}
|
||||
className="h-13 w-full rounded-2xl border border-border-soft bg-white px-4 text-base outline-none transition focus:border-brand focus:ring-4 focus:ring-brand/10"
|
||||
>
|
||||
{TASK_STATUS_OPTIONS.map((status) => (
|
||||
<option key={status} value={status}>
|
||||
{statusLabels[status]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
|
||||
{errorMessage ? (
|
||||
<div className="rounded-2xl border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900">
|
||||
{errorMessage}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="flex flex-wrap items-center gap-4">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isSubmitting}
|
||||
className="inline-flex min-w-44 items-center justify-center rounded-2xl bg-brand px-6 py-3 text-sm font-semibold text-white transition hover:bg-brand-strong disabled:cursor-not-allowed disabled:opacity-70"
|
||||
>
|
||||
{isSubmitting ? "Criando task..." : "Criar task"}
|
||||
</button>
|
||||
|
||||
<p className="text-sm text-text-muted">
|
||||
O backend define os ids e devolve a task criada.
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
10
frontend/src/router.tsx
Normal file
10
frontend/src/router.tsx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { createBrowserRouter } from 'react-router-dom'
|
||||
|
||||
import { CreateTaskPage } from './pages/CreateTaskPage'
|
||||
|
||||
export const router = createBrowserRouter([
|
||||
{
|
||||
path: '/',
|
||||
element: <CreateTaskPage />,
|
||||
},
|
||||
])
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
export type TaskStatus = 'OPEN' | 'IN_PROGRESS' | 'DONE'
|
||||
|
||||
export interface Task {
|
||||
id: string
|
||||
name: string
|
||||
description: string | null
|
||||
status: TaskStatus
|
||||
createdAt: string
|
||||
}
|
||||
23
frontend/src/types/task.ts
Normal file
23
frontend/src/types/task.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
export const TASK_STATUS_OPTIONS = [
|
||||
'NOT_STARTED',
|
||||
'IN_PROGRESS',
|
||||
'COMPLETED',
|
||||
'CANCELED',
|
||||
] as const
|
||||
|
||||
export type TaskStatus = (typeof TASK_STATUS_OPTIONS)[number]
|
||||
|
||||
export type CreateTaskPayload = {
|
||||
title: string
|
||||
description: string
|
||||
status: TaskStatus
|
||||
project: string
|
||||
}
|
||||
|
||||
export type TaskResponse = {
|
||||
id: number
|
||||
title: string
|
||||
description: string
|
||||
status: TaskStatus
|
||||
project: string
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"types": ["vite/client"],
|
||||
"skipLibCheck": true,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
import tailwindcss from '@tailwindcss/vite'
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(), tailwindcss()],
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
target: process.env.VITE_API_PROXY_TARGET ?? 'http://localhost:8080',
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue