Skip to content
This repository was archived by the owner on Jun 19, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ const App = () => (
</ProtectedRoute>
}
/>
<Route
path="goals"
element={
<ProtectedRoute>
<Goals />
</ProtectedRoute>
}
/>
<Route
path="bills"
element={
Expand Down
75 changes: 75 additions & 0 deletions app/src/api/goals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { api } from './client';

export type Goal = {
id: number;
title: string;
description: string | null;
target_amount: number;
current_amount: number;
currency: string;
deadline: string | null;
icon: string | null;
active: boolean;
created_at: string | null;
};

export type GoalCreate = {
title: string;
description?: string | null;
target_amount: number;
current_amount?: number;
currency?: string;
deadline?: string | null;
icon?: string | null;
};

export type GoalUpdate = Partial<GoalCreate> & {
active?: boolean;
};

export type GoalMilestone = {
id: number;
goal_id: number;
label: string;
target_amount: number;
reached: boolean;
reached_at: string | null;
created_at: string | null;
};

export type GoalMilestoneCreate = {
label: string;
target_amount: number;
};

export async function listGoals(): Promise<Goal[]> {
return api<Goal[]>('/goals');
}

export async function createGoal(payload: GoalCreate): Promise<{ id: number }> {
return api<{ id: number }>('/goals', { method: 'POST', body: payload });
}

export async function updateGoal(id: number, payload: GoalUpdate): Promise<{ message: string }> {
return api<{ message: string }>(`/goals/${id}`, { method: 'PATCH', body: payload });
}

export async function deleteGoal(id: number): Promise<{ message: string }> {
return api<{ message: string }>(`/goals/${id}`, { method: 'DELETE' });
}

export async function contributeToGoal(id: number, amount: number): Promise<{ current_amount: number }> {
return api<{ current_amount: number }>(`/goals/${id}/contribute`, { method: 'POST', body: { amount } });
}

export async function listMilestones(goalId: number): Promise<GoalMilestone[]> {
return api<GoalMilestone[]>(`/goals/${goalId}/milestones`);
}

export async function createMilestone(goalId: number, payload: GoalMilestoneCreate): Promise<{ id: number }> {
return api<{ id: number }>(`/goals/${goalId}/milestones`, { method: 'POST', body: payload });
}

export async function deleteMilestone(goalId: number, milestoneId: number): Promise<{ message: string }> {
return api<{ message: string }>(`/goals/${goalId}/milestones/${milestoneId}`, { method: 'DELETE' });
}
1 change: 1 addition & 0 deletions app/src/components/layout/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { logout as logoutApi } from '@/api/auth';
const navigation = [
{ name: 'Dashboard', href: '/dashboard' },
{ name: 'Budgets', href: '/budgets' },
{ name: 'Goals', href: '/goals' },
{ name: 'Bills', href: '/bills' },
{ name: 'Reminders', href: '/reminders' },
{ name: 'Expenses', href: '/expenses' },
Expand Down
Loading