@afncdelacru/brady-chat 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/lib/EnhancedBradyChat.tsx +19 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@afncdelacru/brady-chat",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Brady AI chat sidebar component and context for AFN recruiting experiences.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"afn"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@afncdelacru/brady-chat": "^0.4.
|
|
35
|
+
"@afncdelacru/brady-chat": "^0.4.2"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -28,12 +28,12 @@ export interface EnhancedBradyChatProps {
|
|
|
28
28
|
avatarSrc: string;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* If set, will set the input value and send it
|
|
31
|
+
* If set, will immediately set the input value and send it as a user message.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
setUserText?: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
export function EnhancedBradyChat({ modeVariant = 'loan-officer', avatarSrc,
|
|
36
|
+
export function EnhancedBradyChat({ modeVariant = 'loan-officer', avatarSrc, setUserText }: EnhancedBradyChatProps) {
|
|
37
37
|
|
|
38
38
|
const [bradyHealthy, setBradyHealthy] = useState(true);
|
|
39
39
|
const {
|
|
@@ -54,22 +54,23 @@ export function EnhancedBradyChat({ modeVariant = 'loan-officer', avatarSrc, aut
|
|
|
54
54
|
setIsHidden,
|
|
55
55
|
} = useBradyChat();
|
|
56
56
|
const [inputValue, setInputValue] = useState('');
|
|
57
|
-
const [
|
|
58
|
-
// Auto-send user text if provided
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (autoUserText && !autoUserTextSent) {
|
|
61
|
-
setInputValue(autoUserText);
|
|
62
|
-
setAutoUserTextSent(true);
|
|
63
|
-
}
|
|
64
|
-
}, [autoUserText, autoUserTextSent]);
|
|
57
|
+
const [setUserTextSent, setSetUserTextSent] = useState<string | undefined>(undefined);
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
// Auto-send user text if setUserText changes
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (setUserText && setUserText !== setUserTextSent) {
|
|
62
|
+
setInputValue(setUserText);
|
|
63
|
+
setSetUserTextSent(setUserText);
|
|
64
|
+
}
|
|
65
|
+
}, [setUserText, setUserTextSent]);
|
|
66
|
+
|
|
67
|
+
// When inputValue is set by setUserText, trigger send
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (setUserText && setUserTextSent === setUserText && inputValue === setUserText && inputValue.trim()) {
|
|
70
|
+
handleSend();
|
|
71
|
+
}
|
|
72
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
|
+
}, [inputValue, setUserText, setUserTextSent]);
|
|
73
74
|
const [showForm, setShowForm] = useState(false);
|
|
74
75
|
const [inputDisabled, setInputDisabled] = useState(false);
|
|
75
76
|
const [showModePrompts, setShowModePrompts] = useState(false);
|