This commit is contained in:
mmrbnjd
2025-08-03 23:41:54 +03:30
parent 65eeb4694e
commit ba0c513830
4 changed files with 199 additions and 82 deletions

View File

@@ -104,12 +104,21 @@ namespace Hushian.Application.Services
}).ToList() }).ToList()
}).ToListAsync(); }).ToListAsync();
public async Task<List<ChatItemDto>> ChatsAwaitingOurResponse(int CompanyID) public async Task<List<ChatItemDto>> ChatsAwaitingOurResponse(int CompanyID, int? ExperID)
=> await _ConversationRepository.Get() {
int[]? groupallow = null;
if (ExperID.HasValue)
{
var groups = await _groupService.GetGroupsExper(ExperID.Value);
if (groups.Count > 0) groupallow = groups.Select(s => s.ID).ToArray();
}
var request = _ConversationRepository.Get()
.Include(inc => inc.Group) .Include(inc => inc.Group)
.Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper) .Include(inc => inc.ConversationResponses).ThenInclude(tinc => tinc.Exper)
.Where(w => w.Status == ConversationStatus.Recorded && w.CompanyID == CompanyID) .Where(w => w.Status == ConversationStatus.Recorded && w.CompanyID == CompanyID);
.Select(s => new ChatItemDto() if (groupallow != null) request = request.Where(w=>!w.GroupID.HasValue || groupallow.Contains(w.GroupID.Value));
return await request.Select(s => new ChatItemDto()
{ {
ID = s.ID, ID = s.ID,
ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID, ExperID = s.ConversationResponses.OrderBy(o => o.ID).Last().ExperID,
@@ -138,6 +147,7 @@ namespace Hushian.Application.Services
}).ToList() }).ToList()
}).ToListAsync(); }).ToListAsync();
}
//------------------------ //------------------------
public async Task<ResponseBase<ChatItemDto>> NewChat(ADD_ConversationDto dto, ConversationType type = ConversationType.UE) public async Task<ResponseBase<ChatItemDto>> NewChat(ADD_ConversationDto dto, ConversationType type = ConversationType.UE)
{ {
@@ -322,7 +332,11 @@ namespace Hushian.Application.Services
return true; return true;
} }
public async Task<bool> Attachedto(int ChatID, int? FromExperID, int toExperID, int CompanyID)
{
return false;
}
public async Task<bool> MarkAsReadChatItem(int ID, ConversationType Type, int? ExperID) public async Task<bool> MarkAsReadChatItem(int ID, ConversationType Type, int? ExperID)
{ {
var item = await _ConversationResponseRepository.Get() var item = await _ConversationResponseRepository.Get()

View File

@@ -69,12 +69,13 @@ namespace Hushian.WebApi.Controllers.v1
public async Task<ActionResult> ChatsAwaitingOurResponse() public async Task<ActionResult> ChatsAwaitingOurResponse()
{ {
int CompanyID = 0; int CompanyID = 0;
int? ExperID = null;
if (User.IsInRole("Exper")) if (User.IsInRole("Exper"))
{ {
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First(); string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
int ExperID = Convert.ToInt32(strExperID); ExperID = Convert.ToInt32(strExperID);
CompanyID = await _experService.GetCompanyIDExper(ExperID); CompanyID = await _experService.GetCompanyIDExper(ExperID.Value);
} }
else if (User.IsInRole("Company")) else if (User.IsInRole("Company"))
{ {
@@ -82,9 +83,31 @@ namespace Hushian.WebApi.Controllers.v1
CompanyID = Convert.ToInt32(strCompanyID); CompanyID = Convert.ToInt32(strCompanyID);
} }
var response = await _chatService.ChatsAwaitingOurResponse(CompanyID); var response = await _chatService.ChatsAwaitingOurResponse(CompanyID,ExperID);
return Ok(response); return Ok(response);
} }
[HttpPut("Attached-to/{toExperID}/{ChatID}")]
[Authorize(Roles = "Company,Exper")]
public async Task<ActionResult> Attachedto(int toExperID,int ChatID)
{
int CompanyID = 0;
int? ExperID = null;
if (User.IsInRole("Exper"))
{
string strExperID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
ExperID = Convert.ToInt32(strExperID);
CompanyID = await _experService.GetCompanyIDExper(ExperID.Value);
}
else if (User.IsInRole("Company"))
{
string strCompanyID = User.Claims.Where(w => w.Type == CustomClaimTypes.Uid).Select(s => s.Value).First();
CompanyID = Convert.ToInt32(strCompanyID);
}
var response = await _chatService.Attachedto(ChatID, ExperID,toExperID,CompanyID);
return response ?NoContent(): BadRequest(new List<string> { "خطا در بروزرسانی وضعیت" });
}
[HttpPost("NewChatFromCurrentUser")] [HttpPost("NewChatFromCurrentUser")]
public async Task<ActionResult> NewChatFromCurrentUser(ADD_ConversationDto conversation) public async Task<ActionResult> NewChatFromCurrentUser(ADD_ConversationDto conversation)
{ {

View File

@@ -26,8 +26,8 @@
<!-- A2: Buttons --> <!-- A2: Buttons -->
<div class="sidebar-tabs" id="A2"> <div class="sidebar-tabs" id="A2">
<!-- Inbox1 --> <!-- Inbox1 -->
<Button Outline="@isSelectedInbox1" Type="ButtonType.Link" @onclick="async()=>{await OnclickInbox(1);}" Size=ButtonSize.Small Color="ButtonColor.Primary" <Button Outline="@isSelectedInbox1" Type="ButtonType.Link" @onclick="async()=>{await OnclickInbox(1);}" Size=ButtonSize.Small Color="ButtonColor.Warning"
class=@($"tab-button {(isSelectedInbox1 ? "active-tab" : "")}")> class=@($"tab-button inbox1-button {(isSelectedInbox1 ? "active-tab inbox1-active" : "")}")>
<Icon Name="IconName.Inbox" Class="tab-icon" /> <Icon Name="IconName.Inbox" Class="tab-icon" />
<span class="tab-text">پیام های آمده</span> <span class="tab-text">پیام های آمده</span>
<Badge Color="BadgeColor.Warning" Class="tab-badge">@Inbox1Items.Count()</Badge> <Badge Color="BadgeColor.Warning" Class="tab-badge">@Inbox1Items.Count()</Badge>
@@ -35,15 +35,15 @@
<!-- Inbox2 --> <!-- Inbox2 -->
<Button Outline="@isSelectedInbox2" Type="ButtonType.Link" @onclick="async()=>{await OnclickInbox(2);}" Size=ButtonSize.Small Color="ButtonColor.Primary" <Button Outline="@isSelectedInbox2" Type="ButtonType.Link" @onclick="async()=>{await OnclickInbox(2);}" Size=ButtonSize.Small Color="ButtonColor.Primary"
class=@($"tab-button {(isSelectedInbox2 ? "active-tab" : "")}")> class=@($"tab-button inbox2-button {(isSelectedInbox2 ? "active-tab inbox2-active" : "")}")>
<Icon Name="IconName.Send" Class="tab-icon" /> <Icon Name="IconName.Send" Class="tab-icon" />
<span class="tab-text">پیام های من</span> <span class="tab-text">پیام های من</span>
<Badge Color="BadgeColor.Warning" Class="tab-badge">@Inbox2Items.Count()</Badge> <Badge Color="BadgeColor.Warning" Class="tab-badge">@Inbox2Items.Count()</Badge>
</Button> </Button>
<!-- Inbox3 --> <!-- Inbox3 -->
<Button Outline="@isSelectedInbox3" Type="ButtonType.Link" @onclick="async()=>{await OnclickInbox(3);}" Size=ButtonSize.Small Color="ButtonColor.Primary" <Button Outline="@isSelectedInbox3" Type="ButtonType.Link" @onclick="async()=>{await OnclickInbox(3);}" Size=ButtonSize.Small Color="ButtonColor.Danger"
class=@($"tab-button {(isSelectedInbox3 ? "active-tab" : "")}")> class=@($"tab-button inbox3-button {(isSelectedInbox3 ? "active-tab inbox3-active" : "")}")>
<Icon Name="IconName.Archive" Class="tab-icon" /> <Icon Name="IconName.Archive" Class="tab-icon" />
<span class="tab-text">پیام های بسته</span> <span class="tab-text">پیام های بسته</span>
</Button> </Button>
@@ -159,7 +159,7 @@
</Button> </Button>
<Button Color="ButtonColor.Secondary" Size=ButtonSize.ExtraSmall Outline="true" Class="toexper-btn"> <Button Color="ButtonColor.Secondary" Size=ButtonSize.ExtraSmall Outline="true" Class="toexper-btn">
<Icon Name="IconName.EnvelopeArrowUp" /> ارجاع به... <Icon Name="IconName.EnvelopeArrowUp" /> پیوست به...
</Button> </Button>
} }
else if (ChatCurrent.status == Common.Enums.ConversationStatus.Finished else if (ChatCurrent.status == Common.Enums.ConversationStatus.Finished
@@ -520,6 +520,81 @@
box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3); box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
} }
/* Smaller tab buttons */
.tab-button {
padding: 0.5rem 0.75rem;
font-size: 0.8rem;
border-radius: 10px;
}
.tab-text {
font-size: 0.8rem;
}
.tab-icon {
font-size: 0.9rem;
}
/* Inbox1 - Yellow theme */
.inbox1-button {
border-color: #ffc107;
color: #856404;
background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
}
.inbox1-button:hover {
border-color: #e0a800;
background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
color: #856404;
}
.inbox1-active {
background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
color: #212529 !important;
border-color: #ffc107 !important;
box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3) !important;
}
/* Inbox2 - Blue theme */
.inbox2-button {
border-color: #0d6efd;
color: #0d6efd;
background: linear-gradient(135deg, #e7f1ff 0%, #cce7ff 100%);
}
.inbox2-button:hover {
border-color: #0b5ed7;
background: linear-gradient(135deg, #cce7ff 0%, #b3d9ff 100%);
color: #0b5ed7;
}
.inbox2-active {
background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%) !important;
color: white !important;
border-color: #0d6efd !important;
box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3) !important;
}
/* Inbox3 - Red theme */
.inbox3-button {
border-color: #dc3545;
color: #721c24;
background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
}
.inbox3-button:hover {
border-color: #c82333;
background: linear-gradient(135deg, #f5c6cb 0%, #f1b0b7 100%);
color: #721c24;
}
.inbox3-active {
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%) !important;
color: white !important;
border-color: #dc3545 !important;
box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3) !important;
}
.tab-icon { .tab-icon {
margin-right: 0.5rem; margin-right: 0.5rem;
font-size: 1.1rem; font-size: 1.1rem;

View File

@@ -73,6 +73,11 @@ namespace HushianWebApp.Service
var response = await _baseController.Put($"{BaseRoute}ChatIsFinish/{ChatID}"); var response = await _baseController.Put($"{BaseRoute}ChatIsFinish/{ChatID}");
return response.IsSuccessStatusCode; return response.IsSuccessStatusCode;
} }
public async Task<bool> Attachedto(int toExperID, int ChatID)
{
var response = await _baseController.Put($"{BaseRoute}Attached-to/{toExperID}/{ChatID}");
return response.IsSuccessStatusCode;
}
public async Task<bool> ChatIsFinishFromUser(int ChatID) public async Task<bool> ChatIsFinishFromUser(int ChatID)
{ {
var response = await _baseController.Put($"{BaseRoute}ChatIsFinishFromUser/{ChatID}"); var response = await _baseController.Put($"{BaseRoute}ChatIsFinishFromUser/{ChatID}");