|
1 | 1 | import axios, { AxiosProgressEvent } from 'axios'; |
2 | | -import { MedicalReport, ReportCategory, ReportStatus, ProcessingStatus } from '../models/medicalReport'; |
| 2 | +import { MedicalReport } from '../models/medicalReport'; |
3 | 3 | import { fetchAuthSession } from '@aws-amplify/auth'; |
4 | 4 | // Get the API URL from environment variables |
5 | 5 | const API_URL = import.meta.env.VITE_BASE_URL_API || ''; |
6 | 6 |
|
7 | | -// Mock data for testing and development |
8 | | -const mockReports: MedicalReport[] = [ |
9 | | - { |
10 | | - id: '1', |
11 | | - userId: 'user1', |
12 | | - title: 'Blood Test Report', |
13 | | - category: ReportCategory.GENERAL, |
14 | | - bookmarked: false, |
15 | | - processingStatus: ProcessingStatus.PROCESSED, |
16 | | - labValues: [], |
17 | | - summary: 'Blood test results within normal range', |
18 | | - status: ReportStatus.UNREAD, |
19 | | - filePath: '/reports/blood-test.pdf', |
20 | | - createdAt: '2023-04-15T12:30:00Z', |
21 | | - updatedAt: '2023-04-15T12:30:00Z', |
22 | | - }, |
23 | | - { |
24 | | - id: '2', |
25 | | - userId: 'user1', |
26 | | - title: 'Heart Checkup', |
27 | | - category: ReportCategory.HEART, |
28 | | - bookmarked: true, |
29 | | - processingStatus: ProcessingStatus.PROCESSED, |
30 | | - labValues: [], |
31 | | - summary: 'Heart functioning normally', |
32 | | - status: ReportStatus.READ, |
33 | | - filePath: '/reports/heart-checkup.pdf', |
34 | | - createdAt: '2023-04-10T10:15:00Z', |
35 | | - updatedAt: '2023-04-10T10:15:00Z', |
36 | | - }, |
37 | | -]; |
38 | | - |
39 | 7 | /** |
40 | 8 | * Interface for upload progress callback |
41 | 9 | */ |
@@ -195,28 +163,15 @@ export const toggleReportBookmark = async ( |
195 | 163 | isBookmarked: boolean, |
196 | 164 | ): Promise<MedicalReport> => { |
197 | 165 | try { |
198 | | - await axios.patch( |
| 166 | + const response = await axios.patch( |
199 | 167 | `${API_URL}/api/reports/${reportId}/bookmark`, |
200 | 168 | { |
201 | 169 | bookmarked: isBookmarked, |
202 | 170 | }, |
203 | 171 | await getAuthConfig(), |
204 | 172 | ); |
205 | 173 |
|
206 | | - // In a real implementation, this would return the response from the API |
207 | | - // return response.data; |
208 | | - |
209 | | - // For now, we'll mock the response |
210 | | - const report = mockReports.find((r) => r.id === reportId); |
211 | | - |
212 | | - if (!report) { |
213 | | - throw new Error(`Report with ID ${reportId} not found`); |
214 | | - } |
215 | | - |
216 | | - // Update the bookmark status |
217 | | - report.bookmarked = isBookmarked; |
218 | | - |
219 | | - return { ...report }; |
| 174 | + return response.data; |
220 | 175 | } catch (error) { |
221 | 176 | if (axios.isAxiosError(error)) { |
222 | 177 | throw new ReportError(`Failed to toggle bookmark status: ${error.message}`); |
|
0 commit comments