5 changed files with 112 additions and 0 deletions
@ -0,0 +1,8 @@
|
||||
<% if display_banner? %> |
||||
<%= govuk_notification_banner(title_text: "Important") do %> |
||||
<p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content"> |
||||
<%= header_text %> |
||||
<p> |
||||
<%= banner_text %> |
||||
<% end %> |
||||
<% end %> |
||||
@ -0,0 +1,64 @@
|
||||
class MissingStockOwnersBannerComponent < ViewComponent::Base |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attr_reader :user, :organisation |
||||
|
||||
HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze |
||||
|
||||
def initialize(user:) |
||||
@user = user |
||||
@organisation = user.organisation |
||||
|
||||
super |
||||
end |
||||
|
||||
def display_banner? |
||||
return false if user.support? |
||||
return false if DataProtectionConfirmationBannerComponent.new(user:, organisation:).display_banner? |
||||
|
||||
!organisation.holds_own_stock? && organisation.stock_owners.empty? && organisation.absorbed_organisations.empty? |
||||
end |
||||
|
||||
def header_text |
||||
if user.data_coordinator? |
||||
"Your organisation does not own stock. You must #{add_stock_owner_link} before you can create logs.".html_safe |
||||
else |
||||
"Your organisation does not own stock. You must add a stock owner before you can create logs.".html_safe |
||||
end |
||||
end |
||||
|
||||
def banner_text |
||||
if user.data_coordinator? |
||||
"If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe |
||||
else |
||||
"If your organisation does own stock, #{contact_helpdesk_link} to update your details.</br> |
||||
Ask a data coordinator to add a stock owner. Find your data coordinators on the #{users_link}.".html_safe |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def add_stock_owner_link |
||||
govuk_link_to( |
||||
"add a stock owner", |
||||
stock_owners_add_organisation_path(id: organisation.id), |
||||
class: "govuk-notification-banner__link govuk-!-font-weight-bold", |
||||
) |
||||
end |
||||
|
||||
def contact_helpdesk_link |
||||
govuk_link_to( |
||||
"contact the helpdesk", |
||||
HELPDESK_URL, |
||||
class: "govuk-notification-banner__link govuk-!-font-weight-bold", |
||||
) |
||||
end |
||||
|
||||
def users_link |
||||
govuk_link_to( |
||||
"users page", |
||||
users_path, |
||||
class: "govuk-notification-banner__link govuk-!-font-weight-bold", |
||||
) |
||||
end |
||||
end |
||||
Loading…
Reference in new issue