From 513d9540270e79034456821b1706f92b0ce84dd1 Mon Sep 17 00:00:00 2001 From: raza-ak <116057378+raza-ak@users.noreply.github.com> Date: Wed, 4 Jun 2025 21:22:13 +0500 Subject: [PATCH] feat: Show active Contacts (#8243) --- .../api/v1/accounts/contacts_controller.rb | 4 +- app/javascript/dashboard/api/contacts.js | 5 ++ .../Contacts/ContactsCard/ContactsCard.vue | 9 ++- .../Contacts/ContactsHeader/ContactHeader.vue | 57 ++++++------------- .../ContactListHeaderWrapper.vue | 2 + .../Contacts/ContactsListLayout.vue | 24 +++++--- .../Contacts/Pages/ContactsList.vue | 1 + .../components-next/sidebar/Sidebar.vue | 6 ++ .../layout/config/sidebarItems/contacts.js | 8 +++ .../dashboard/i18n/locale/en/contact.json | 4 +- .../dashboard/i18n/locale/en/settings.json | 1 + .../contacts/pages/ContactsIndex.vue | 49 ++++++++++++++-- .../routes/dashboard/contacts/routes.js | 6 ++ .../store/modules/contacts/actions.js | 15 +++++ .../modules/specs/contacts/actions.spec.js | 24 ++++++++ 15 files changed, 159 insertions(+), 56 deletions(-) diff --git a/app/controllers/api/v1/accounts/contacts_controller.rb b/app/controllers/api/v1/accounts/contacts_controller.rb index b4d5e3fc1..4fbe50902 100644 --- a/app/controllers/api/v1/accounts/contacts_controller.rb +++ b/app/controllers/api/v1/accounts/contacts_controller.rb @@ -14,7 +14,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController before_action :check_authorization before_action :set_current_page, only: [:index, :active, :search, :filter] before_action :fetch_contact, only: [:show, :update, :destroy, :avatar, :contactable_inboxes, :destroy_custom_attributes] - before_action :set_include_contact_inboxes, only: [:index, :search, :filter, :show, :update] + before_action :set_include_contact_inboxes, only: [:index, :active, :search, :filter, :show, :update] def index @contacts_count = resolved_contacts.count @@ -56,7 +56,7 @@ class Api::V1::Accounts::ContactsController < Api::V1::Accounts::BaseController contacts = Current.account.contacts.where(id: ::OnlineStatusTracker .get_available_contact_ids(Current.account.id)) @contacts_count = contacts.count - @contacts = contacts.page(@current_page) + @contacts = fetch_contacts(contacts) end def show; end diff --git a/app/javascript/dashboard/api/contacts.js b/app/javascript/dashboard/api/contacts.js index 2eee3f484..025df2122 100644 --- a/app/javascript/dashboard/api/contacts.js +++ b/app/javascript/dashboard/api/contacts.js @@ -61,6 +61,11 @@ class ContactAPI extends ApiClient { return axios.get(requestURL); } + active(page = 1, sortAttr = 'name') { + let requestURL = `${this.url}/active?${buildContactParams(page, sortAttr)}`; + return axios.get(requestURL); + } + // eslint-disable-next-line default-param-last filter(page = 1, sortAttr = 'name', queryPayload) { let requestURL = `${this.url}/filter?${buildContactParams(page, sortAttr)}`; diff --git a/app/javascript/dashboard/components-next/Contacts/ContactsCard/ContactsCard.vue b/app/javascript/dashboard/components-next/Contacts/ContactsCard/ContactsCard.vue index b2b0dbfa0..0932a79c7 100644 --- a/app/javascript/dashboard/components-next/Contacts/ContactsCard/ContactsCard.vue +++ b/app/javascript/dashboard/components-next/Contacts/ContactsCard/ContactsCard.vue @@ -17,6 +17,7 @@ const props = defineProps({ additionalAttributes: { type: Object, default: () => ({}) }, phoneNumber: { type: String, default: '' }, thumbnail: { type: String, default: '' }, + availabilityStatus: { type: String, default: null }, isExpanded: { type: Boolean, default: false }, isUpdating: { type: Boolean, default: false }, }); @@ -92,7 +93,13 @@ const onClickViewDetails = () => emit('showContact', props.id);