Skip to content

Commit

Permalink
fix: userstate issues, relogin fix (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkesavan13 authored Feb 21, 2025
1 parent 8f64885 commit 19256c0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ const UserStateComponent: React.FunctionComponent<Omit<IUserState, "setCurrentSt
color: 'black',
};

const getIcon = (name) => {
const getIcon = (name, iconColor='gray') => {
if (name === 'Available') {
return <CheckCircleOutlineIcon style={{ color: 'green' }} />;
} else if (name === 'RONA') {
return <RemoveCircleOutlineIcon style={{ color: 'red' }} />;
} else {
return <RemoveCircleOutlineIcon style={{ color: customState?.iconColor || 'gray' }} />;
return <RemoveCircleOutlineIcon style={{ color: iconColor }} />;
}
};

Expand All @@ -119,7 +121,7 @@ const UserStateComponent: React.FunctionComponent<Omit<IUserState, "setCurrentSt
const selectedCode = idleCodes?.find(code => code.id === selected) || (customState?.developerName === selected ? selectedState : null);
return (
<div className="selectedValueContainer">
{getIcon(selectedCode?.name)}
{getIcon(selectedCode?.name, selectedCode?.name === "RONA" ? "red" : selectedCode?.iconColor)}
<span style={{ marginLeft: '8px' }}>{selectedCode ? selectedCode.name : ''}</span>
<span className="timer">
{formatTime(elapsedTime)}
Expand All @@ -131,7 +133,7 @@ const UserStateComponent: React.FunctionComponent<Omit<IUserState, "setCurrentSt
>
{
customState?.developerName && (
<MenuItem key={customState?.developerName} value={customState?.developerName} hidden>{customState.name}</MenuItem>
<MenuItem style={{display: 'none'}} key={customState?.developerName} value={customState?.developerName} hidden>{customState.name}</MenuItem>
)
}
{idleCodes?.filter(code => !code.isSystem).map((code) => (
Expand Down
9 changes: 3 additions & 6 deletions packages/contact-center/station-login/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export const useStationLogin = (props: UseStationLoginProps) => {
if (res.data.lastStateChangeTimestamp) {
store.setLastStateChangeTimestamp(new Date(res.data.lastStateChangeTimestamp));
}
if (loginCb) {
loginCb();
}
})
.catch((error: Error) => {
logger.error(`Error logging in: ${error}`, {
Expand Down Expand Up @@ -91,9 +88,9 @@ export const useStationLogin = (props: UseStationLoginProps) => {

function relogin() {
store.setDeviceType(deviceType);
// if (loginCb) {
// loginCb();
// }
if (loginCb) {
loginCb();
}
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ const StationLoginPresentational: React.FunctionComponent<StationLoginPresentati
if (deviceType) {
relogin();
}
}, [isAgentLoggedIn, deviceType, relogin]);
}, [isAgentLoggedIn]);

const handleSelectLoginOption = (event: SelectChangeEvent<string>) => {
setDeviceType(event.target.value);
Expand Down
4 changes: 3 additions & 1 deletion packages/contact-center/store/src/storeEventsWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class StoreWrapper implements IStoreWrapper {
return this.store.logger;
}
get idleCodes() {
return this.store.idleCodes.filter((code) => !code.isSystem);
return this.store.idleCodes.filter((code) => {
return code.name === "RONA" || !code.isSystem;
});
}
get agentId() {
return this.store.agentId;
Expand Down
5 changes: 3 additions & 2 deletions packages/contact-center/user-state/src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const useUserState = ({idleCodes, agentId, cc, currentState, customState,
method: 'useEffect - currentState',
});

// Call setAgentStatus and update prevStateRef after promise resolves
// Call setAgentState and update prevStateRef after promise resolves
setAgentState(currentState).then(() => {
prevStateRef.current = currentState;
}).catch((error) => {
Expand All @@ -110,7 +110,8 @@ export const useUserState = ({idleCodes, agentId, cc, currentState, customState,
}, [customState, currentState]);

const setAgentStatus = (selectedCode) => {
store.setCurrentState(selectedCode);
selectedCode = idleCodes?.filter((code) => code.id === selectedCode)[0];
store.setState(selectedCode);
}

const setAgentState = (selectedCode) => {
Expand Down

0 comments on commit 19256c0

Please sign in to comment.