Skip to content

Commit 7b9ddb1

Browse files
authored
Merge pull request #112 from ModusCreateOrg/NO-TICKET-FIX-MARK-AS-READ-STATUS
Update reportService API endpoint for marking reports as read
2 parents 618d4d6 + f1d5ff2 commit 7b9ddb1

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

backend/src/reports/reports.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ export class ReportsService {
243243

244244
const command = new UpdateItemCommand({
245245
TableName: this.tableName,
246-
Key: marshall({ id }),
246+
Key: marshall({
247+
userId, // Partition key
248+
id, // Sort key
249+
}),
247250
UpdateExpression: 'SET #status = :status, updatedAt = :updatedAt',
248251
ConditionExpression: 'userId = :userId', // Ensure the report belongs to the user
249252
ExpressionAttributeNames: {

frontend/src/common/api/__tests__/reportService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ vi.mock('../reportService', async (importOriginal) => {
103103
// Mock markReportAsRead to avoid the dependency on getAuthConfig
104104
markReportAsRead: async (reportId: string) => {
105105
try {
106-
const response = await axios.patch(`/api/reports/${reportId}`, {
106+
const response = await axios.patch(`/api/reports/${reportId}/status`, {
107107
status: 'READ',
108108
});
109109
return response.data;

frontend/src/common/api/reportService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const fetchAllReports = async (): Promise<MedicalReport[]> => {
142142
export const markReportAsRead = async (reportId: string): Promise<MedicalReport> => {
143143
try {
144144
const response = await axios.patch(
145-
`${API_URL}/api/reports/${reportId}`,
145+
`${API_URL}/api/reports/${reportId}/status`,
146146
{
147147
status: 'READ',
148148
},

0 commit comments

Comments
 (0)