diff --git a/backend/src/reports/reports.service.ts b/backend/src/reports/reports.service.ts index 2c3c2b2..e5e8d99 100644 --- a/backend/src/reports/reports.service.ts +++ b/backend/src/reports/reports.service.ts @@ -243,7 +243,10 @@ export class ReportsService { const command = new UpdateItemCommand({ TableName: this.tableName, - Key: marshall({ id }), + Key: marshall({ + userId, // Partition key + id, // Sort key + }), UpdateExpression: 'SET #status = :status, updatedAt = :updatedAt', ConditionExpression: 'userId = :userId', // Ensure the report belongs to the user ExpressionAttributeNames: { diff --git a/frontend/src/common/api/__tests__/reportService.test.ts b/frontend/src/common/api/__tests__/reportService.test.ts index 7734aac..ffb020d 100644 --- a/frontend/src/common/api/__tests__/reportService.test.ts +++ b/frontend/src/common/api/__tests__/reportService.test.ts @@ -103,7 +103,7 @@ vi.mock('../reportService', async (importOriginal) => { // Mock markReportAsRead to avoid the dependency on getAuthConfig markReportAsRead: async (reportId: string) => { try { - const response = await axios.patch(`/api/reports/${reportId}`, { + const response = await axios.patch(`/api/reports/${reportId}/status`, { status: 'READ', }); return response.data; diff --git a/frontend/src/common/api/reportService.ts b/frontend/src/common/api/reportService.ts index 5b31a4e..840cf6e 100644 --- a/frontend/src/common/api/reportService.ts +++ b/frontend/src/common/api/reportService.ts @@ -142,7 +142,7 @@ export const fetchAllReports = async (): Promise => { export const markReportAsRead = async (reportId: string): Promise => { try { const response = await axios.patch( - `${API_URL}/api/reports/${reportId}`, + `${API_URL}/api/reports/${reportId}/status`, { status: 'READ', },