danielsanga/personalagent-integration
0
1const API_BASE = process.env.NEXT_PUBLIC_ORCHESTRATOR_URL || 'http://localhost:3001/api/v1';2 3export async function fetchApprovals() {4 const res = await fetch(`${API_BASE}/approvals`);5 if (!res.ok) throw new Error('Failed to fetch approvals');6 return res.json();7}8 9export async function resolveApproval(planId: string, stepId: string, approved: boolean, token: string) {10 const res = await fetch(`${API_BASE}/approvals/${planId}/${stepId}/resolve`, {11 method: 'POST',12 headers: { 'Content-Type': 'application/json' },13 body: JSON.stringify({ approved, token })14 });15 16 if (!res.ok) {17 const error = await res.json();18 throw new Error(error.error || 'Failed to resolve approval');19 }20 21 return res.json();22}23 24export async function submitGoal(goal: string) {25 const res = await fetch(`${API_BASE}/plan`, {26 method: 'POST',27 headers: { 'Content-Type': 'application/json' },28 body: JSON.stringify({ goal })29 });30 31 if (!res.ok) throw new Error('Failed to submit goal');32 return res.json();33}34 