From b32b3eaca1ce467ccf9659cf3aab9f96695b7d0f Mon Sep 17 00:00:00 2001 From: Samuel James Date: Sat, 5 Sep 2026 15:28:05 +0000 Subject: [PATCH] Clean up: Remove src files --- frontend/src/App.tsx | 202 ------------------------------------------- 1 file changed, 202 deletions(-) delete mode 100644 frontend/src/App.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx deleted file mode 100644 index 858a971..0000000 --- a/frontend/src/App.tsx +++ /dev/null @@ -1,202 +0,0 @@ -import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import AppShell from './components/common/AppShell'; -import TaskForm from './components/TaskForm/TaskForm'; -import TaskList, { FilterCounts } from './components/TaskList/TaskList'; -import { api } from './services/api'; -import { Task, TaskDraft, TaskFilter, TaskStatus, User } from './types'; -import './App.css'; - -interface Notice { - kind: 'info' | 'error'; - text: string; -} - -const errorText = (error: unknown, fallback: string): string => - error instanceof Error && error.message ? error.message : fallback; - -function App() { - const [tasks, setTasks] = useState([]); - const [users, setUsers] = useState([]); - const [currentUser, setCurrentUser] = useState(null); - const [filter, setFilter] = useState('all'); - const [loading, setLoading] = useState(true); - const [loadError, setLoadError] = useState(null); - const [formOpen, setFormOpen] = useState(false); - const [editingTask, setEditingTask] = useState(null); - const [pendingTaskId, setPendingTaskId] = useState(null); - const [notice, setNotice] = useState(null); - - /** Element that opened the dialog, so focus can go back where the user left it. */ - const formTriggerRef = useRef(null); - - const load = useCallback(async (): Promise => { - setLoading(true); - setLoadError(null); - try { - const [me, teamMembers, taskList] = await Promise.all([ - api.getCurrentUser(), - api.getUsers(), - api.getTasks(), - ]); - setCurrentUser(me); - setUsers(teamMembers); - setTasks(taskList); - } catch (error) { - setLoadError( - errorText(error, 'TaskFlow could not reach the server. Check your connection and retry.') - ); - } finally { - setLoading(false); - } - }, []); - - useEffect(() => { - load(); - }, [load]); - - const counts: FilterCounts = useMemo( - () => ({ - my: tasks.filter((task) => task.assigned_to?.id === currentUser?.id).length, - all: tasks.length, - blocked: tasks.filter((task) => task.status === 'blocked').length, - }), - [tasks, currentUser] - ); - - const visibleTasks = useMemo(() => { - if (filter === 'my') { - return tasks.filter((task) => task.assigned_to?.id === currentUser?.id); - } - if (filter === 'blocked') { - return tasks.filter((task) => task.status === 'blocked'); - } - return tasks; - }, [tasks, filter, currentUser]); - - const openForm = (task: Task | null): void => { - formTriggerRef.current = document.activeElement as HTMLElement | null; - setEditingTask(task); - setNotice(null); - setFormOpen(true); - }; - - const closeForm = (): void => { - setFormOpen(false); - setEditingTask(null); - formTriggerRef.current?.focus(); - }; - - /** Rejects on failure so TaskForm can keep the user's input on screen. */ - const saveTask = async (draft: TaskDraft): Promise => { - if (editingTask) { - const updated = await api.updateTask(editingTask.id, draft); - setTasks((current) => current.map((task) => (task.id === updated.id ? updated : task))); - setNotice({ kind: 'info', text: `"${updated.title}" was updated.` }); - } else { - const created = await api.createTask(draft); - setTasks((current) => [created, ...current]); - setNotice({ kind: 'info', text: `"${created.title}" was created.` }); - } - closeForm(); - }; - - const changeStatus = async (task: Task, status: TaskStatus): Promise => { - setPendingTaskId(task.id); - setNotice(null); - try { - const updated = await api.updateTask(task.id, { status }); - setTasks((current) => current.map((item) => (item.id === updated.id ? updated : item))); - setNotice({ kind: 'info', text: `"${updated.title}" is now ${status.replace('_', ' ')}.` }); - } catch (error) { - setNotice({ - kind: 'error', - text: errorText(error, `"${task.title}" could not be updated. It is unchanged, so try again.`), - }); - } finally { - setPendingTaskId(null); - } - }; - - const deleteTask = async (task: Task): Promise => { - // eslint-disable-next-line no-restricted-globals - const confirmed = window.confirm(`Delete "${task.title}"? This cannot be undone.`); - if (!confirmed) { - return; - } - - setPendingTaskId(task.id); - setNotice(null); - try { - await api.deleteTask(task.id); - setTasks((current) => current.filter((item) => item.id !== task.id)); - setNotice({ kind: 'info', text: `"${task.title}" was deleted.` }); - } catch (error) { - setNotice({ - kind: 'error', - text: errorText(error, `"${task.title}" could not be deleted. Nothing changed, so try again.`), - }); - } finally { - setPendingTaskId(null); - } - }; - - if (loading) { - return ( -
- - ); - } - - if (loadError || !currentUser) { - return ( -
-

We could not load your tasks

-

{loadError ?? 'Your account details are unavailable right now.'}

- -
- ); - } - - return ( - -
- {notice && ( -
- {notice.text} - -
- )} -
- - openForm(null)} - onEditTask={openForm} - onDeleteTask={deleteTask} - onStatusChange={changeStatus} - /> - - {formOpen && ( - - )} -
- ); -} - -export default App;