Fix Projects/Time pages: guard array state + merge conflict resolution
Build & Auto-Repair / build (push) Has been cancelled
Build & Auto-Repair / build (push) Has been cancelled
This commit is contained in:
@@ -50,7 +50,11 @@ if (!isRunning()) {
|
||||
spawn(bin, ["serve"], { stdio: "ignore", detached: true }).unref()
|
||||
}
|
||||
// Give it a moment to start listening
|
||||
if (platform() === "win32") {
|
||||
execSync("timeout /t 3 /nobreak >nul", { stdio: "ignore", timeout: 10000, shell: true })
|
||||
} else {
|
||||
execSync("sleep 3", { stdio: "ignore", timeout: 5000 })
|
||||
}
|
||||
} else {
|
||||
console.log("Ollama already running")
|
||||
}
|
||||
|
||||
@@ -62,10 +62,11 @@ export default function ProjectsPage() {
|
||||
if (search) params.set("search", search)
|
||||
if (statusFilter !== "all") params.set("status", statusFilter)
|
||||
const res = await fetch(`/api/projects?${params}`)
|
||||
const data = await res.json()
|
||||
const data = res.ok ? await res.json() : []
|
||||
setProjects(Array.isArray(data) ? data : [])
|
||||
} catch (e) {
|
||||
console.error("Failed to load projects", e)
|
||||
setProjects([])
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
@@ -167,8 +168,8 @@ function NewProjectDialog({ statuses, onCreated }: { statuses: ProjectStatus[];
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
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(() => {})
|
||||
fetch("/api/customers?limit=100").then(r => r.json()).then(d => setCustomers(Array.isArray(d) ? d : [])).catch(() => {})
|
||||
fetch("/api/users").then(r => r.json()).then(d => setUsers(d.users || [])).catch(() => {})
|
||||
}, [open])
|
||||
|
||||
const handleSubmit = async () => {
|
||||
|
||||
@@ -116,7 +116,7 @@ export default function NewProposalPage() {
|
||||
const formatCurrency = (n: number) => `R${n.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`
|
||||
|
||||
return (
|
||||
<div className="space-y-6 max-w-4xl">
|
||||
<div className="space-y-6 max-w-4xl mx-auto">
|
||||
<PageHeader title="New Proposal" description="Create a professional quote for your client">
|
||||
<Button variant="outline" size="sm" onClick={() => router.push("/proposals")}>
|
||||
<ArrowLeft className="mr-1.5 h-4 w-4" /> Back
|
||||
|
||||
@@ -52,14 +52,16 @@ export default function TimeTrackingPage() {
|
||||
fetch("/api/time-entries/summary"),
|
||||
fetch("/api/projects"),
|
||||
])
|
||||
const eData = await eRes.json()
|
||||
const sData = await sRes.json()
|
||||
const pData = await pRes.json()
|
||||
const eData = eRes.ok ? await eRes.json() : []
|
||||
const sData = sRes.ok ? await sRes.json() : null
|
||||
const pData = pRes.ok ? 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)
|
||||
setEntries([])
|
||||
setProjects([])
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user