fix: Selected agent profile picture in agent multi select (#2949)
This commit is contained in:
parent
b74261205d
commit
571fefd7cd
3 changed files with 28 additions and 13 deletions
|
@ -1,20 +1,34 @@
|
|||
class Api::V1::Accounts::Conversations::AssignmentsController < Api::V1::Accounts::Conversations::BaseController
|
||||
# assigns agent/team to a conversation
|
||||
def create
|
||||
set_assignee
|
||||
render json: @assignee
|
||||
if params.key?(:assignee_id)
|
||||
set_agent
|
||||
elsif params.key?(:team_id)
|
||||
set_team
|
||||
else
|
||||
render json: nil
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_assignee
|
||||
# if params[:assignee_id] is not a valid id, it will set to nil, hence unassigning the conversation
|
||||
if params.key?(:assignee_id)
|
||||
@assignee = Current.account.users.find_by(id: params[:assignee_id])
|
||||
@conversation.update_assignee(@assignee)
|
||||
elsif params.key?(:team_id)
|
||||
@assignee = Current.account.teams.find_by(id: params[:team_id])
|
||||
@conversation.update!(team: @assignee)
|
||||
def set_agent
|
||||
@agent = Current.account.users.find_by(id: params[:assignee_id])
|
||||
@conversation.update_assignee(@agent)
|
||||
render_agent
|
||||
end
|
||||
|
||||
def render_agent
|
||||
if @agent.nil?
|
||||
render json: nil
|
||||
else
|
||||
render partial: 'api/v1/models/agent', formats: [:json], locals: { resource: @agent }
|
||||
end
|
||||
end
|
||||
|
||||
def set_team
|
||||
@team = Current.account.teams.find_by(id: params[:team_id])
|
||||
@conversation.update!(team: @team)
|
||||
render json: @team
|
||||
end
|
||||
end
|
||||
|
|
|
@ -365,7 +365,7 @@ export default {
|
|||
id,
|
||||
name,
|
||||
role,
|
||||
thumbnail,
|
||||
avatar_url,
|
||||
} = this.currentUser;
|
||||
const selfAssign = {
|
||||
account_id,
|
||||
|
@ -375,7 +375,7 @@ export default {
|
|||
id,
|
||||
name,
|
||||
role,
|
||||
thumbnail,
|
||||
thumbnail: avatar_url,
|
||||
};
|
||||
this.assignedAgent = selfAssign;
|
||||
},
|
||||
|
|
|
@ -156,7 +156,8 @@ class User < ApplicationRecord
|
|||
available_name: available_name,
|
||||
avatar_url: avatar_url,
|
||||
type: 'user',
|
||||
availability_status: availability_status
|
||||
availability_status: availability_status,
|
||||
thumbnail: avatar_url
|
||||
}
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue