-
Notifications
You must be signed in to change notification settings - Fork 65
feat(cc): add campaign preview #684
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
base: next
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -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'; | ||
|
|
@@ -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 { | ||
|
|
@@ -23,6 +24,7 @@ import { | |
| QUEUE, | ||
| PHONE_NUMBER, | ||
| CUSTOMER_NAME, | ||
| CAMPAIGN_CALL, | ||
| } from '../constants'; | ||
| import {withMetrics} from '@webex/cc-ui-logging'; | ||
|
|
||
|
|
@@ -48,6 +50,7 @@ const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) => | |
| isMuted, | ||
| toggleMute, | ||
| conferenceParticipants, | ||
| isCampaignCall = false, | ||
| } = props; | ||
|
|
||
| const formatTime = (time: number): string => { | ||
|
|
@@ -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
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.
When Useful? React with 👍 / 👎.
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. addressed |
||
| const globalVariables = globalVariablesRef.current; | ||
|
|
||
| // Create unique IDs for tooltips | ||
| const customerNameTriggerId = `customer-name-trigger-${currentTask.data.interaction.interactionId}`; | ||
|
|
@@ -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}`} /> | ||
|
|
@@ -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 && ( | ||
| <> | ||
| {' '} | ||
|
|
@@ -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 || ''}`}> | ||
|
|
||
| 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; | ||
| } |
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.
Quick question — if all the CAD variables get legitimately cleared (empty array comes back from a valid task update), this ref will keep showing the old values since we only update when
length > 0. Is that intentional? If so maybe a quick comment saying why would be helpful for the next person reading this.