Merge pull request #14 from whtvrboo/fix/expense-api-pathing

Fix: Correct API endpoint pathing for expenses to resolve 404 errors
This commit is contained in:
whtvrboo 2025-06-03 12:05:08 +02:00 committed by GitHub
commit dbfbe7922e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 17 deletions

View File

@ -19,7 +19,7 @@ api_router_v1.include_router(lists.router, prefix="/lists", tags=["Lists"])
api_router_v1.include_router(items.router, tags=["Items"]) api_router_v1.include_router(items.router, tags=["Items"])
api_router_v1.include_router(ocr.router, prefix="/ocr", tags=["OCR"]) api_router_v1.include_router(ocr.router, prefix="/ocr", tags=["OCR"])
api_router_v1.include_router(costs.router, prefix="/costs", tags=["Costs"]) api_router_v1.include_router(costs.router, prefix="/costs", tags=["Costs"])
api_router_v1.include_router(financials.router) api_router_v1.include_router(financials.router, prefix="/financials", tags=["Financials"])
api_router_v1.include_router(chores.router, prefix="/chores", tags=["Chores"]) api_router_v1.include_router(chores.router, prefix="/chores", tags=["Chores"])
# Add other v1 endpoint routers here later # Add other v1 endpoint routers here later
# e.g., api_router_v1.include_router(users.router, prefix="/users", tags=["Users"]) # e.g., api_router_v1.include_router(users.router, prefix="/users", tags=["Users"])

View File

@ -97,16 +97,16 @@ export const API_ENDPOINTS = {
// Financials // Financials
FINANCIALS: { FINANCIALS: {
EXPENSES: '/financials/expenses', EXPENSES: '/api/v1/financials/expenses',
EXPENSE: (id: string) => `/financials/expenses/${id}`, EXPENSE: (id: string) => `/api/v1/financials/expenses/${id}`,
SETTLEMENTS: '/financials/settlements', SETTLEMENTS: '/api/v1/financials/settlements',
SETTLEMENT: (id: string) => `/financials/settlements/${id}`, SETTLEMENT: (id: string) => `/api/v1/financials/settlements/${id}`,
BALANCES: '/financials/balances', BALANCES: '/api/v1/financials/balances',
BALANCE: (userId: string) => `/financials/balances/${userId}`, BALANCE: (userId: string) => `/api/v1/financials/balances/${userId}`,
REPORTS: '/financials/reports', REPORTS: '/api/v1/financials/reports',
REPORT: (id: string) => `/financials/reports/${id}`, REPORT: (id: string) => `/api/v1/financials/reports/${id}`,
CATEGORIES: '/financials/categories', CATEGORIES: '/api/v1/financials/categories',
CATEGORY: (id: string) => `/financials/categories/${id}`, CATEGORY: (id: string) => `/api/v1/financials/categories/${id}`,
}, },
// Health // Health

View File

@ -1,5 +1,5 @@
import type { Expense, RecurrencePattern } from '@/types/expense' import type { Expense, RecurrencePattern } from '@/types/expense'
import { api } from '@/services/api' import { api, API_ENDPOINTS } from '@/services/api'
export interface CreateExpenseData { export interface CreateExpenseData {
description: string description: string
@ -32,21 +32,21 @@ export interface UpdateExpenseData extends Partial<CreateExpenseData> {
export const expenseService = { export const expenseService = {
async createExpense(data: CreateExpenseData): Promise<Expense> { async createExpense(data: CreateExpenseData): Promise<Expense> {
const response = await api.post<Expense>('/expenses', data) const response = await api.post<Expense>(API_ENDPOINTS.FINANCIALS.EXPENSES, data)
return response.data return response.data
}, },
async updateExpense(id: number, data: UpdateExpenseData): Promise<Expense> { async updateExpense(id: number, data: UpdateExpenseData): Promise<Expense> {
const response = await api.put<Expense>(`/expenses/${id}`, data) const response = await api.put<Expense>(API_ENDPOINTS.FINANCIALS.EXPENSE(id.toString()), data)
return response.data return response.data
}, },
async deleteExpense(id: number): Promise<void> { async deleteExpense(id: number): Promise<void> {
await api.delete(`/expenses/${id}`) await api.delete(API_ENDPOINTS.FINANCIALS.EXPENSE(id.toString()))
}, },
async getExpense(id: number): Promise<Expense> { async getExpense(id: number): Promise<Expense> {
const response = await api.get<Expense>(`/expenses/${id}`) const response = await api.get<Expense>(API_ENDPOINTS.FINANCIALS.EXPENSE(id.toString()))
return response.data return response.data
}, },
@ -55,7 +55,7 @@ export const expenseService = {
group_id?: number group_id?: number
isRecurring?: boolean isRecurring?: boolean
}): Promise<Expense[]> { }): Promise<Expense[]> {
const response = await api.get<Expense[]>('/expenses', { params }) const response = await api.get<Expense[]>(API_ENDPOINTS.FINANCIALS.EXPENSES, { params })
return response.data return response.data
}, },