This commit is contained in:
mmrbnjd
2025-07-28 17:41:14 +03:30
parent 43b6e4e746
commit ea152671d6
13 changed files with 691 additions and 12 deletions

View File

@@ -0,0 +1,114 @@
@page "/Chant"
@using Common.Dtos.Conversation
@using Common.Dtos.Group
@using HushianWebApp.Service
@inject ChatService chatService
@inject GroupService groupService
@inject UserService userService
@inject IJSRuntime JS
@code {
public Common.Dtos.CurrentUserInfo CurrentUser { get; set; }
List<Read_GroupDto> _Group = new List<Read_GroupDto>();
//-------------------------------------
bool isSelectedInbox1 = false;
public List<ChatItemDto> Inbox1Items { get; set; } = new();
bool isSelectedInbox2 = true;
public List<ChatItemDto> Inbox2Items { get; set; } = new();
bool isSelectedInbox3 = false;
public List<ChatItemDto> Inbox3Items { get; set; } = new();
/////////////
public ChatItemDto? ChatCurrent { get; set; } = null;
public string MsgInput { get; set; }
}
@functions {
protected override async Task OnInitializedAsync()
{
CurrentUser =await userService.GetCurrentUserInfo();
_Group = await groupService.GetGroups();
Inbox1Items = await chatService.ChatAwaitingOurResponse();
Inbox2Items = await chatService.MyChatsIsInProgress();
Inbox3Items = await chatService.MyChatsIsFinished();
await base.OnInitializedAsync();
}
async Task OnclickInbox(int ID)
{
switch (ID)
{
case 1:
isSelectedInbox1 = true;
isSelectedInbox2 = false;
isSelectedInbox3 = false;
break;
case 2:
isSelectedInbox2 = true;
isSelectedInbox1 = false;
isSelectedInbox3 = false;
break;
case 3:
isSelectedInbox3 = true;
isSelectedInbox2 = false;
isSelectedInbox1 = false;
break;
}
ChatCurrent = null;
}
async Task SendMsg()
{
if (!string.IsNullOrEmpty(MsgInput) && ChatCurrent != null)
{
Common.Enums.ConversationType type = CurrentUser.Role == "Company" ? Common.Enums.ConversationType.CU : Common.Enums.ConversationType.EU;
await chatService.ADDChatResponse(ChatCurrent.ID, MsgInput, type);
ChatCurrent?.Responses.Add(new() { text = MsgInput, Type = type });
ChatCurrent.LastText = MsgInput;
await Task.Yield();
await JS.InvokeVoidAsync("scrollToBottom", "B1");
MsgInput = string.Empty;
}
}
async Task onClickSelectedCon(int InboxID, Read_ConversationDto conversationDto)
{
}
}
<style>
.input-group-text-chat {
display: flex;
align-items: center;
padding: .375rem .75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: var(--bs-body-color);
text-align: center;
white-space: nowrap;
border-radius: var(--bs-border-radius);
}
</style>
<script>
window.getWindowSize = () => {
return {
width: window.innerWidth,
height: window.innerHeight
};
};
window.registerResizeCallback = (dotNetHelper) => {
window.onresize = () => {
dotNetHelper.invokeMethodAsync("OnResize");
};
};
window.scrollToBottom = (elementId) => {
const el = document.getElementById(elementId);
if (el) {
el.scrollTop = el.scrollHeight;
}
};
</script>