Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
10ac925
fix(store): direct-all-events-through-store
Shreyas281299 Jan 31, 2025
8322a1e
fix(store): fix-wrapup-required-not-re-rendering-issue
Shreyas281299 Feb 10, 2025
ca6850a
fix(store): add-unit-tests
Shreyas281299 Feb 10, 2025
25a3738
Merge remote-tracking branch 'upstream/ccwidgets' into store-wrapper
Shreyas281299 Feb 10, 2025
cf1ed99
fix(store): move-multilogin-userstate-event-to-store
Shreyas281299 Feb 11, 2025
7b8fbc0
fix(store): remove-console-logs
Shreyas281299 Feb 11, 2025
3568747
fix(store): remove-duplicate-properties
Shreyas281299 Feb 11, 2025
3751062
fix(store): fix-timer-issue-call-rona-issue
Shreyas281299 Feb 12, 2025
6dfd0c8
fix(store): add-tests
Shreyas281299 Feb 12, 2025
102712c
feat(cc): add task hydrate
rarajes2 Feb 12, 2025
d5a8034
fix(store): task-end-workaround-wrapuprequired
Shreyas281299 Feb 12, 2025
dcfc0dc
fix(store): add-tests
Shreyas281299 Feb 12, 2025
1cdb349
resolve conflicts
rarajes2 Feb 12, 2025
c90a652
disable end button on hold
rarajes2 Feb 12, 2025
3eb367c
fix(store): event-listener
Shreyas281299 Feb 14, 2025
50fb2f5
fix(store): move-setters-to-wrapper
Shreyas281299 Feb 14, 2025
bf2269c
fix(styles): remove-unecessary-formatting
Shreyas281299 Feb 14, 2025
e15e7e6
fix(store): change-event-name
Shreyas281299 Feb 14, 2025
fae8bb0
fix(store): add-UTs
Shreyas281299 Feb 14, 2025
5694f48
test(cc-store): fix failing UTs
rarajes2 Feb 14, 2025
a9d6664
Merge remote-tracking branch 'origin/store-wrapper' into store-wrappe…
Shreyas281299 Feb 14, 2025
1a5b1c3
fix(store): add-hydrate-event-for-tasks
Shreyas281299 Feb 14, 2025
aabf6df
fix(store): fix-unit-tests
Shreyas281299 Feb 14, 2025
7ea2c7d
fix(samples): add-wc-samples-changes
Shreyas281299 Feb 14, 2025
cf22511
fix(store): review-comments
Shreyas281299 Feb 14, 2025
991c9ca
Merge remote-tracking branch 'upstream/ccwidgets' into store-wrapper
Shreyas281299 Feb 14, 2025
671d8d4
fix(store): conflict-resolution
Shreyas281299 Feb 17, 2025
f93e60e
fix(station-login): fix-tests-after-conflicts
Shreyas281299 Feb 17, 2025
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
2 changes: 1 addition & 1 deletion packages/contact-center/station-login/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build": "yarn run -T tsc",
"build:src": "yarn run clean:dist && webpack",
"build:watch": "webpack --watch",
"test:unit": "jest"
"test:unit": "jest --coverage"
},
"dependencies": {
"@webex/cc-store": "workspace:*",
Expand Down
28 changes: 7 additions & 21 deletions packages/contact-center/station-login/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {useState, useEffect} from 'react';
import {StationLoginSuccess, StationLogoutSuccess} from '@webex/plugin-cc';
import {UseStationLoginProps} from './station-login/station-login.types';
import store from '@webex/cc-store'; // we need to import as we are losing the context of this in store
import {AGENT_MULTI_LOGIN} from './station-login/constants';

export const useStationLogin = (props: UseStationLoginProps) => {
const cc = props.cc;
Expand All @@ -11,34 +10,19 @@ export const useStationLogin = (props: UseStationLoginProps) => {
const logger = props.logger;
const [isAgentLoggedIn, setIsAgentLoggedIn] = useState(props.isAgentLoggedIn);
const [dialNumber, setDialNumber] = useState('');
const [deviceType, setDeviceType] = useState('');
const [deviceType, setDeviceType] = useState(props.deviceType || '');
const [team, setTeam] = useState('');
const [loginSuccess, setLoginSuccess] = useState<StationLoginSuccess>();
const [loginFailure, setLoginFailure] = useState<Error>();
const [logoutSuccess, setLogoutSuccess] = useState<StationLogoutSuccess>();
const [showMultipleLoginAlert, setShowMultipleLoginAlert] = useState(false);

useEffect(() => {
const handleMultiLoginCloseSession = (data) => {
if (data && typeof data === 'object' && data.type === 'AgentMultiLoginCloseSession') {
setShowMultipleLoginAlert(true);
}
};

cc.on(AGENT_MULTI_LOGIN, handleMultiLoginCloseSession);

return () => {
cc.off(AGENT_MULTI_LOGIN, handleMultiLoginCloseSession);
};
}, [cc]);

useEffect(() => {
setIsAgentLoggedIn(props.isAgentLoggedIn);
}, [props.isAgentLoggedIn]);

const handleContinue = async () => {
try {
setShowMultipleLoginAlert(false);
store.setShowMultipleLoginAlert(false);
await store.registerCC();
if (store.isAgentLoggedIn) {
logger.log(`Agent Relogin Success`, {
Expand All @@ -64,7 +48,8 @@ export const useStationLogin = (props: UseStationLoginProps) => {
.then((res: StationLoginSuccess) => {
setLoginSuccess(res);
setIsAgentLoggedIn(true);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if we can remove this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

store.setSelectedLoginOption(deviceType);
store.setDeviceType(deviceType);
store.setIsAgentLoggedIn(true);
if (res.data.auxCodeId) {
store.setCurrentState(res.data.auxCodeId);
}
Expand All @@ -89,6 +74,8 @@ export const useStationLogin = (props: UseStationLoginProps) => {
.then((res: StationLogoutSuccess) => {
setLogoutSuccess(res);
setIsAgentLoggedIn(false);
store.setIsAgentLoggedIn(false);
store.setDeviceType('');
Comment on lines +77 to +78

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need isAgentLoggedIn, if deviceType is available that means the agent is logged in

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change this to selectedDeviceType and setSelectedDeviceType

if (logoutCb) {
logoutCb();
}
Expand All @@ -102,7 +89,7 @@ export const useStationLogin = (props: UseStationLoginProps) => {
};

function relogin() {
store.setSelectedLoginOption(deviceType);
store.setDeviceType(deviceType);
if (loginCb) {
loginCb();
}
Expand All @@ -119,7 +106,6 @@ export const useStationLogin = (props: UseStationLoginProps) => {
loginSuccess,
loginFailure,
logoutSuccess,
showMultipleLoginAlert,
isAgentLoggedIn,
handleContinue,
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@ export const MULTIPLE_SIGN_IN_ALERT_MESSAGE =
'You are signed in to the Desktop in multiple application instances. Click Continue to proceed with the Desktop in this application instance. Else, close this window.';

export const MULTIPLE_SIGN_IN_ALERT_TITLE = 'Multiple Sign In Alert';

export const AGENT_MULTI_LOGIN = 'agent:multiLogin';
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import {useStationLogin} from '../helper';
import {StationLoginProps} from './station-login.types';

const StationLoginComponent: React.FunctionComponent<StationLoginProps> = ({onLogin, onLogout}) => {
const {cc, teams, loginOptions, logger, deviceType, isAgentLoggedIn} = store;
const {cc, teams, loginOptions, logger, isAgentLoggedIn, showMultipleLoginAlert, deviceType} = store;
const result = useStationLogin({
cc,
onLogin,
onLogout,
logger,
isAgentLoggedIn,
deviceType,
});

const props = {
Expand All @@ -22,7 +23,7 @@ const StationLoginComponent: React.FunctionComponent<StationLoginProps> = ({onLo
loginOptions,
deviceType,
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add showMultipleLoginAlert in the props object.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return <StationLoginPresentational {...props} />;
return <StationLoginPresentational {...props} showMultipleLoginAlert={showMultipleLoginAlert} />;
};

const StationLogin = observer(StationLoginComponent);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import React, { useEffect, useRef} from 'react';
import { StationLoginPresentationalProps } from './station-login.types';
import React, {useEffect, useRef} from 'react';
Comment thread
Shreyas281299 marked this conversation as resolved.
import {StationLoginPresentationalProps} from './station-login.types';
import './station-login.style.scss';
import { MULTIPLE_SIGN_IN_ALERT_MESSAGE, MULTIPLE_SIGN_IN_ALERT_TITLE } from './constants';
import './alert-modal.scss';
import {MULTIPLE_SIGN_IN_ALERT_MESSAGE, MULTIPLE_SIGN_IN_ALERT_TITLE} from './constants';

const StationLoginPresentational: React.FunctionComponent<StationLoginPresentationalProps> = (props) => {
const { name, teams, loginOptions, login, logout, relogin, setDeviceType, setDialNumber, setTeam, isAgentLoggedIn, deviceType, showMultipleLoginAlert, handleContinue} = props; // TODO: Use the loginSuccess, loginFailure, logoutSuccess props returned fromthe API response via helper file to reflect UI changes
const {
name,
teams,
loginOptions,
login,
logout,
relogin,
setDeviceType,
setDialNumber,
setTeam,
isAgentLoggedIn,
deviceType,
showMultipleLoginAlert,
handleContinue,
} = props; // TODO: Use the loginSuccess, loginFailure, logoutSuccess props returned fromthe API response via helper file to reflect UI changes
const modalRef = useRef<HTMLDialogElement>(null);

useEffect(() => {
Expand Down Expand Up @@ -33,6 +46,9 @@ const StationLoginPresentational: React.FunctionComponent<StationLoginPresentati
option.value = options;
agentLogin.add(option);
});
if (agentLogin && deviceType) {
agentLogin.value = deviceType;
}
}
}, [teams, loginOptions]);

Expand All @@ -53,8 +69,7 @@ const StationLoginPresentational: React.FunctionComponent<StationLoginPresentati
}
}, [isAgentLoggedIn]);

const selectLoginOption = (event: { target: { value: string } }) =>
{
const selectLoginOption = (event: {target: {value: string}}) => {
const dialNumber = document.querySelector('#dialNumber') as HTMLInputElement;
const deviceType = event.target.value;
setDeviceType(deviceType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,41 @@
border: 1px solid #ccc;
border-radius: 4px;
}


.modal {
width: 400px;
border: none;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
padding: 20px;
text-align: center;
}

.modal-content {
display: flex;
justify-content: flex-end; // Aligns the button to the right
}

.modal::backdrop {
background: rgba(0, 0, 0, 0.5);
}

h2 {
margin-top: 0;
}

#ContinueButton {
background-color: #0078d4;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
cursor: pointer;
}

#ContinueButton:hover {
background-color: #005a9e;
}
Comment on lines +80 to +93

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve button styles maintainability.

Two issues found:

  1. Using ID selectors makes styles less reusable
  2. The cursor property is duplicated (lines 86 and 88)
-#ContinueButton {
+.continue-button {
   background-color: #0078d4;
   color: white;
   border: none;
   padding: 10px 20px;
   border-radius: 5px;
   cursor: pointer;
   font-size: 16px;
-  cursor: pointer;
 }

-#ContinueButton:hover {
+.continue-button:hover {
   background-color: #005a9e;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#ContinueButton {
background-color: #0078d4;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
cursor: pointer;
}
#ContinueButton:hover {
background-color: #005a9e;
}
.continue-button {
background-color: #0078d4;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
.continue-button:hover {
background-color: #005a9e;
}

Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export type StationLoginPresentationalProps = Pick<

export type UseStationLoginProps = Pick<
IStationLoginProps,
'cc' | 'onLogin' | 'onLogout' | 'logger' | 'isAgentLoggedIn'
'cc' | 'onLogin' | 'onLogout' | 'logger' | 'isAgentLoggedIn' | 'deviceType'
>;

export type StationLoginProps = Pick<IStationLoginProps, 'onLogin' | 'onLogout'>;
Loading