feat(widget): Add captain handoff request

This commit is contained in:
aakashb95
2026-05-01 23:01:05 +05:30
parent 68cd725a62
commit e89d8567fd
7 changed files with 109 additions and 2 deletions
@@ -6,6 +6,7 @@ import {
toggleTyping,
setUserLastSeenAt,
toggleStatus,
requestHandoff,
setCustomAttributes,
deleteCustomAttribute,
} from 'widget/api/conversation';
@@ -212,6 +213,11 @@ export const actions = {
await toggleStatus();
},
requestHandoff: async ({ dispatch }) => {
await requestHandoff();
dispatch('conversationAttributes/getAttributes', {}, { root: true });
},
setCustomAttributes: async (
{ commit, rootGetters },
customAttributes = {}
@@ -39,6 +39,15 @@ export const getters = {
getMessageCount: _state => {
return Object.values(_state.conversations).length;
},
getCaptainReplyCount: _state => {
return Object.values(_state.conversations).filter(message => {
const { message_type: messageType, sender = {} } = message;
return (
messageType === MESSAGE_TYPE.OUTGOING &&
sender.type === 'captain_assistant'
);
}).length;
},
getUnreadMessageCount: _state => {
const { userLastSeenAt } = _state.meta;
return Object.values(_state.conversations).filter(chat => {