Initial commit: personal task planner with categories, projects, and tiered assignment
Personal-first lists/tasks/reminders/recurrence, plus an admin-editable status pipeline, shared categories, project containers, and a three-tier permission model for cross-user work: assign (hand off your own tasks), reallocate (dispatcher — move anyone's tasks), admin (reserved, full manage-all).
This commit is contained in:
commit
d8dc4e2b81
54 changed files with 10908 additions and 0 deletions
32
frontend/src/context/ListsContext.tsx
Normal file
32
frontend/src/context/ListsContext.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { createContext, useContext, useEffect, useState, useCallback } from 'react'
|
||||
import type { List } from '../types'
|
||||
import { fetchLists } from '../api'
|
||||
|
||||
interface ListsCtx {
|
||||
lists: List[]
|
||||
loading: boolean
|
||||
reload: () => Promise<void>
|
||||
}
|
||||
|
||||
const Ctx = createContext<ListsCtx | null>(null)
|
||||
|
||||
export function useLists() {
|
||||
const ctx = useContext(Ctx)
|
||||
if (!ctx) throw new Error('useLists must be used inside ListsProvider')
|
||||
return ctx
|
||||
}
|
||||
|
||||
export function ListsProvider({ children }: { children: React.ReactNode }) {
|
||||
const [lists, setLists] = useState<List[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
const reload = useCallback(async () => {
|
||||
const data = await fetchLists().catch(() => [])
|
||||
setLists(data)
|
||||
setLoading(false)
|
||||
}, [])
|
||||
|
||||
useEffect(() => { reload() }, [reload])
|
||||
|
||||
return <Ctx.Provider value={{ lists, loading, reload }}>{children}</Ctx.Provider>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue