Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/show blocked users #386

Merged
merged 5 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<button mat-menu-item (click)="updateList('stashed', 'Stashed')">Stashed</button>
<button mat-menu-item (click)="updateList('completed', 'Completed')">Completed</button> -->
<button mat-menu-item (click)="updateList('all', 'All')">All</button>
<button mat-menu-item (click)="updateList('blocked', 'Help Requests')">Help Requests</button>
</mat-menu>
<div class="menu-title">
{{ selected }} ({{displayedChats.length}})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class ChatsListComponent implements AfterViewInit
paused: Chat[];
completed: Chat[];
stashed: Chat[];
blocked: Chat[];

@ViewChildren(MatPaginator) paginator: QueryList<MatPaginator>;

Expand Down Expand Up @@ -101,10 +102,16 @@ export class ChatsListComponent implements AfterViewInit
this.onboarding = [];
this.completed = [];
this.stashed = [];
this.blocked = [];
}

categorize(chat: Chat)
{
if(chat.isConversationComplete === -1) {
this.blocked.push(chat);
return;
}

switch(chat.flow)
{
case ChatFlowStatus.PausedByAgent:
Expand Down Expand Up @@ -189,6 +196,9 @@ export class ChatsListComponent implements AfterViewInit
case "completed":
this.displayedChats = this.completed;
break;
case "blocked":
this.displayedChats = this.blocked;
break;
case 'all':
default:
this.displayedChats = this.chats;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</mat-card>

<mat-card fxFlex="23" class="stats-card">
<div class="stats-number">{{pendingAssessments}}</div>
<div class="stats-number">{{pausedChats}}</div>
<div class="stats-title">Paused Chats</div>
<div class="stats-difference negative">
<i class="fas fa-arrow-circle-down"></i> decrease
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component} from '@angular/core';

import { Chat, ChatFlowStatus } from '@app/model/convs-mgr/conversations/chats';
import { Chat, ChatFlowStatus, ChatStatus } from '@app/model/convs-mgr/conversations/chats';
import { ChatsStore } from '@app/state/convs-mgr/conversations/chats';

@Component({
Expand All @@ -14,7 +14,7 @@ export class TrainerStatsComponent
engagedChats: number;
activeChats: number;
seekingAssistance: number;
pendingAssessments: number;
pausedChats: number;

constructor(private _chats$: ChatsStore)
{
Expand All @@ -24,11 +24,9 @@ export class TrainerStatsComponent
getChatStats(chats: Chat[])
{
this.engagedChats = chats.length;
this.activeChats = chats.filter(chat => chat.flow !== ChatFlowStatus.Completed).length;
const helpRequests = chats.filter(chat => chat.flow === ChatFlowStatus.Paused).length;
const offlineRequests = chats.filter(chat => chat.flow === ChatFlowStatus.OnWaitlist).length;
this.seekingAssistance = helpRequests + offlineRequests;
this.pendingAssessments = chats.filter(chat => chat.flow === ChatFlowStatus.PendingAssessment).length;
this.activeChats = chats.filter(chat => chat.status === ChatStatus.Running).length;
this.seekingAssistance = chats.filter(chat => chat.isConversationComplete === -1).length;
this.pausedChats = chats.filter(chat => chat.status === (ChatStatus.PausedByAgent)).length;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,20 @@ export class SendOutgoingMsgHandler extends FunctionHandler<Message, RestResult>
// Check if the last message sent was more than 24hours ago
if ((Date.now() - latestMessageTime) > 86400000) {
const templateConfig = communicationChannel.templateConfig;
if(templateConfig) {
// Send the opt-in message template

// Get the opt-in message template
outgoingMessagePayload = activeChannel
.parseOutMessageTemplate(templateConfig, outgoingPayload.endUserPhoneNumber, outgoingPayload);
.parseOutMessageTemplate(templateConfig, outgoingPayload.endUserPhoneNumber, outgoingPayload);
}
}}

// STEP 5: Send the message
await activeChannel.send(outgoingMessagePayload as any);

tools.Logger.error(() => `[WhatsAppSendOutgoingMsgHandler].execute - Success in sending message ${JSON.stringify(outgoingMessagePayload)}`);

return { success: true } as RestResult200;
} catch (error) {
tools.Logger.error(() => `[WhatsAppSendOutgoingMsgHandler].execute - Encountered an error ${error}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class WhatsappActiveChannel implements ActiveChannel
{
// Create the message template payload which will be sent to whatsapp
const messageTemplate = new WhatsappOutgoingMessageParser()
.parseOutMessageTemplate(templateConfig, phone, message);
.getMessageTemplateParserOut(templateConfig, phone, message);

return messageTemplate;
}
Expand Down Expand Up @@ -106,7 +106,7 @@ export class WhatsappActiveChannel implements ActiveChannel
this._tools.Logger.log(() => `[SendWhatsAppMessageModel].sendMessage: Success in sending message ${JSON.stringify(response.data)}`);

// Mark the conversation as complete
this.endUserService.setConversationComplete(`w_${this.channel.n}_${whatsappMessage.to}`, +1).then(() => {
this.endUserService.setConversationComplete(`w_${this.channel.n}_${whatsappMessage.to}`, 1).then(() => {

this._tools.Logger.log(() => `[SendWhatsAppMessageModel].sendMessage: Conversation marked as complete`);
}).catch(err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export interface Chat extends IObject
instructors?: string[];

lastMsg?: any;

isConversationComplete?: number;
}

export interface ChatUserInfo {
Expand Down