UNPKG

@botonic/react

Version:

Build Chatbots using React

38 lines 2.15 kB
import { __awaiter } from "tslib"; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { EventAction } from '@botonic/core'; import { useContext, useEffect, useState } from 'react'; import { WebchatContext } from '../../../webchat/context'; import { HeadSetSvg } from '../icons'; import { StyledDebugDetail, StyledDebugLabel, StyledDebugValue, } from '../styles'; import { LABELS } from './constants'; export const HandoffSuccess = (props) => { const { previewUtils } = useContext(WebchatContext); const [noteMessage, setNoteMessage] = useState(); useEffect(() => { const fetchNoteMessage = () => __awaiter(void 0, void 0, void 0, function* () { if (!previewUtils || !props.handoff_note_id) { return; } const noteMessage = yield previewUtils.getMessageById(props.handoff_note_id); if (!noteMessage) { return; } setNoteMessage(noteMessage.text); }); fetchNoteMessage(); }, [previewUtils, props.handoff_note_id]); return (_jsxs(_Fragment, { children: [_jsxs(StyledDebugDetail, { children: [_jsx(StyledDebugLabel, { children: LABELS.QUEUE }), _jsx(StyledDebugValue, { children: props.handoff_queue_name })] }), _jsxs(StyledDebugDetail, { children: [_jsx(StyledDebugLabel, { children: LABELS.AUTO_ASSIGN }), _jsx(StyledDebugValue, { children: props.handoff_has_auto_assign ? LABELS.AUTO_ASSIGN_ON : LABELS.AUTO_ASSIGN_OFF })] }), Boolean(noteMessage) && (_jsxs(StyledDebugDetail, { children: [_jsx(StyledDebugLabel, { children: LABELS.NOTE }), _jsx(StyledDebugValue, { children: noteMessage })] }))] })); }; export const getHandoffSuccessEventConfig = (data) => { return { action: EventAction.HandoffSuccess, title: (_jsxs(_Fragment, { children: ["Handoff to agent ", _jsxs("span", { children: ["- ", data.handoff_queue_name] })] })), icon: _jsx(HeadSetSvg, {}), component: HandoffSuccess, collapsible: true, }; }; //# sourceMappingURL=handoff-success.js.map