-
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
Open
cmullenx
wants to merge
5
commits into
webex:next
Choose a base branch
from
cmullenx:chrmulle/campaignPrev
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
...ponents/src/components/task/CampaignTask/CampaignTaskListItem/campaign-task-list-item.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
61 changes: 61 additions & 0 deletions
61
...ts/src/components/task/CampaignTask/CampaignTaskListItem/campaign-task-list-item.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When
currentTaskchanges to a different interaction whose snapshot has nocallAssociatedData, this ref is not cleared because it only updates for non-empty arrays.GlobalVariablesPanelwill 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 byinteractionIdbefore preserving missing snapshots for the same task.Useful? React with 👍 / 👎.
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.
addressed