...
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
@inject IJSRuntime JS
|
||||
@inject ToastService toastService
|
||||
@layout UserPanelLayout
|
||||
<ConfirmDialog @ref="dialog" />
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row" style="height:85vh">
|
||||
@if (IsEndFirstProcess)
|
||||
@@ -33,11 +35,11 @@
|
||||
{
|
||||
@if (LastOpenChat.status == Common.Enums.ConversationStatus.InProgress)
|
||||
{
|
||||
<Button Color="ButtonColor.Danger" Size=ButtonSize.ExtraSmall Outline="true" Class="finish-conversation-btn">
|
||||
<Button Color="ButtonColor.Danger" Size=ButtonSize.ExtraSmall Outline="true" @onclick="CloseChat" Class="finish-conversation-btn">
|
||||
<Icon Name="IconName.Escape" Class="me-1" /> اتمام گفتگو
|
||||
</Button>
|
||||
}
|
||||
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" Class="finish-conversation-btn">
|
||||
<Button Color="ButtonColor.Success" Size=ButtonSize.ExtraSmall Outline="true" @onclick="NewChat" Class="finish-conversation-btn">
|
||||
<Icon Name="IconName.ChatDots" Class="me-1" /> گفتگو جدید
|
||||
</Button>
|
||||
}
|
||||
@@ -105,7 +107,7 @@
|
||||
@foreach (var group in CompanyGroups)
|
||||
{
|
||||
<div class="group-card @(GroupID == group.ID ? "selected" : "")"
|
||||
@onclick="() => SelectGroup(group.ID)">
|
||||
@onclick="() => SelectGroup(group.ID)">
|
||||
<div class="group-card-content">
|
||||
@if (group.img == null || group.img.Length == 0)
|
||||
{
|
||||
@@ -133,7 +135,7 @@
|
||||
<!-- B2: Message input -->
|
||||
<div class="message-input-container" id="B2">
|
||||
<div class="input-wrapper">
|
||||
<input type="text" @bind-value="MsgInput" class="message-input" placeholder="پیام خود را بنویسید..." />
|
||||
<input type="text" @bind-value="MsgInput" class="message-input" placeholder="پیام خود را بنویسید..." @onkeydown="HandleKeyDown" />
|
||||
<Button Color="ButtonColor.Primary" Size=ButtonSize.Small @onclick="OnClickSendMsg" Class="send-btn">
|
||||
<Icon Name="IconName.Send" />
|
||||
</Button>
|
||||
@@ -170,6 +172,7 @@
|
||||
@code {
|
||||
[Parameter] public int CompanyID { get; set; }
|
||||
[Parameter] public int? ChatID { get; set; }
|
||||
private ConfirmDialog dialog = default!;
|
||||
|
||||
private bool _shouldObserveVisibility = false;
|
||||
int? GroupID = null;
|
||||
@@ -297,7 +300,7 @@
|
||||
{
|
||||
if (ChatID.HasValue) LastOpenChat = await ChatService.Getchat(ChatID.GetValueOrDefault());
|
||||
else LastOpenChat = LastOpenChat = await ChatService.GetLastOpenChatInCompany(CompanyID);
|
||||
|
||||
|
||||
if (LastOpenChat != null)
|
||||
{
|
||||
|
||||
@@ -337,6 +340,37 @@
|
||||
await JS.InvokeVoidAsync("autoScrollToNewMessage");
|
||||
}
|
||||
}
|
||||
}
|
||||
async Task NewChat()
|
||||
{
|
||||
LastOpenChat = null;
|
||||
}
|
||||
async Task CloseChat()
|
||||
{
|
||||
var options = new ConfirmDialogOptions
|
||||
{
|
||||
YesButtonText = "بله",
|
||||
YesButtonColor = ButtonColor.Success,
|
||||
NoButtonText = "انصراف",
|
||||
NoButtonColor = ButtonColor.Danger
|
||||
};
|
||||
|
||||
var confirmation = await dialog.ShowAsync(
|
||||
title: "پایان دادن به گفتگو",
|
||||
message1: "اطمینان دارید ؟",
|
||||
confirmDialogOptions: options);
|
||||
|
||||
if (confirmation)
|
||||
{
|
||||
if (await chatService.ChatIsFinishFromUser(LastOpenChat.ID))
|
||||
{
|
||||
LastOpenChat.status = Common.Enums.ConversationStatus.Finished;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
async Task Logout()
|
||||
{
|
||||
@@ -345,7 +379,6 @@
|
||||
IsLogin = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
async Task SelectGroup(int groupId)
|
||||
{
|
||||
GroupID = groupId;
|
||||
@@ -353,7 +386,10 @@
|
||||
}
|
||||
private string GetImageSource(byte[] bytes)
|
||||
=> $"data:image/jpeg;base64,{Convert.ToBase64String(bytes)}";
|
||||
|
||||
private async Task HandleKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
if (e.Key == "Enter") await OnClickSendMsg();
|
||||
}
|
||||
|
||||
}
|
||||
<style>
|
||||
|
Reference in New Issue
Block a user