feat(frontend-notification): implement management features and enhance UX#278
feat(frontend-notification): implement management features and enhance UX#278siervo-jallaine merged 17 commits intodevelopfrom
Conversation
|
|
||
| return ResponseEntity.ok(paginatedResponse); | ||
| } | ||
| private final CopyOnWriteArrayList<SseEmitter> emitters = new CopyOnWriteArrayList<>(); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 89). Please break this line.
| User authenticatedUser = (User) authentication.getPrincipal(); | ||
| int userId = authenticatedUser.getUserId(); | ||
|
|
||
| Map<String, Object> paginatedResponse = service.listByUserId(userId, page, size, status); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 93). Please break this line.
| List<Notification> findByUserId(@Param("userId") int userId, | ||
| Pageable pageable); | ||
|
|
||
| @Query("SELECT n FROM Notification n WHERE n.user_id = :userId AND n.status = :status " + |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 91). Please break this line.
| @Query("SELECT COUNT(n) FROM Notification n WHERE n.user_id = :userId") | ||
| int countByUserId(@Param("userId") int userId); | ||
|
|
||
| @Query("SELECT COUNT(n) FROM Notification n WHERE n.user_id = :userId AND n.status = :status") |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 96). Please break this line.
| int countByUserId(@Param("userId") int userId); | ||
|
|
||
| @Query("SELECT COUNT(n) FROM Notification n WHERE n.user_id = :userId AND n.status = :status") | ||
| int countByUserIdAndStatus(@Param("userId") int userId, @Param("status") String status); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 90). Please break this line.
| @Query("SELECT COUNT(n) FROM Notification n WHERE n.user_id = :userId AND n.status = :status") | ||
| int countByUserIdAndStatus(@Param("userId") int userId, @Param("status") String status); | ||
|
|
||
| @Query("SELECT COUNT(n) FROM Notification n WHERE n.user_id = :userId AND n.status = 'unread'") |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 97). Please break this line.
|
|
||
| private final Map<Integer, SseConnection> userConnections = | ||
| new ConcurrentHashMap<>(); | ||
| private final Map<Integer, SseConnection> userConnections = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 88). Please break this line.
| }); | ||
| } | ||
|
|
||
| public Map<String, Object> listByUserId(int userId, int page, int size, String status) { |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 90). Please break this line.
| List<Notification> notifications; | ||
| int totalItems; | ||
|
|
||
| if (status != null && !status.isEmpty() && !status.equalsIgnoreCase("all")) { |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 81). Please break this line.
| return this.http.put(`${this.API_BASE_URL}/notifications/${id}/read`, {}); | ||
| } | ||
|
|
||
| markAllAsRead(): Observable<any> { |
There was a problem hiding this comment.
🤖 AI Review: The function markAllAsRead returns Observable<any>. This violates the 'Strict Typing: Never use the any or Object type' guideline. Please define a specific type for the HTTP response, e.g., Observable<MarkAllAsReadResponse>. This also ensures compliance with the 'Always create a model/type for HTTP responses' guideline.
markAllAsRead(): Observable<any> {…g notifications as read
|
|
||
| return ResponseEntity.ok(Map.of("success", true, "message", "Match status updated to " + status)); | ||
| } | ||
| return ResponseEntity.ok(Map.of("success", true, "message", "Match status updated to " + status)); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 102). Please break this line.
|
|
||
| return ResponseEntity.ok(paginatedResponse); | ||
| } | ||
| private final CopyOnWriteArrayList<SseEmitter> emitters = new CopyOnWriteArrayList<>(); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 89). Please break this line.
| User authenticatedUser = (User) authentication.getPrincipal(); | ||
| int userId = authenticatedUser.getUserId(); | ||
|
|
||
| Map<String, Object> paginatedResponse = service.listByUserId(userId, page, size, status); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 93). Please break this line.
| @Query("UPDATE Match m SET m.status = :status WHERE m.matchId = :id") | ||
| int updateMatchStatus(@Param("id") int id, @Param("status") String status); | ||
|
|
||
| @Query("SELECT m FROM Match m WHERE m.lostReportId = :reportId OR m.foundReportId = :reportId") |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 97). Please break this line.
| List<Notification> findByUserId(@Param("userId") int userId, | ||
| Pageable pageable); | ||
|
|
||
| @Query("SELECT n FROM Notification n WHERE n.user_id = :userId AND n.status = :status " + |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 91). Please break this line.
| } | ||
|
|
||
| @PutMapping("/notifications/read-all") | ||
| public ResponseEntity<?> markAllAsRead(Authentication authentication) { |
There was a problem hiding this comment.
🤖 AI Review: Strict Typing Violation: Avoid using wildcard type <?> in ResponseEntity. Always define a specific response type or a model for HTTP responses. For example, ResponseEntity<SuccessResponseDTO> or ResponseEntity<ErrorResponseDTO>.
public ResponseEntity<?> markAllAsRead(Authentication authentication) {| } | ||
|
|
||
| @Transactional | ||
| public Map<String, Object> create(int userId, int reportId, |
There was a problem hiding this comment.
🤖 AI Review: Strict Typing / Model Violation: Avoid using generic Map<String, Object> as a return type for service methods. Create a specific DTO (e.g., NotificationCreationResponseDTO) to represent the created notification data for better type safety and clarity.
public Map<String, Object> create(int userId, int reportId,| return data; | ||
| } | ||
|
|
||
| private void broadcastToAdmins(Map<String, Object> data) { |
There was a problem hiding this comment.
🤖 AI Review: Strict Typing / Model Violation: Avoid using generic Map<String, Object> for method parameters. Define a specific DTO (e.g., NotificationDataDTO) to ensure type safety and clarity.
private void broadcastToAdmins(Map<String, Object> data) {| }); | ||
| } | ||
|
|
||
| public void sendPrivateNotification(int userId, Map<String, Object> data) { |
There was a problem hiding this comment.
🤖 AI Review: Strict Typing / Model Violation: Avoid using generic Map<String, Object> for method parameters. Define a specific DTO (e.g., NotificationDataDTO) to ensure type safety and clarity.
public void sendPrivateNotification(int userId, Map<String, Object> data) {| }); | ||
| } | ||
|
|
||
| public Map<String, Object> listByUserId(int userId, int page, int size, String status) { |
There was a problem hiding this comment.
🤖 AI Review: Strict Typing / Model Violation: Avoid using generic Map<String, Object> as a return type for service methods. Create a specific DTO (e.g., PaginatedNotificationsResponseDTO) to represent the paginated notification data for better type safety and clarity.
public Map<String, Object> listByUserId(int userId, int page, int size, String status) {|
|
||
| return ResponseEntity.ok(Map.of("success", true, "message", "Match status updated to " + status)); | ||
| } | ||
| return ResponseEntity.ok(Map.of("success", true, "message", "Match status updated to " + status)); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 102). Please break this line.
|
|
||
| return ResponseEntity.ok(paginatedResponse); | ||
| } | ||
| private final CopyOnWriteArrayList<SseEmitter> emitters = new CopyOnWriteArrayList<>(); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 89). Please break this line.
| User authenticatedUser = (User) authentication.getPrincipal(); | ||
| int userId = authenticatedUser.getUserId(); | ||
|
|
||
| Map<String, Object> paginatedResponse = service.listByUserId(userId, page, size, status); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 93). Please break this line.
| @Query("UPDATE Match m SET m.status = :status WHERE m.matchId = :id") | ||
| int updateMatchStatus(@Param("id") int id, @Param("status") String status); | ||
|
|
||
| @Query("SELECT m FROM Match m WHERE m.lostReportId = :reportId OR m.foundReportId = :reportId") |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 97). Please break this line.
| List<Notification> findByUserId(@Param("userId") int userId, | ||
| Pageable pageable); | ||
|
|
||
| @Query("SELECT n FROM Notification n WHERE n.user_id = :userId AND n.status = :status " + |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 91). Please break this line.
| }); | ||
| } | ||
|
|
||
| public Map<String, Object> listByUserId(int userId, int page, int size, String status) { |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 90). Please break this line.
| List<Notification> notifications; | ||
| int totalItems; | ||
|
|
||
| if (status != null && !status.isEmpty() && !status.equalsIgnoreCase("all")) { |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 81). Please break this line.
| return this.http.put(`${this.apiUrl}/match/${matchId}`, { status }); | ||
| } | ||
|
|
||
| getMatchForReport(reportId: number): Observable<MatchResponseDTO | undefined> { |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 81). Please break this line.
| </div> | ||
|
|
||
| <div class="reminder-box"> | ||
| <p><strong>Note:</strong> You may be asked to provide additional proof of ownership.</p> |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 102). Please break this line.
| if (this.unreadCount() === 0) return; | ||
|
|
||
| const previousCount = this.unreadCount(); | ||
| const previousStatus = this.notifications.map(n => ({ id: n.notif_id, status: n.status })); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 95). Please break this line.
|
|
||
| return ResponseEntity.ok(Map.of("success", true, "message", "Match status updated to " + status)); | ||
| } | ||
| return ResponseEntity.ok(Map.of("success", true, "message", "Match status updated to " + status)); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 102). Please break this line.
| @Query("UPDATE Match m SET m.status = :status WHERE m.matchId = :id") | ||
| int updateMatchStatus(@Param("id") int id, @Param("status") String status); | ||
|
|
||
| @Query("SELECT m FROM Match m WHERE m.lostReportId = :reportId OR m.foundReportId = :reportId") |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 97). Please break this line.
| return userLostReports.stream() | ||
| .filter(lostReport -> | ||
| "approved".equalsIgnoreCase(lostReport.getStatus()) || | ||
| .filter(lostReport -> "approved".equalsIgnoreCase(lostReport.getStatus()) || |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 84). Please break this line.
| ); | ||
|
|
||
| String msgLost = String.format( | ||
| "Match Found: We found a potential match (%s) for your lost %s. Click to verify.", |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 90). Please break this line.
| lostReport.getUserId(), lostReport.getReportId(), msgLost, true); | ||
|
|
||
| String msgFound = String.format( | ||
| "Update: The %s you found has been matched to a lost report. Thank you for helping!", |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 93). Please break this line.
| return this.http.put(`${this.apiUrl}/match/${matchId}`, { status }); | ||
| } | ||
|
|
||
| getMatchForReport(reportId: number): Observable<MatchResponseDTO | undefined> { |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 81). Please break this line.
| </div> | ||
|
|
||
| <div class="reminder-box"> | ||
| <p><strong>Note:</strong> You may be asked to provide additional proof of ownership.</p> |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 102). Please break this line.
| if (this.unreadCount() === 0) return; | ||
|
|
||
| const previousCount = this.unreadCount(); | ||
| const previousStatus = this.notifications.map(n => ({ id: n.notif_id, status: n.status })); |
There was a problem hiding this comment.
📏 Style Violation: Line exceeds 80 characters
(Current: 95). Please break this line.
| ); | ||
| } | ||
|
|
||
| updateMatchStatus(matchId: number, status: string): Observable<any> { |
There was a problem hiding this comment.
🤖 AI Review: Strict Typing: The return type Observable<any> should be replaced with a more specific type to avoid using the any keyword. Define a clear type for the expected response, even if it's a simple { success: boolean; message: string; } or a custom type like UpdateMatchStatusResponse.
updateMatchStatus(matchId: number, status: string): Observable<any> {| height: 100%; | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; |
There was a problem hiding this comment.
🤖 AI Review: Styling: The align-items property value appears incomplete. It should likely be align-items: center;.
align-items: cent
No description provided.