You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
class CreateLogActionsComponent < ViewComponent::Base |
|
include Rails.application.routes.url_helpers |
|
|
|
attr_reader :bulk_upload, :user, :log_type |
|
|
|
def initialize(user:, log_type:, bulk_upload: nil) |
|
@bulk_upload = bulk_upload |
|
@user = user |
|
@log_type = log_type |
|
|
|
super |
|
end |
|
|
|
def display_actions? |
|
return false if bulk_upload.present? |
|
return true if user.support? |
|
|
|
user.organisation.data_protection_confirmed? && user.organisation.organisation_or_stock_owner_signed_dsa_and_holds_own_stock? |
|
end |
|
|
|
def create_button_href |
|
case log_type |
|
when "lettings" |
|
lettings_logs_path |
|
when "sales" |
|
sales_logs_path |
|
end |
|
end |
|
|
|
def create_button_copy |
|
case log_type |
|
when "lettings" |
|
"Create a new lettings log" |
|
when "sales" |
|
"Create a new sales log" |
|
end |
|
end |
|
|
|
def upload_button_copy |
|
case log_type |
|
when "lettings" |
|
"Upload lettings logs in bulk" |
|
when "sales" |
|
"Upload sales logs in bulk" |
|
end |
|
end |
|
|
|
def upload_button_href |
|
case log_type |
|
when "lettings" |
|
bulk_upload_lettings_log_path(id: "start") |
|
when "sales" |
|
bulk_upload_sales_log_path(id: "start") |
|
end |
|
end |
|
end
|
|
|