|
1 | 1 | import React, {useState, useRef} from 'react';
|
2 | 2 | import {StationLogin, UserState, IncomingTask, TaskList, CallControl, store} from '@webex/cc-widgets';
|
3 |
| -import {ThemeProvider,IconProvider} from '@momentum-design/components/dist/react'; |
| 3 | +import {ThemeProvider, IconProvider} from '@momentum-design/components/dist/react'; |
4 | 4 |
|
5 | 5 | function App() {
|
6 | 6 | const [isSdkReady, setIsSdkReady] = useState(false);
|
7 | 7 | const [accessToken, setAccessToken] = useState('');
|
8 | 8 | const [isLoggedIn, setIsLoggedIn] = useState(false);
|
9 | 9 | const themeCheckboxRef = useRef(null);
|
10 | 10 | const [currentTheme, setCurrentTheme] = useState(store.currentTheme);
|
| 11 | + const [isMultiLoginEnabled, setIsMultiLoginEnabled] = useState(false); |
11 | 12 |
|
12 | 13 | const webexConfig = {
|
13 | 14 | fedramp: false,
|
14 | 15 | logger: {
|
15 | 16 | level: 'log',
|
16 | 17 | },
|
| 18 | + cc: { |
| 19 | + allowMultiLogin: isMultiLoginEnabled, |
| 20 | + }, |
17 | 21 | };
|
18 | 22 |
|
19 | 23 | const onLogin = () => {
|
@@ -54,52 +58,75 @@ function App() {
|
54 | 58 | console.log('onWrapup invoked');
|
55 | 59 | };
|
56 | 60 |
|
| 61 | + const enableDisableMultiLogin = () => { |
| 62 | + if (isMultiLoginEnabled) { |
| 63 | + setIsMultiLoginEnabled(false); |
| 64 | + } else { |
| 65 | + setIsMultiLoginEnabled(true); |
| 66 | + } |
| 67 | + }; |
| 68 | + |
57 | 69 | return (
|
58 | 70 | <div className="mds-typography">
|
59 |
| - <ThemeProvider themeclass={currentTheme === 'LIGHT' ? 'mds-theme-stable-lightWebex': 'mds-theme-stable-darkWebex'}><IconProvider> |
60 |
| - <h1>Contact Center widgets in a react app</h1> |
61 |
| - <input |
62 |
| - type="text" |
63 |
| - placeholder="Enter your access token" |
64 |
| - value={accessToken} |
65 |
| - onChange={(e) => setAccessToken(e.target.value)} |
66 |
| - /> |
67 |
| - <br /> |
68 |
| - <input |
69 |
| - type='checkbox' |
70 |
| - id='theme' |
71 |
| - name='theme' |
72 |
| - ref={themeCheckboxRef} |
73 |
| - onChange={() => { |
74 |
| - setCurrentTheme(themeCheckboxRef.current.checked ? 'DARK' : 'LIGHT'); |
75 |
| - store.setCurrentTheme(themeCheckboxRef.current.checked ? 'DARK' : 'LIGHT'); |
76 |
| - }} |
77 |
| - /> Dark Theme |
78 |
| - <br /> |
79 |
| - <button |
80 |
| - disabled={accessToken.trim() === ''} |
81 |
| - onClick={() => { |
82 |
| - store.init({webexConfig, access_token: accessToken}).then(() => { |
83 |
| - setIsSdkReady(true); |
84 |
| - }); |
85 |
| - }} |
86 |
| - > |
87 |
| - Init Widgets |
88 |
| - </button> |
89 |
| - {isSdkReady && ( |
90 |
| - <> |
91 |
| - <StationLogin onLogin={onLogin} onLogout={onLogout} /> |
92 |
| - {isLoggedIn && ( |
93 |
| - <> |
94 |
| - <UserState /> |
95 |
| - <IncomingTask onAccepted={onAccepted} onDeclined={onDeclined} /> |
96 |
| - <TaskList onTaskAccepted={onTaskAccepted} onTaskDeclined={onTaskDeclined} /> |
97 |
| - <CallControl onHoldResume={onHoldResume} onEnd={onEnd} onWrapup={onWrapup} /> |
98 |
| - </> |
99 |
| - )} |
100 |
| - </> |
101 |
| - )} |
102 |
| - </IconProvider></ThemeProvider> |
| 71 | + <ThemeProvider |
| 72 | + themeclass={currentTheme === 'LIGHT' ? 'mds-theme-stable-lightWebex' : 'mds-theme-stable-darkWebex'} |
| 73 | + > |
| 74 | + <IconProvider> |
| 75 | + <h1>Contact Center widgets in a react app</h1> |
| 76 | + <input |
| 77 | + type="text" |
| 78 | + placeholder="Enter your access token" |
| 79 | + value={accessToken} |
| 80 | + onChange={(e) => setAccessToken(e.target.value)} |
| 81 | + /> |
| 82 | + <br /> |
| 83 | + <input |
| 84 | + type="checkbox" |
| 85 | + id="theme" |
| 86 | + name="theme" |
| 87 | + ref={themeCheckboxRef} |
| 88 | + onChange={() => { |
| 89 | + setCurrentTheme(themeCheckboxRef.current.checked ? 'DARK' : 'LIGHT'); |
| 90 | + store.setCurrentTheme(themeCheckboxRef.current.checked ? 'DARK' : 'LIGHT'); |
| 91 | + }} |
| 92 | + />{' '} |
| 93 | + Dark Theme |
| 94 | + <br /> |
| 95 | + <div className="warning-note" style={{color: 'red', marginBottom: '10px'}}> |
| 96 | + <strong>Note:</strong> The "Enable Multi Login" option must be set before initializing the SDK. Changes to |
| 97 | + this setting after SDK initialization will not take effect. Please ensure you configure this option before |
| 98 | + clicking the "Init Widgets" button. |
| 99 | + </div> |
| 100 | + <label> |
| 101 | + <input type="checkbox" id="multiLoginFlag" name="multiLoginFlag" onChange={enableDisableMultiLogin} />{' '} |
| 102 | + Enable Multi Login |
| 103 | + </label> |
| 104 | + <br /> |
| 105 | + <button |
| 106 | + disabled={accessToken.trim() === ''} |
| 107 | + onClick={() => { |
| 108 | + store.init({webexConfig, access_token: accessToken}).then(() => { |
| 109 | + setIsSdkReady(true); |
| 110 | + }); |
| 111 | + }} |
| 112 | + > |
| 113 | + Init Widgets |
| 114 | + </button> |
| 115 | + {isSdkReady && ( |
| 116 | + <> |
| 117 | + <StationLogin onLogin={onLogin} onLogout={onLogout} /> |
| 118 | + {isLoggedIn && ( |
| 119 | + <> |
| 120 | + <UserState /> |
| 121 | + <IncomingTask onAccepted={onAccepted} onDeclined={onDeclined} /> |
| 122 | + <TaskList onTaskAccepted={onTaskAccepted} onTaskDeclined={onTaskDeclined} /> |
| 123 | + <CallControl onHoldResume={onHoldResume} onEnd={onEnd} onWrapup={onWrapup} /> |
| 124 | + </> |
| 125 | + )} |
| 126 | + </> |
| 127 | + )} |
| 128 | + </IconProvider> |
| 129 | + </ThemeProvider> |
103 | 130 | </div>
|
104 | 131 | );
|
105 | 132 | }
|
|
0 commit comments