|
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 | 4 |
|
4 | 5 | function App() {
|
5 | 6 | const [isSdkReady, setIsSdkReady] = useState(false);
|
6 | 7 | const [accessToken, setAccessToken] = useState('');
|
7 | 8 | const [isLoggedIn, setIsLoggedIn] = useState(false);
|
8 | 9 | const themeCheckboxRef = useRef(null);
|
| 10 | + const [currentTheme, setCurrentTheme] = useState(store.currentTheme); |
9 | 11 |
|
10 | 12 | const webexConfig = {
|
11 | 13 | fedramp: false,
|
@@ -53,51 +55,52 @@ function App() {
|
53 | 55 | };
|
54 | 56 |
|
55 | 57 | return (
|
56 |
| - // @ts-ignore |
57 |
| - <md-theme theme="momentumv2"> |
58 |
| - <h1>Contact Center widgets in a react app</h1> |
59 |
| - <input |
60 |
| - type="text" |
61 |
| - placeholder="Enter your access token" |
62 |
| - value={accessToken} |
63 |
| - onChange={(e) => setAccessToken(e.target.value)} |
64 |
| - /> |
65 |
| - <br /> |
66 |
| - <input |
67 |
| - type='checkbox' |
68 |
| - id='theme' |
69 |
| - name='theme' |
70 |
| - ref={themeCheckboxRef} |
71 |
| - onChange={() => { |
72 |
| - store.setCurrentTheme(themeCheckboxRef.current.checked ? 'DARK' : 'LIGHT'); |
73 |
| - }} |
74 |
| - /> Dark Theme |
75 |
| - <br /> |
76 |
| - <button |
77 |
| - disabled={accessToken.trim() === ''} |
78 |
| - onClick={() => { |
79 |
| - store.init({webexConfig, access_token: accessToken}).then(() => { |
80 |
| - setIsSdkReady(true); |
81 |
| - }); |
82 |
| - }} |
83 |
| - > |
84 |
| - Init Widgets |
85 |
| - </button> |
86 |
| - {isSdkReady && ( |
87 |
| - <> |
88 |
| - <StationLogin onLogin={onLogin} onLogout={onLogout} /> |
89 |
| - {isLoggedIn && ( |
90 |
| - <> |
91 |
| - <UserState /> |
92 |
| - <IncomingTask onAccepted={onAccepted} onDeclined={onDeclined} /> |
93 |
| - <TaskList onTaskAccepted={onTaskAccepted} onTaskDeclined={onTaskDeclined} /> |
94 |
| - <CallControl onHoldResume={onHoldResume} onEnd={onEnd} onWrapup={onWrapup} /> |
95 |
| - </> |
96 |
| - )} |
97 |
| - </> |
98 |
| - )} |
99 |
| - {/* @ts-ignore */} |
100 |
| - </md-theme> |
| 58 | + <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> |
| 103 | + </div> |
101 | 104 | );
|
102 | 105 | }
|
103 | 106 |
|
|
0 commit comments