From a2a81ca339149dd3cea9915f560c901cdd4a8122 Mon Sep 17 00:00:00 2001 From: NishaSharma14 Date: Thu, 21 Sep 2023 15:15:24 +0200 Subject: [PATCH] fix: update notification view --- .../Controllers/Admin/UsersController.php | 15 + .../ProjectInviteNotification.php | 2 +- app/Notifications/StudyInviteNotification.php | 2 +- .../TeamInvitationNotification.php | 2 +- resources/js/Layouts/AppLayout.vue | 87 +---- resources/js/Shared/Notification.vue | 323 ++++++++++++++---- routes/web.php | 3 + 7 files changed, 285 insertions(+), 149 deletions(-) diff --git a/app/Http/Controllers/Admin/UsersController.php b/app/Http/Controllers/Admin/UsersController.php index 45f5ce8e..a09e64c0 100644 --- a/app/Http/Controllers/Admin/UsersController.php +++ b/app/Http/Controllers/Admin/UsersController.php @@ -205,4 +205,19 @@ public function markNotificationAsRead(User $user, Request $request) return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', 'notification-markedAsRead'); } + + /** + * Mark all notification as read. + * + * @param User $user + * @return \Illuminate\Http\RedirectResponse + */ + public function markAllNotificationAsRead(Request $request) + { + $user = Auth::user(); + + $user->unreadNotifications()->update(['read_at' => now()]); + + return $request->wantsJson() ? new JsonResponse('', 200) : back()->with('status', 'all-notification-markedAsRead'); + } } diff --git a/app/Notifications/ProjectInviteNotification.php b/app/Notifications/ProjectInviteNotification.php index 6bcc168f..6c49b7df 100644 --- a/app/Notifications/ProjectInviteNotification.php +++ b/app/Notifications/ProjectInviteNotification.php @@ -42,7 +42,7 @@ public function via($notifiable) */ public function toArray($notifiable) { - $title = 'Invitation from project - '.$this->invitation->project->name; + $title = 'Invitation from project - '.$this->invitation->project->name.''; $message = 'You have been invited to join the project - '.$this->invitation->project->name.' (role: '.$this->invitation['role'].') by '.$this->invitation['invited_by'].'. Please check your mail to accept or decline the invitation.'; return [ diff --git a/app/Notifications/StudyInviteNotification.php b/app/Notifications/StudyInviteNotification.php index d0db437b..03b0deb9 100644 --- a/app/Notifications/StudyInviteNotification.php +++ b/app/Notifications/StudyInviteNotification.php @@ -41,7 +41,7 @@ public function via($notifiable) */ public function toArray($notifiable) { - $title = 'Invitation from study - '.$this->invitation->study->name; + $title = 'Invitation from study - '.$this->invitation->study->name.''; $message = 'You have been invited to join the study - '.$this->invitation->study->name.' (role: '.$this->invitation['role'].') by '.$this->invitation['invited_by'].'. Please check your mail to accept or decline the invitation.'; return [ diff --git a/app/Notifications/TeamInvitationNotification.php b/app/Notifications/TeamInvitationNotification.php index f6556ba2..b037d287 100644 --- a/app/Notifications/TeamInvitationNotification.php +++ b/app/Notifications/TeamInvitationNotification.php @@ -42,7 +42,7 @@ public function via($notifiable) */ public function toArray($notifiable) { - $title = 'Invitation from team - '.$this->invitation->team->name; + $title = 'Invitation recieved to join '.$this->invitation->team->name.' team'; $message = 'You have been invited to join the '.$this->invitation->team->name.' team (role: '.$this->invitation['role'].') by '.$this->invitation['invited_by'].'. Please check your mail to accept or decline the invitation.'; return [ diff --git a/resources/js/Layouts/AppLayout.vue b/resources/js/Layouts/AppLayout.vue index 28b6e37b..2eb4bbd0 100644 --- a/resources/js/Layouts/AppLayout.vue +++ b/resources/js/Layouts/AppLayout.vue @@ -294,78 +294,23 @@ :notification="$page.props.user.notifications" />
- -
- - - - - {{ countNotification() }} - - -
- +
+ + +
+ + {{ countNotification() }}
- -
-
- - + +
-
-
-
-
-
-

- {{ selectedNotificationForm.title }} -

-

- {{ selectedNotificationForm.message }} -

-
- -
-
-
- +
+ +
- Close -
-
+
+ + Close + + + Mark All As Read + +
+
+ +
- -
-
+ + +