Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,8 @@
}
}

.global-variables {
display: flex;
flex-flow: row wrap;
justify-content: space-between;
width: 100%;
max-height: 11.25rem;
overflow-y: auto;
margin-top: 0.75rem;

.global-variable-item {
flex-basis: 50%;
min-width: 0;
box-sizing: border-box;
padding: 0.125rem 0;
line-height: 1.75rem;
}
.cad-global-variables {
margin-top: 0.5rem;
}

/* On-hold chip styling */
Expand Down Expand Up @@ -192,6 +178,11 @@
.media-icon.chat {
color: var(--mds-color-theme-indicator-secure);
}

.campaign-call-avatar {
--mdc-avatar-default-background-color: var(--mds-color-theme-avatar-campaign);
--mdc-avatar-default-foreground-color: var(--mds-color-theme-indicator-stable);
}
}
.call-control-task-tooltip::part(popover-content) {
white-space: normal;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import React, {useRef} from 'react';
import CallControlComponent from '../CallControl/call-control';
import {Text, PopoverNext} from '@momentum-ui/react-collaboration';
import {Brandvisual, Icon, Tooltip, Button} from '@momentum-design/components/dist/react';
import {Avatar, Brandvisual, Icon, Tooltip, Button} from '@momentum-design/components/dist/react';
import './call-control-cad.styles.scss';
import TaskTimer from '../TaskTimer/index';
import CallControlConsultComponent from '../CallControl/CallControlCustom/call-control-consult';
Expand All @@ -12,6 +12,7 @@ import {
CallAssociatedDataMap,
} from '../task.types';
import {getAgentViewableGlobalVariables} from '../Task/task.utils';
import GlobalVariablesPanel from '../GlobalVariablesPanel/global-variables-panel';

import {getMediaTypeInfo} from '../../../utils';
import {
Expand All @@ -23,6 +24,7 @@ import {
QUEUE,
PHONE_NUMBER,
CUSTOMER_NAME,
CAMPAIGN_CALL,
} from '../constants';
import {withMetrics} from '@webex/cc-ui-logging';

Expand All @@ -48,6 +50,7 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) =>
isMuted,
toggleMute,
conferenceParticipants,
isCampaignCall = false,
} = props;

const formatTime = (time: number): string => {
Expand Down Expand Up @@ -77,7 +80,22 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) =>

//@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
const callAssociatedData = currentTask?.data?.interaction?.callAssociatedData as CallAssociatedDataMap | undefined;
const globalVariables = getAgentViewableGlobalVariables(callAssociatedData);
const latestGlobalVariables = getAgentViewableGlobalVariables(callAssociatedData);

// Persist global variables across task updates — some store refreshes
// replace currentTask with a snapshot that omits callAssociatedData.
// Reset when the interaction changes so stale CAD from a previous task
// is never shown on a new call.
const interactionId = currentTask.data.interaction.interactionId;
const globalVariablesRef = useRef(latestGlobalVariables);
const prevInteractionIdRef = useRef(interactionId);
if (prevInteractionIdRef.current !== interactionId) {
prevInteractionIdRef.current = interactionId;
globalVariablesRef.current = latestGlobalVariables;
} else if (latestGlobalVariables.length > 0) {
globalVariablesRef.current = latestGlobalVariables;
}
Comment on lines +90 to +97
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reset CAD variables when task changes

When currentTask changes to a different interaction whose snapshot has no callAssociatedData, this ref is not cleared because it only updates for non-empty arrays. GlobalVariablesPanel will then keep rendering the previous task's global variables, which can show stale or wrong customer CAD on the next call; key/reset the ref by interactionId before preserving missing snapshots for the same task.

Useful? React with 👍 / 👎.

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.

addressed

const globalVariables = globalVariablesRef.current;

// Create unique IDs for tooltips
const customerNameTriggerId = `customer-name-trigger-${currentTask.data.interaction.interactionId}`;
Expand Down Expand Up @@ -178,7 +196,9 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) =>
{/* Caller Information */}
<div className="caller-info">
<div className="call-icon-background">
{currentMediaType.isBrandVisual ? (
{isCampaignCall ? (
<Avatar icon-name="campaign-management-bold" className="campaign-call-avatar" />
) : currentMediaType.isBrandVisual ? (
<Brandvisual name={currentMediaType.iconName} className={`media-icon ${currentMediaType.className}`} />
) : (
<Icon name={currentMediaType.iconName} size={1} className={`media-icon ${currentMediaType.className}`} />
Expand All @@ -190,7 +210,8 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) =>
<div className="call-details">
<div className="call-details-row">
<Text className="call-timer" type="body-secondary" tagName={'small'} data-testid="cc-cad:call-timer">
{currentMediaType.labelName} - <TaskTimer startTimeStamp={startTimestamp} />
{isCampaignCall ? CAMPAIGN_CALL : currentMediaType.labelName} -{' '}
<TaskTimer startTimeStamp={startTimestamp} />
{stateTimerLabel && stateTimerTimestamp && (
<>
{' '}
Expand Down Expand Up @@ -285,24 +306,7 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) =>
</Text>
{renderPhoneNumber()}
</div>
{globalVariables.length > 0 && (
<div className="global-variables" data-testid="cc-cad:global-variables">
{globalVariables.map((variable) => (
<div
key={variable.name}
className="global-variable-item"
data-testid={`cc-cad:global-var-${variable.name}`}
>
<Text type="body-secondary" tagName={'small'}>
{variable.displayName || variable.name}
</Text>
<Text type="body-secondary" tagName={'small'}>
{variable.value || ''}
</Text>
</div>
))}
</div>
)}
<GlobalVariablesPanel variables={globalVariables} className="cad-global-variables" />
</div>
{controlVisibility.isConsultInitiatedOrAccepted && !controlVisibility.wrapup.isVisible && (
<div className={`call-control-consult-container ${callControlConsultClassName || ''}`}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type CampaignErrorType = 'ACCEPT_FAILED' | 'SKIP_FAILED' | 'REMOVE_FAILED';
export type CampaignErrorType = 'ACCEPT_FAILED' | 'SKIP_FAILED' | 'REMOVE_FAILED' | 'CANCEL_FAILED';

export interface CampaignErrorDialogProps {
errorType: CampaignErrorType;
Expand All @@ -10,6 +10,7 @@ export const ERROR_TITLES: Record<CampaignErrorType, string> = {
ACCEPT_FAILED: "Can't accept contact",
SKIP_FAILED: "Can't skip contact",
REMOVE_FAILED: "Can't remove contact",
CANCEL_FAILED: "Can't cancel contact",
};

export const ERROR_MESSAGE =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import React from 'react';
import {Avatar, Button, ListItem, Text, Tooltip} from '@momentum-design/components/dist/react';
import CampaignCountdown from '../../CampaignCountdown/campaign-countdown';
import TaskTimer from '../../TaskTimer/index';
import {CampaignTaskListItemProps} from './campaign-task-list-item.types';
import {
CAMPAIGN_ACCEPT,
CAMPAIGN_CONNECTING,
CAMPAIGN_SKIP,
CAMPAIGN_SKIP_TOOLTIP,
CAMPAIGN_SKIP_DISABLED_TOOLTIP,
CAMPAIGN_REMOVE,
CAMPAIGN_REMOVE_TOOLTIP,
CAMPAIGN_REMOVE_DISABLED_TOOLTIP,
CAMPAIGN_ACTIONS_LABEL,
HANDLE_TIME,
} from '../../constants';

/**
* CampaignTaskListItem renders the ListItem row shared between the
* CampaignTask inline card and the CampaignTaskPopover.
*
* Layout: Avatar | Title / Phone / Countdown | Accept + Skip/Remove buttons
*/
const CampaignTaskListItem: React.FC<CampaignTaskListItemProps> = ({
title,
phoneNumber,
customerName,
timeoutTimestamp,
isAcceptClicked,
isAccepted,
isAcceptDisabled,
isSkipDisabled,
isRemoveDisabled,
onAccept,
onSkip,
onRemove,
onTimeout,
handleTimestamp,
logger,
className,
testIdPrefix = 'campaign-task',
}) => {
const skipTooltipText = isSkipDisabled ? CAMPAIGN_SKIP_DISABLED_TOOLTIP : CAMPAIGN_SKIP_TOOLTIP;
const removeTooltipText = isRemoveDisabled ? CAMPAIGN_REMOVE_DISABLED_TOOLTIP : CAMPAIGN_REMOVE_TOOLTIP;
const skipButtonId = `${testIdPrefix}-skip-btn`;
const removeButtonId = `${testIdPrefix}-remove-btn`;

return (
<ListItem className={className} data-testid={`${testIdPrefix}-list-item`}>
<Avatar slot="leading-controls" icon-name="campaign-management-bold" className="campaign-avatar" />

<Text slot="leading-text-primary-label" type="body-large-medium" data-testid={`${testIdPrefix}-title`}>
{title}
</Text>
{customerName && phoneNumber && phoneNumber !== customerName && (
<Text slot="leading-text-secondary-label" type="body-midsize-regular" data-testid={`${testIdPrefix}-phone`}>
{phoneNumber}
</Text>
)}
{!isAccepted && timeoutTimestamp && (
<div slot="leading-text-tertiary-label">
<CampaignCountdown timeoutTimestamp={timeoutTimestamp} onTimeout={onTimeout} logger={logger} />
</div>
)}
{isAccepted && handleTimestamp && (
<Text
slot="leading-text-tertiary-label"
tagname="span"
type="body-midsize-regular"
className="campaign-task-handle-time"
data-testid={`${testIdPrefix}-handle-time`}
>
{HANDLE_TIME} <TaskTimer startTimeStamp={handleTimestamp} />
</Text>
)}

{!isAccepted && (
<div
slot="trailing-controls"
className="campaign-task-actions"
aria-label={CAMPAIGN_ACTIONS_LABEL}
data-testid={`${testIdPrefix}-actions`}
>
{!isAcceptClicked ? (
<Button
variant="primary"
color="positive"
size={28}
onClick={onAccept}
disabled={isAcceptDisabled}
aria-label={CAMPAIGN_ACCEPT}
data-testid={`${testIdPrefix}-accept-button`}
>
{CAMPAIGN_ACCEPT}
</Button>
) : (
<Button
variant="secondary"
size={28}
disabled
aria-label={CAMPAIGN_CONNECTING}
data-testid={`${testIdPrefix}-connecting-button`}
>
{CAMPAIGN_CONNECTING}
</Button>
)}

<div
className="campaign-task-skip-remove"
role="group"
aria-label={`${CAMPAIGN_SKIP} and ${CAMPAIGN_REMOVE}`}
data-testid={`${testIdPrefix}-skip-remove`}
>
<Button
id={skipButtonId}
variant="secondary"
size={28}
prefixIcon="skip-bold"
onClick={onSkip}
disabled={isSkipDisabled}
aria-label={CAMPAIGN_SKIP}
data-testid={`${testIdPrefix}-skip-button`}
/>
<Tooltip triggerID={skipButtonId} placement="bottom" tooltipType="label">
{skipTooltipText}
</Tooltip>

<Button
id={removeButtonId}
variant="secondary"
size={28}
prefixIcon="remove-bold"
onClick={onRemove}
disabled={isRemoveDisabled}
aria-label={CAMPAIGN_REMOVE}
data-testid={`${testIdPrefix}-remove-button`}
/>
<Tooltip triggerID={removeButtonId} placement="bottom" tooltipType="label">
{removeTooltipText}
</Tooltip>
</div>
</div>
)}
</ListItem>
);
};

export default CampaignTaskListItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {ILogger} from '@webex/cc-store';

/**
* Properties for the CampaignTaskListItem component.
*
* Renders the ListItem row shared between the CampaignTask card
* and CampaignTaskPopover: avatar, title, phone, countdown, and
* Accept / Skip / Remove action buttons.
*/
export interface CampaignTaskListItemProps {
/** Display title (customer name or caller identifier). */
title: string;

/** Phone number to show as secondary label. */
phoneNumber?: string;

/** Customer name — used to decide whether to show phone as secondary label. */
customerName?: string;

/** Campaign preview offer timeout timestamp (ms string). */
timeoutTimestamp?: string;

/** Whether the Accept button has been clicked (shows "Connecting..." state). */
isAcceptClicked: boolean;

/** Whether the campaign preview has been accepted by the backend (call controls visible). */
isAccepted: boolean;

/** Whether the Accept button is disabled. */
isAcceptDisabled: boolean;

/** Whether the Skip button is disabled. */
isSkipDisabled: boolean;

/** Whether the Remove button is disabled. */
isRemoveDisabled: boolean;

/** Handler for Accept button click. */
onAccept: () => void;

/** Handler for Skip button click. */
onSkip: () => void;

/** Handler for Remove button click. */
onRemove: () => void;

/** Handler for countdown timeout. */
onTimeout: () => void;

/** Timestamp (ms) when the campaign call was accepted — used for the handle time timer. */
handleTimestamp?: number;

/** Logger instance. */
logger?: ILogger;

/** Optional CSS class name applied to the ListItem. */
className?: string;

/** Optional test ID prefix for data-testid attributes. */
testIdPrefix?: string;
}
Loading
Loading