Skip to content

Commit 35ceb2c

Browse files
committed
add back isAnonymous
1 parent 99074cc commit 35ceb2c

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Replace `v0.2.0` with the specific version you want to use. This method provides
120120
| prompt | string | Text shown in the input field |
121121
| embedded | boolean | Display in embedded mode |
122122
| isLoggedIn / is-logged-in | boolean | Whether the user is logged in |
123+
| isAnonymous / is-anonymous | boolean | Whether the user is anonymous |
123124
| disabled | boolean | Disable the chat input |
124125
| isOpen / is-open | boolean | Whether the chat is open |
125126
| apiKey / api-key | string | API key for authentication |

src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import QABot from './components/QABot';
1010
* - welcome: string
1111
* - prompt: string
1212
* - isLoggedIn: boolean
13+
* - isAnonymous: boolean
1314
* - disabled: boolean
1415
* - isOpen: boolean
1516
* - onClose: function
@@ -21,6 +22,7 @@ function App(props) {
2122
welcome={props.welcome}
2223
prompt={props.prompt}
2324
isLoggedIn={props.isLoggedIn}
25+
isAnonymous={props.isAnonymous}
2426
disabled={props.disabled}
2527
isOpen={props.isOpen}
2628
onClose={props.onClose}

src/components/QABot.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ const QABot = (props) => {
1111
const containerRef = useRef(null);
1212

1313
const isLoggedIn = props.isLoggedIn !== undefined ? props.isLoggedIn : false;
14+
const isAnonymous = props.isAnonymous !== undefined ? props.isAnonymous : !isLoggedIn;
15+
1416
// Derive disabled state, respecting explicit disabled prop if provided
15-
const disabled = props.disabled !== undefined ? props.disabled : !isLoggedIn;
17+
const disabled = props.disabled !== undefined ? props.disabled : isAnonymous;
1618

1719
// Use isOpen prop with default to false if not provided
1820
const isOpen = props.isOpen !== undefined ? props.isOpen : false;

src/lib.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export { WebComponentQABot };
1515
// Function-based API that prioritizes web component usage
1616
// and then attempts a react render (since some people may use the function within a react context)
1717
export function qAndATool(config) {
18-
const { target, version, isLoggedIn, isOpen, ...otherProps } = config;
18+
const { target, version, isLoggedIn, isOpen, isAnonymous, ...otherProps } = config;
1919

2020
if (!target || !(target instanceof HTMLElement)) {
2121
console.error('QA Bot: A valid target DOM element is required');
@@ -28,6 +28,7 @@ export function qAndATool(config) {
2828
return webComponentQAndATool({
2929
target,
3030
isLoggedIn,
31+
isAnonymous,
3132
isOpen,
3233
...otherProps
3334
});
@@ -38,6 +39,7 @@ export function qAndATool(config) {
3839
<React.StrictMode>
3940
<App
4041
isLoggedIn={isLoggedIn}
42+
isAnonymous={isAnonymous}
4143
isOpen={isOpen}
4244
{...otherProps}
4345
/>

src/web-component.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class AccessQABot extends HTMLElement {
122122
'prompt',
123123
'embedded',
124124
'is-logged-in',
125+
'is-anonymous',
125126
'disabled',
126127
'is-open',
127128
'api-key'
@@ -142,6 +143,7 @@ class AccessQABot extends HTMLElement {
142143
prompt: this.getAttribute('prompt'),
143144
embedded: this.hasAttribute('embedded'),
144145
isLoggedIn: this.hasAttribute('is-logged-in'),
146+
isAnonymous: this.hasAttribute('is-anonymous'),
145147
disabled: this.hasAttribute('disabled'),
146148
isOpen: this.hasAttribute('is-open'),
147149
// Always provide an apiKey to prevent process.env reference errors

0 commit comments

Comments
 (0)