diff --git a/app/assets/stylesheets/navigation/notifications.scss b/app/assets/stylesheets/navigation/notifications.scss index 5322db761..3646bd65d 100644 --- a/app/assets/stylesheets/navigation/notifications.scss +++ b/app/assets/stylesheets/navigation/notifications.scss @@ -94,7 +94,7 @@ border-radius: 50%; color: $color-white; display: flex; - grid-row: 1 / 4; + grid-row: 1 / 5; height: 2rem; justify-content: center; margin-right: .75rem; diff --git a/app/controllers/user_notifications_controller.rb b/app/controllers/user_notifications_controller.rb index eb2c7e976..819d7ebf7 100644 --- a/app/controllers/user_notifications_controller.rb +++ b/app/controllers/user_notifications_controller.rb @@ -2,13 +2,10 @@ class UserNotificationsController < ApplicationController def index - page = (params[:page] || 1).to_i - notifications = load_notifications.page(page).per(Constants::INFINITE_SCROLL_LIMIT).without_count + page = (params.dig(:page, :number) || 1).to_i + notifications = load_notifications.page(page).per(Constants::INFINITE_SCROLL_LIMIT) - render json: { - notifications: notification_serializer(notifications), - next_page: notifications.next_page - } + render json: notifications, each_serializer: NotificationSerializer notifications.mark_as_read! end @@ -26,17 +23,4 @@ class UserNotificationsController < ApplicationController .order(created_at: :desc) end - def notification_serializer(notifications) - notifications.map do |notification| - { - id: notification.id, - type_of: notification.type, - title: notification.to_notification.title, - message: notification.to_notification.message, - created_at: I18n.l(notification.created_at, format: :full), - today: notification.created_at.today?, - checked: notification.read_at.present? - } - end - end end diff --git a/app/javascript/vue/navigation/notifications/notification_item.vue b/app/javascript/vue/navigation/notifications/notification_item.vue index 8fae78c2d..dbf7a1471 100644 --- a/app/javascript/vue/navigation/notifications/notification_item.vue +++ b/app/javascript/vue/navigation/notifications/notification_item.vue @@ -1,15 +1,23 @@ - + - {{ notification.created_at }} + {{ notification.attributes.created_at }} - + v-html="notification.attributes.title" + :data-seen="notification.attributes.checked"> + + + + + + {{ breadcrumb.name }} + + + @@ -21,7 +29,7 @@ export default { }, computed: { icon() { - switch(this.notification.type_of) { + switch(this.notification.attributes.type_of) { case 'deliver': return 'fas fa-truck'; case 'assignment': diff --git a/app/javascript/vue/navigation/notifications/notifications_flyout.vue b/app/javascript/vue/navigation/notifications/notifications_flyout.vue index c5c1feb60..951a43543 100644 --- a/app/javascript/vue/navigation/notifications/notifications_flyout.vue +++ b/app/javascript/vue/navigation/notifications/notifications_flyout.vue @@ -24,6 +24,7 @@