diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb
index 28dd6286..e99f1544 100644
--- a/app/views/dashboard/index.html.erb
+++ b/app/views/dashboard/index.html.erb
@@ -16,17 +16,49 @@
margin-top: 15px;
}
- .box {
- width: 350px;
- border: 1px solid black;
- padding: 5px;
- margin: 5px;
- margin-bottom: 15px;
+ .subtitle {
+ font-family: Roboto, sans-serif;
+ font-weight: bold;
+ font-size: 20px;
+ spacing: auto spacing;
+ color: #b8043c;
+ margin-bottom: 7px;
+ }
+
+ .button {
+ width: 100%;
+ border: none;
+ color: white;
+ padding: 10px 20px;
+ text-align: center;
+ text-decoration: none;
+ display: inline-block;
+ margin: 4px 2px;
+ cursor: pointer;
+ font-family: Roboto, sans-serif;
+ font-weight: bold;
+ font-size: 16px;
+ spacing: auto spacing;
+ margin-bottom: 18px;
+ <% if user_signed_in? && @user.notifications.where(unread: true).size > 0 %>
+ background-color: #2596be;
+ <% else %>
+ background-color: #7cc0d8;
+ <% end %>
+ }
+
+ .button:hover {
+ color: white;
}
+
-
<%= t('views.dashboard.greeting', name: @user.first_name)%>
-<%= t 'views.dashboard.unread_messages' %>
+<% if user_signed_in? %>
+ <%= t('views.dashboard.greeting', name: @user.first_name)%>
+
+ <%= t('views.dashboard.unread_messages', num: @user.notifications.where(unread: true).size) %>
+
+ <%= t 'views.dashboard.lent_items.title' %>
<%= t 'views.dashboard.lent_items.title' %>
<%= render "lent_items"%>
@@ -36,3 +68,4 @@
<%= t 'views.dashboard.wishlist.title' %>
<%= render "wishlist"%>
+<% end %>
\ No newline at end of file
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 2a3134d9..a6fde8aa 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -19,7 +19,8 @@ de:
title: "Übersicht"
no_lent_items: "Aktuell hast du keine ausgeliehenen Artikel."
greeting: "Hallo, %{name}!"
- unread_messages: "Du hast ... ungelesene Nachrichten"
+ not_signed_in: "Du bist nicht angemeldet."
+ unread_messages: "Du hast %{num} ungelesene Nachrichten"
lent_items:
title: "AUSGELIEHENE ARTIKEL"
expired: "abgelaufen am %{date}"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 5db6e0c3..440d4364 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -50,7 +50,8 @@ en:
title: "Dashboard"
no_lent_items: "Currently you have no lent items."
greeting: "Hello, %{name}!"
- unread_messages: "You have ... unread messages"
+ not_signed_in: "You are not signed in."
+ unread_messages: "You have %{num} unread messages"
lent_items:
title: "LENT ITEMS"
expired: "expired on %{date}"
diff --git a/db/schema.rb b/db/schema.rb
index f39cf66a..4945e4b2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -14,8 +14,8 @@
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
- t.bigint "record_id", null: false
- t.bigint "blob_id", null: false
+ t.integer "record_id", null: false
+ t.integer "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
@@ -34,7 +34,7 @@
end
create_table "active_storage_variant_records", force: :cascade do |t|
- t.bigint "blob_id", null: false
+ t.integer "blob_id", null: false
t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
diff --git a/spec/features/dashboard/dashboard_spec.rb b/spec/features/dashboard/dashboard_spec.rb
index 46cb6883..dbb2ed41 100644
--- a/spec/features/dashboard/dashboard_spec.rb
+++ b/spec/features/dashboard/dashboard_spec.rb
@@ -1,7 +1,11 @@
require "rails_helper"
RSpec.describe "Dashboard", type: :feature do
- let(:user) { build(:user) }
+
+ let(:password) { 'password' }
+ let(:user) { create(:user, password: password) }
+ let(:borrower) { create(:max, password: password) }
+ let(:item) { create(:item, owner: user.id) }
it "redirects to login without user signed in" do
visit dashboard_path
@@ -15,10 +19,15 @@
expect(page).to have_content(@user.first_name)
end
- it "shows unread messages" do
+ it "shows unread messages and links to notifications" do
sign_in user
visit dashboard_path
- expect(page).to have_content I18n.t('views.dashboard.unread_messages')
+ expect(page).to have_link(href: '/notifications')
+ expect(page).to have_content I18n.t('views.dashboard.unread_messages', num: 0)
+ @notifications = create_list(:lend_request_notification, 2, user: user, item: item, borrower: borrower)
+ @notifications.each(&:save)
+ page.refresh
+ expect(page).to have_content I18n.t('views.dashboard.unread_messages', num: 2)
end
it "shows lent items" do