diff --git a/app/controllers/api/v1/accounts/inboxes_controller.rb b/app/controllers/api/v1/accounts/inboxes_controller.rb index c7d3e2737..b7c28c1c3 100644 --- a/app/controllers/api/v1/accounts/inboxes_controller.rb +++ b/app/controllers/api/v1/accounts/inboxes_controller.rb @@ -9,7 +9,9 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController include Api::V1::Accounts::Concerns::WhatsappHealthManagement def index - @inboxes = policy_scope(Current.account.inboxes.order_by_name.includes(:channel, { avatar_attachment: [:blob] })) + @inboxes = policy_scope(Current.account.inboxes) + .includes(:channel, :portal, :working_hours, { avatar_attachment: :blob }) + .order_by_name end def show; end diff --git a/app/models/concerns/out_of_offisable.rb b/app/models/concerns/out_of_offisable.rb index f1753a5f8..9b9a59a19 100644 --- a/app/models/concerns/out_of_offisable.rb +++ b/app/models/concerns/out_of_offisable.rb @@ -19,7 +19,17 @@ module OutOfOffisable end def weekly_schedule - working_hours.order(day_of_week: :asc).select(*OFFISABLE_ATTRS).as_json(except: :id) + working_hours.sort_by(&:day_of_week).map do |wh| + { + 'day_of_week' => wh.day_of_week, + 'closed_all_day' => wh.closed_all_day, + 'open_hour' => wh.open_hour, + 'open_minutes' => wh.open_minutes, + 'close_hour' => wh.close_hour, + 'close_minutes' => wh.close_minutes, + 'open_all_day' => wh.open_all_day + } + end end # accepts an array of hashes similiar to the format of weekly_schedule