diff --git a/packages/journey-manager/src/ui.tsx b/packages/journey-manager/src/ui.tsx
index bd84d17b..b3f5e80b 100644
--- a/packages/journey-manager/src/ui.tsx
+++ b/packages/journey-manager/src/ui.tsx
@@ -2,8 +2,15 @@
import { type Client } from "@nlxai/multimodal";
import { autoUpdate, platform } from "@floating-ui/dom";
-import { render, type FunctionComponent } from "preact";
-import { useEffect, useState, useRef, useMemo } from "preact/hooks";
+import { render, type FunctionComponent, type VNode } from "preact";
+import {
+ useEffect,
+ useState,
+ useRef,
+ useMemo,
+ type MutableRef,
+} from "preact/hooks";
+import { createPortal } from "preact/compat";
import tinycolor from "tinycolor2";
/**
@@ -38,6 +45,10 @@ export interface Theme {
fontFamily: string;
}
+interface SimpleHandlerArg {
+ sendStep: Client["sendStep"];
+}
+
interface HandlerArg {
sendStep: Client["sendStep"];
triggeredSteps: Array<{ stepId: string; url: string }>;
@@ -106,7 +117,7 @@ export interface UiConfig {
/**
* Escalation handler
*/
- onEscalation?: (config: { sendStep: Client["sendStep"] }) => void;
+ onEscalation?: (config: SimpleHandlerArg) => void;
/**
* Escalation button label
*/
@@ -118,7 +129,7 @@ export interface UiConfig {
/**
* End handler
*/
- onEnd?: (config: { sendStep: Client["sendStep"] }) => void;
+ onEnd?: (config: SimpleHandlerArg) => void;
/**
* End button label
*/
@@ -353,7 +364,24 @@ button {
margin-right: auto;
}
-.drawer-content > * + * {
+.drawer-dialog {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-direction: column;
+ background-color: white;
+ border-top-left-radius: 12px;
+ border-top-right-radius: 12px;
+ z-index: 20;
+}
+
+/** Only add spacing margins from the third child onwards (as the first child is the dialog container) */
+.drawer-content > * + * + * {
margin-top: 25px;
}
@@ -596,6 +624,77 @@ type ControlCenterStatus =
| "success-escalation"
| "success-end";
+const SuccessMessage: FunctionComponent<{ message: string }> = ({
+ message,
+}) => {
+ return (
+
+
+
+
+ {message}
+
+ );
+};
+
+const DrawerDialog: FunctionComponent<{ children: VNode }> = ({
+ children,
+}) => {
+ return {children}
;
+};
+
+const EscalationButton: FunctionComponent<{
+ onEscalation: (config: SimpleHandlerArg) => void;
+ escalationButtonLabel?: string;
+ client: Client;
+ onClose: () => void;
+ drawerDialogRef: MutableRef;
+}> = ({
+ onEscalation,
+ drawerDialogRef,
+ onClose,
+ client,
+ escalationButtonLabel,
+}) => {
+ const [status, setStatus] = useState<
+ "confirming" | "pending" | "success" | null
+ >(null);
+ return (
+ <>
+ {status === "confirming"
+ ? createPortal(
+
+ abcd
+ ,
+ drawerDialogRef.current!,
+ )
+ : null}
+ {status === "success" ? (
+
+ ) : (
+
+ )}
+ >
+ );
+};
+
const ControlCenter: FunctionComponent<{
config: UiConfig;
client: Client;
@@ -607,6 +706,7 @@ const ControlCenter: FunctionComponent<{
const [isOpen, setIsOpen] = useState(false);
const [status, setStatus] = useState(null);
const drawerContentRef = useRef(null);
+ const drawerDialogRef = useRef(null);
const [isNudgeVisible, setIsNudgeVisible] = useState(false);
useEffect(() => {
@@ -680,11 +780,20 @@ const ControlCenter: FunctionComponent<{
/>
+
{config.title}
{config.subtitle}
@@ -708,12 +818,7 @@ const ControlCenter: FunctionComponent<{
) : null}
{successMessage != null ? (
-
-
-
-
- {successMessage}
-
+
) : (
@@ -728,22 +833,15 @@ const ControlCenter: FunctionComponent<{
{config.onEscalation != null ? (
-
+ drawerDialogRef={drawerDialogRef}
+ />
) : null}
{config.onEnd != null ? (
diff --git a/packages/website/src/components/Prototyping.tsx b/packages/website/src/components/Prototyping.tsx
index 7ba8d450..81de85df 100644
--- a/packages/website/src/components/Prototyping.tsx
+++ b/packages/website/src/components/Prototyping.tsx
@@ -133,14 +133,12 @@ const runJourneyManager = async (): Promise => {
fontFamily: "'Neue Haas Grotesk'",
colors: { highlight: "#7dd3fc" },
},
+ escalationButtonLabel: "Hand Off To Specialist",
onEscalation: (args) => {
// eslint-disable-next-line no-console
console.log("escalation", args);
},
- escalationButtonLabel: "Hand Off To Specialist",
- nudgeContent: "Control panel",
- nudgeShowAfterMs: 2000,
- nudgeHideAFterMs: 20000,
+ nudgeContent: "click me! click me!",
buttons: [
{
label: "Google Chat",