Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
383aafc
fix: convert npm to yarn
mkesavan13 Oct 21, 2024
520fac9
Merge remote-tracking branch 'upstream/master' into convert_to_yarn
mkesavan13 Oct 21, 2024
a9d5669
fix: yarn lock
mkesavan13 Oct 21, 2024
c9fe972
fix: rename folder to match package name
mkesavan13 Oct 22, 2024
6d24f89
fix: move to yarn 4.5.1
mkesavan13 Oct 22, 2024
09adcc5
fix: nitpick self review comments
mkesavan13 Oct 24, 2024
debdaaa
feat(cc-widgets): inital-packages-setup
Oct 24, 2024
f775ae2
fix(cc-widgets): move-widgets-inside-webex-folder
Oct 24, 2024
11a111b
fix(cc-widgets): remove-yarn-changes
Oct 24, 2024
840074c
fix(cc-widgets): added-babel-webpack-configs
Oct 24, 2024
72173d2
feat(setup): update-setup
Nov 4, 2024
f195b14
fix(cc-widgets): add-react-w2x-and-mobx
Nov 5, 2024
d8309fe
feat(cc-widgets): add-tests-for-widgets
Nov 5, 2024
5ce6996
feat(react-samples): add-widgets-samples-with-react
Nov 5, 2024
6505954
feat(cc-widgets): samples-app-for-widgets-as-web-component
Nov 5, 2024
e1ca859
fix(cc-widgets): review-comments
Nov 5, 2024
842e311
Merge remote-tracking branch 'upstream/feat/cc-widgets' into packages…
Nov 5, 2024
0aa1ad6
fix(cc-widgets): create-common-webpack-config
Nov 6, 2024
dd165c9
fix(cc-widgets): add-ts-doc-fix-babelrc
Nov 6, 2024
e3d4569
fix(cc-widgets): minor-fixes
Nov 6, 2024
e0646ad
fix(webpack): remove-react-react-dom-as-external
Nov 11, 2024
b6a0f69
feat(cc-widgets): review-comments
Nov 11, 2024
1cfd42a
feat(cc-widgets): add-home-page-for-samples
Nov 11, 2024
dd7a176
feat(station-login): Added code for UI and functional logic for stati…
Kesari3008 Nov 12, 2024
de0be73
feat(station-login): tested and refined changes
Kesari3008 Nov 15, 2024
cddf823
fix(station-login): latest merge
Kesari3008 Nov 18, 2024
091c3a9
feat(station-login): review comments
Kesari3008 Nov 18, 2024
692fed1
feat(station-login): review comments
Kesari3008 Nov 18, 2024
e1ed912
feat(station-login): review comments 2
Kesari3008 Nov 18, 2024
0771768
feat(station-login): tests updated
Kesari3008 Nov 19, 2024
6980358
feat(station-login): minor change
Kesari3008 Nov 19, 2024
2f38760
feat(station-login): styles fixes
Kesari3008 Nov 19, 2024
9339aea
feat(station-login): review comments
Kesari3008 Nov 19, 2024
e965f91
feat(station-login): init function changes
Kesari3008 Nov 20, 2024
97e5aa6
feat(station-login): changes in samples
Kesari3008 Nov 20, 2024
b774f9d
feat(station-login): fixed tests
Kesari3008 Nov 20, 2024
7829e0c
feat(station-login): yarn file update
Kesari3008 Nov 20, 2024
ebf602f
feat(station-login): callback comment addressed
Kesari3008 Nov 20, 2024
b7c3104
feat(station-login): merge conflict resolution
Kesari3008 Nov 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions docs/react-samples/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
import React from 'react';
import React, { useEffect } from 'react';
import store from '@webex/cc-store'
import {StationLogin} from '@webex/cc-station-login';
import {UserState} from '@webex/cc-user-state';

function App() {
const token = '';

const webexConfig = {
fedramp: false,
logger: {
level: 'log' // TODO: We will add more logging levels later and set the righ levels
},
}

useEffect(() => {
const init = async () => {
await store.init(webexConfig, token);
}

init();
}, [])

const onLogin = () => {
console.log('Agent login has been succesful');
}

const onLogout = () => {
console.log('Agent logout has been succesful');
}

return (
<>
<h1>Contact Center widgets in a react app</h1>
<StationLogin />
<StationLogin onLogin={onLogin} onLogout={onLogout} />
<UserState />
</>
);
Expand Down
12 changes: 12 additions & 0 deletions docs/web-component-samples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,16 @@ <h1>Contact Center widgets as web-component</h1>
<widget-cc-station-login></widget-cc-station-login>
<widget-cc-user-state></widget-cc-user-state>
</body>
<script>
const token = '';

const webexConfig = {
fedramp: false,
logger: {
level: 'log' // TODO: We will add more logging levels later and set the righ levels
},
}

store.init(webexConfig, token);
</script>
</html>
4 changes: 4 additions & 0 deletions docs/web-component-samples/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
import store from '@webex/cc-store';
import '@webex/cc-station-login';
import '@webex/cc-user-state';

//@ts-ignore
window.store = store;
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@semantic-release/github": "^11.0.1",
"@testing-library/react-hooks": "^8.0.1",
"crypto-browserify": "^3.12.1",
"html-webpack-plugin": "^5.6.3",
"jest": "29.7.0",
"node-gyp": "^10.2.0",
"os-browserify": "^0.3.0",
"process": "^0.11.10",
"querystring-es3": "^0.2.1",
"semantic-release": "^24.2.0",
"stream-browserify": "^3.0.0",
"typescript": "^5.6.3",
"vm-browserify": "^1.1.2",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/contact-center/station-login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"@webex/cc-store": "workspace:*",
"mobx-react": "9.1.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"typescript": "5.6.3"
"react-dom": "18.3.1"
},
"devDependencies": {
"@babel/core": "7.25.2",
Expand All @@ -40,6 +39,7 @@
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"ts-loader": "9.5.1",
"typescript": "5.6.3",
"webpack": "5.94.0",
"webpack-cli": "5.1.4",
"webpack-merge": "6.0.1"
Expand Down
42 changes: 39 additions & 3 deletions packages/contact-center/station-login/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
export const useStationLogin = () => {
return {name: 'StationLogin'};
};
import {useState} from "react";
import {StationLoginSuccess, StationLogoutSuccess} from '@webex/plugin-cc';
import {UseStationLoginProps} from "./station-login/station-login.types";

export const useStationLogin = (props: UseStationLoginProps) => {
const cc = props.cc;
Comment thread
Shreyas281299 marked this conversation as resolved.
const loginCb = props.onLogin;
const logoutCb = props.onLogout;
const [dialNumber, setDialNumber] = useState('');
const [deviceType, setDeviceType] = useState('');
const [team, setTeam] = useState('');
const [loginSuccess, setLoginSuccess] = useState<StationLoginSuccess>();
const [loginFailure, setLoginFailure] = useState<Error>();
const [logoutSuccess, setLogoutSuccess] = useState<StationLogoutSuccess>();

const login = () => {
cc.stationLogin({teamId: team, loginOption: deviceType, dialNumber: dialNumber})
.then((res: StationLoginSuccess) => {
setLoginSuccess(res);
loginCb();
}).catch((error: Error) => {
console.error(error);
setLoginFailure(error);
});
};

const logout = () => {
cc.stationLogout({logoutReason: 'User requested logout'})
.then((res: StationLogoutSuccess) => {
setLogoutSuccess(res);
logoutCb();
}).catch((error: any) => {
console.error(error);
});
};

return {name: 'StationLogin', setDeviceType, setDialNumber, setTeam, login, logout, loginSuccess, loginFailure, logoutSuccess};
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ import {observer} from 'mobx-react';

import StationLoginPresentational from './station-login.presentational';
import {useStationLogin} from '../helper';
import { StationLoginProps } from './station-login.types';

const StationLogin: React.FunctionComponent = observer(() => {
const {loginState, setLoginState, ccSdk, isAvailable} = store;
const result = useStationLogin();
const StationLogin: React.FunctionComponent<StationLoginProps> = observer(({onLogin, onLogout}) => {
const {cc, teams, loginOptions} = store;
const result = useStationLogin({cc, onLogin, onLogout});

const props = {
...result,
loginState,
setLoginState,
ccSdk,
isAvailable,
teams,
loginOptions
};
return <StationLoginPresentational {...props} />;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,137 @@
import React from 'react';
import React, {useEffect} from 'react';
import {StationLoginPresentationalProps} from './station-login.types';

import {IStationLoginProps} from './station-login.types';
const StationLoginPresentational: React.FunctionComponent<StationLoginPresentationalProps> = (props) => {
const {name, teams, loginOptions, login, logout, setDeviceType, setDialNumber, setTeam} = props; // TODO: Use the loginSuccess, loginFailure, logoutSuccess props returned fromthe API response via helper file to reflect UI changes

useEffect(() => {
const teamsDropdown = document.getElementById('teamsDropdown') as HTMLSelectElement;
Comment thread
sreenara marked this conversation as resolved.
const agentLogin = document.querySelector('#LoginOption') as HTMLSelectElement;
const dialNumber = document.querySelector('#dialNumber') as HTMLInputElement;
if (teamsDropdown) {
teamsDropdown.innerHTML = '';
if (teams) {
teams.forEach((team) => {
const option = document.createElement('option');
option.value = team.id;
option.text = team.name;
teamsDropdown.add(option);
});
setTeam(teamsDropdown.value);
dialNumber.value = '';
dialNumber.disabled = true;
}
}
if (loginOptions.length > 0) {
loginOptions.forEach((options)=> {
const option = document.createElement('option');
option.text = options;
option.value = options;
agentLogin.add(option);
});
}
}, [teams, loginOptions]);

const selectLoginOption = (event: { target: { value: string; }; }) => {
const dialNumber = document.querySelector('#dialNumber') as HTMLInputElement;
const deviceType = event.target.value;
setDeviceType(deviceType);
if (deviceType === 'AGENT_DN' || deviceType === 'EXTENSION') {
dialNumber.disabled = false;
} else {
dialNumber.disabled = true;
}
};

function updateDN() {
const dialNumber = document.querySelector('#dialNumber') as HTMLInputElement;
setDialNumber(dialNumber.value);
}

const styles = {
box: {
backgroundColor: '#ffffff',
borderRadius: '8px',
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)',
padding: '20px',
maxWidth: '800px',
margin: '0 auto'
},

sectionBox: {
padding: '10px',
border: '1px solid #ddd',
borderRadius: '8px'
},

fieldset: {
border: '1px solid #ccc',
borderRadius: '5px',
padding: '10px',
marginBottom: '20px'
},

legendBox: {
fontWeight: 'bold',
color: '#0052bf'
},

btn: {
padding: '10px 20px',
backgroundColor: '#0052bf',
color: 'white',
border: 'none',
borderRadius: '4px',
cursor: 'pointer',
transition: 'background-color 0.3s',
marginRight: '8px'
},

select: {
width: '100%',
padding: '8px',
marginTop: '8px',
marginBottom: '12px',
border: '1px solid #ccc',
borderRadius: '4px'
},

input: {
width: '97%',
padding: '8px',
marginTop: '8px',
marginBottom: '12px',
border: '1px solid #ccc',
borderRadius: '4px'
}
}

const StationLoginPresentational: React.FunctionComponent<IStationLoginProps> = (props) => {
return (
<>
<h1 data-testid="station-login-heading">{props.name}</h1>
<h4>Station Login State: {props.loginState}</h4>
<button onClick={() => props.setLoginState('Logged In')}>Click to change state</button>
</>
<><h1 data-testid="station-login-heading">{name}</h1>
<div style={styles.box}>
<section style={styles.sectionBox}>
<fieldset style={styles.fieldset}>
<legend style={styles.legendBox}>Agent</legend>
<div style={{ display: 'flex', flexDirection: 'column', flexGrow: 1 }}>
<div style={{ display: 'flex', gap: '1rem' }}>
<fieldset style={{border: '1px solid #ccc', borderRadius: '5px', padding: '10px', marginBottom: '20px', flex: 0.69 }}>
<legend style={styles.legendBox}>Select Team</legend>
<select id="teamsDropdown" style={styles.select}>Teams</select>
</fieldset>
<fieldset style={styles.fieldset}>
<legend style={styles.legendBox}>Agent Login</legend>
<select name="LoginOption" id="LoginOption" style={styles.select} onChange={selectLoginOption}>
<option value="" selected hidden>Choose Agent Login Option...</option>
</select>
<input style={styles.input} id="dialNumber" name="dialNumber" placeholder="Extension/Dial Number" type="text" onInput={updateDN} />
<button id="AgentLogin" style={styles.btn} onClick={login}>Login</button>
<button id="logoutAgent" style={styles.btn} onClick={logout}>Logout</button>
</fieldset>
</div>
</div>
</fieldset>
</section>
</div></>
);
};

Expand Down
Loading