Sha256: 7eb2962403910c8621a6829922ab34b7619c9c2d8e0feb6cac3856e523dbe68f

Contents?: true

Size: 1.35 KB

Versions: 10

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

require_dependency "renalware/dashboard"
require_dependency "collection_presenter"

module Renalware
  module Dashboard
    class DashboardPresenter
      def initialize(user)
        @user = user
      end

      attr_reader :user

      def bookmarks
        @bookmarks ||= begin
          Patients.cast_user(user)
                  .bookmarks
                  .ordered
                  .includes(patient: [current_modality: :description])
        end
      end

      def letters_in_progress
        @letters_in_progress ||= begin
          present_letters(
            Renalware::Letters.cast_author(user).letters.in_progress.reverse
          )
        end
      end

      def unread_messages_receipts
        @unread_messages_receipts ||= begin
          receipts = Messaging::Internal.cast_recipient(user).receipts.unread
          CollectionPresenter.new(receipts, Messaging::Internal::ReceiptPresenter)
        end
      end

      def unread_electronic_ccs
        @unread_electronic_ccs ||= begin
          receipts = Letters::ElectronicReceipt.unread.for_recipient(user.id).ordered
          CollectionPresenter.new(receipts, Letters::ElectronicReceiptPresenter)
        end
      end

      private

      def present_letters(letters)
        CollectionPresenter.new(letters, Letters::LetterPresenterFactory)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.0.9 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.8 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.7 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.5 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.4 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.3 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.2 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.1 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.0 app/presenters/renalware/dashboard/dashboard_presenter.rb
renalware-core-2.0.0.pre.rc13 app/presenters/renalware/dashboard/dashboard_presenter.rb