From 86a2661329eaa8f5137681534ecec072a938011d Mon Sep 17 00:00:00 2001 From: CartSnitch Engineer Bot Date: Wed, 1 Apr 2026 02:10:12 +0000 Subject: [PATCH] fix(frontend): align API route paths with backend (alerts, price-history) Change frontend to call /alerts (was /price-alerts) and /products/{id}/prices (was /products/{id}/price-history) to match the backend router mounts. Co-Authored-By: Paperclip --- src/hooks/useApi.ts | 4 ++-- src/lib/api.ts | 4 ++-- src/test/mocks/handlers.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hooks/useApi.ts b/src/hooks/useApi.ts index 235b5f6..cccd77d 100644 --- a/src/hooks/useApi.ts +++ b/src/hooks/useApi.ts @@ -35,7 +35,7 @@ export function useProduct(id: string) { export function usePriceHistory(productId: string) { return useQuery({ queryKey: ['priceHistory', productId], - queryFn: () => api.get(`/products/${productId}/price-history`), + queryFn: () => api.get(`/products/${productId}/prices`), enabled: !!productId, }) } @@ -50,6 +50,6 @@ export function useCoupons() { export function usePriceAlerts() { return useQuery({ queryKey: ['priceAlerts'], - queryFn: () => api.get('/price-alerts'), + queryFn: () => api.get('/alerts'), }) } diff --git a/src/lib/api.ts b/src/lib/api.ts index 3907dde..1c2b0f8 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -15,7 +15,7 @@ const mockRoutes: Record unknown> = { '/purchases': () => mockPurchases, '/products': () => mockProducts, '/coupons': () => mockCoupons, - '/price-alerts': () => mockAlerts, + '/alerts': () => mockAlerts, } function matchMockRoute(path: string): T | null { @@ -30,7 +30,7 @@ function matchMockRoute(path: string): T | null { } // /products/:id/price-history - const priceHistoryMatch = path.match(/^\/products\/(.+)\/price-history$/) + const priceHistoryMatch = path.match(/^\/products\/(.+)\/prices$/) if (priceHistoryMatch) { return getMockPriceHistory(priceHistoryMatch[1]) as T } diff --git a/src/test/mocks/handlers.ts b/src/test/mocks/handlers.ts index ddfa9d5..4282004 100644 --- a/src/test/mocks/handlers.ts +++ b/src/test/mocks/handlers.ts @@ -61,5 +61,5 @@ export const handlers = [ http.get('/api/v1/products', () => HttpResponse.json(mockProducts)), http.get('/api/v1/products/prod_1', () => HttpResponse.json(mockProducts[0])), http.get('/api/v1/coupons', () => HttpResponse.json(mockCoupons)), - http.get('/api/v1/price-alerts', () => HttpResponse.json(mockAlerts)), + http.get('/api/v1/alerts', () => HttpResponse.json(mockAlerts)), ]