fix: Selected agent profile picture in agent multi select (#2949)

This commit is contained in:
Brandon Wilson 2021-09-13 04:13:19 -04:00 committed by GitHub
parent b74261205d
commit 571fefd7cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 13 deletions

View file

@ -1,20 +1,34 @@
class Api::V1::Accounts::Conversations::AssignmentsController < Api::V1::Accounts::Conversations::BaseController class Api::V1::Accounts::Conversations::AssignmentsController < Api::V1::Accounts::Conversations::BaseController
# assigns agent/team to a conversation # assigns agent/team to a conversation
def create def create
set_assignee if params.key?(:assignee_id)
render json: @assignee set_agent
elsif params.key?(:team_id)
set_team
else
render json: nil
end
end end
private private
def set_assignee def set_agent
# if params[:assignee_id] is not a valid id, it will set to nil, hence unassigning the conversation @agent = Current.account.users.find_by(id: params[:assignee_id])
if params.key?(:assignee_id) @conversation.update_assignee(@agent)
@assignee = Current.account.users.find_by(id: params[:assignee_id]) render_agent
@conversation.update_assignee(@assignee) end
elsif params.key?(:team_id)
@assignee = Current.account.teams.find_by(id: params[:team_id]) def render_agent
@conversation.update!(team: @assignee) if @agent.nil?
render json: nil
else
render partial: 'api/v1/models/agent', formats: [:json], locals: { resource: @agent }
end end
end end
def set_team
@team = Current.account.teams.find_by(id: params[:team_id])
@conversation.update!(team: @team)
render json: @team
end
end end

View file

@ -365,7 +365,7 @@ export default {
id, id,
name, name,
role, role,
thumbnail, avatar_url,
} = this.currentUser; } = this.currentUser;
const selfAssign = { const selfAssign = {
account_id, account_id,
@ -375,7 +375,7 @@ export default {
id, id,
name, name,
role, role,
thumbnail, thumbnail: avatar_url,
}; };
this.assignedAgent = selfAssign; this.assignedAgent = selfAssign;
}, },

View file

@ -156,7 +156,8 @@ class User < ApplicationRecord
available_name: available_name, available_name: available_name,
avatar_url: avatar_url, avatar_url: avatar_url,
type: 'user', type: 'user',
availability_status: availability_status availability_status: availability_status,
thumbnail: avatar_url
} }
end end