diff --git a/src/App.js b/src/App.js
index f0798cd..804fb95 100644
--- a/src/App.js
+++ b/src/App.js
@@ -72,6 +72,8 @@ const MyChatBot = (props) => {
},
chatInput: {
enabledPlaceholderText: prompt,
+ disabledPlaceholderText: 'Please log in to ask questions.',
+ disabled: props.disabled
},
chatHistory: { storageKey: "qa_bot" },
botBubble: {
@@ -108,7 +110,7 @@ const MyChatBot = (props) => {
function App(props) {
return (
-
+
);
}
diff --git a/src/index.js b/src/index.js
index d9b128a..538cb8d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -6,10 +6,16 @@ import reportWebVitals from './reportWebVitals';
// Popup Chat widget
const domNode = document.createElement('div');
-const root = ReactDOM.createRoot(domNode);
+const root = ReactDOM.createRoot(domNode);
+
+function isAnonymous() {
+ return !document.querySelector('body').classList.contains('user-logged-in');
+}
+const disabled = isAnonymous();
+
root.render(
-
+
);
document.body.appendChild(domNode);
@@ -17,6 +23,7 @@ document.body.appendChild(domNode);
// Look for optional elements for an embedded chat widget
const embeddedQABots = document.querySelectorAll('.embedded-qa-bot');
embeddedQABots.forEach(embeddedQABot => {
+ const disabled = isAnonymous();
// welcome message and prompt are data- attributes
const welcome = embeddedQABot.dataset.welcome;
const prompt = embeddedQABot.dataset.prompt;
@@ -24,7 +31,7 @@ embeddedQABots.forEach(embeddedQABot => {
const embeddedRoot = ReactDOM.createRoot(embeddedDomNode);
embeddedRoot.render(
-
+
);
embeddedQABot.appendChild(embeddedDomNode);