-
Notifications
You must be signed in to change notification settings - Fork 70
fix(store): direct-all-events-through-store #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
10ac925
8322a1e
ca6850a
25a3738
cf1ed99
7b8fbc0
3568747
3751062
6dfd0c8
102712c
d5a8034
dcfc0dc
1cdb349
c90a652
3eb367c
50fb2f5
bf2269c
e15e7e6
fae8bb0
5694f48
a9d6664
1a5b1c3
aabf6df
7ea2c7d
cf22511
991c9ca
671d8d4
f93e60e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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`, { | ||
|
|
@@ -64,7 +48,8 @@ export const useStationLogin = (props: UseStationLoginProps) => { | |
| .then((res: StationLoginSuccess) => { | ||
| setLoginSuccess(res); | ||
| setIsAgentLoggedIn(true); | ||
| store.setSelectedLoginOption(deviceType); | ||
| store.setDeviceType(deviceType); | ||
| store.setIsAgentLoggedIn(true); | ||
| if (res.data.auxCodeId) { | ||
| store.setCurrentState(res.data.auxCodeId); | ||
| } | ||
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe change this to selectedDeviceType and setSelectedDeviceType |
||
| if (logoutCb) { | ||
| logoutCb(); | ||
| } | ||
|
|
@@ -102,7 +89,7 @@ export const useStationLogin = (props: UseStationLoginProps) => { | |
| }; | ||
|
|
||
| function relogin() { | ||
| store.setSelectedLoginOption(deviceType); | ||
| store.setDeviceType(deviceType); | ||
| if (loginCb) { | ||
| loginCb(); | ||
| } | ||
|
|
@@ -119,7 +106,6 @@ export const useStationLogin = (props: UseStationLoginProps) => { | |
| loginSuccess, | ||
| loginFailure, | ||
| logoutSuccess, | ||
| showMultipleLoginAlert, | ||
| isAgentLoggedIn, | ||
| handleContinue, | ||
| }; | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 = { | ||
|
|
@@ -22,7 +23,7 @@ const StationLoginComponent: React.FunctionComponent<StationLoginProps> = ({onLo | |
| loginOptions, | ||
| deviceType, | ||
| }; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add showMultipleLoginAlert in the props object.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve button styles maintainability. Two issues found:
-#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
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed