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(ocr.router, prefix="/ocr", tags=["OCR"])
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"])
# Add other v1 endpoint routers here later
# 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: {
EXPENSES: '/financials/expenses',
EXPENSE: (id: string) => `/financials/expenses/${id}`,
SETTLEMENTS: '/financials/settlements',
SETTLEMENT: (id: string) => `/financials/settlements/${id}`,
BALANCES: '/financials/balances',
BALANCE: (userId: string) => `/financials/balances/${userId}`,
REPORTS: '/financials/reports',
REPORT: (id: string) => `/financials/reports/${id}`,
CATEGORIES: '/financials/categories',
CATEGORY: (id: string) => `/financials/categories/${id}`,
EXPENSES: '/api/v1/financials/expenses',
EXPENSE: (id: string) => `/api/v1/financials/expenses/${id}`,
SETTLEMENTS: '/api/v1/financials/settlements',
SETTLEMENT: (id: string) => `/api/v1/financials/settlements/${id}`,
BALANCES: '/api/v1/financials/balances',
BALANCE: (userId: string) => `/api/v1/financials/balances/${userId}`,
REPORTS: '/api/v1/financials/reports',
REPORT: (id: string) => `/api/v1/financials/reports/${id}`,
CATEGORIES: '/api/v1/financials/categories',
CATEGORY: (id: string) => `/api/v1/financials/categories/${id}`,
},
// Health

View File

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