Fixed Projects/Proposals/Time
This commit is contained in:
@@ -62,7 +62,8 @@ export default function ProjectsPage() {
|
||||
if (search) params.set("search", search)
|
||||
if (statusFilter !== "all") params.set("status", statusFilter)
|
||||
const res = await fetch(`/api/projects?${params}`)
|
||||
setProjects(await res.json())
|
||||
const data = await res.json()
|
||||
setProjects(Array.isArray(data) ? data : [])
|
||||
} catch (e) {
|
||||
console.error("Failed to load projects", e)
|
||||
} finally {
|
||||
@@ -73,7 +74,7 @@ export default function ProjectsPage() {
|
||||
useEffect(() => { fetchProjects() }, [search, statusFilter])
|
||||
|
||||
useEffect(() => {
|
||||
fetch("/api/project-statuses").then(r => r.json()).then(setStatuses).catch(() => {})
|
||||
fetch("/api/project-statuses").then(r => r.json()).then((d) => setStatuses(Array.isArray(d) ? d : [])).catch(() => {})
|
||||
}, [])
|
||||
|
||||
const formatDate = (d: string) => d ? new Date(d).toLocaleDateString() : "—"
|
||||
@@ -166,8 +167,8 @@ function NewProjectDialog({ statuses, onCreated }: { statuses: ProjectStatus[];
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
fetch("/api/customers?limit=100").then(r => r.json()).then(setCustomers).catch(() => {})
|
||||
fetch("/api/users").then(r => r.json()).then(setUsers).catch(() => {})
|
||||
fetch("/api/customers?limit=100").then(r => r.json()).then((d) => setCustomers(Array.isArray(d) ? d : (d.customers || d.rows || []))).catch(() => {})
|
||||
fetch("/api/users").then(r => r.json()).then((d) => setUsers(Array.isArray(d) ? d : (d.users || d.rows || []))).catch(() => {})
|
||||
}, [open])
|
||||
|
||||
const handleSubmit = async () => {
|
||||
|
||||
@@ -52,9 +52,12 @@ export default function TimeTrackingPage() {
|
||||
fetch("/api/time-entries/summary"),
|
||||
fetch("/api/projects"),
|
||||
])
|
||||
setEntries(await eRes.json())
|
||||
setSummary(await sRes.json())
|
||||
setProjects(await pRes.json())
|
||||
const eData = await eRes.json()
|
||||
const sData = await sRes.json()
|
||||
const pData = await pRes.json()
|
||||
setEntries(Array.isArray(eData) ? eData : [])
|
||||
setSummary(sData?.totals ? sData : null)
|
||||
setProjects(Array.isArray(pData) ? pData : [])
|
||||
} catch (e) {
|
||||
console.error("Failed to load time data", e)
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user