|
1 | 1 | import React from 'react';
|
2 | 2 | import {IncomingTaskPresentationalProps} from '../task.types';
|
3 |
| -import {ButtonPill} from '@momentum-ui/react-collaboration'; |
4 |
| - |
5 |
| -const styles: {[key: string]: React.CSSProperties} = { |
6 |
| - box: { |
7 |
| - backgroundColor: '#ffffff', |
8 |
| - borderRadius: '8px', |
9 |
| - boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)', |
10 |
| - padding: '20px', |
11 |
| - maxWidth: '800px', |
12 |
| - margin: '0 auto', |
13 |
| - }, |
14 |
| - sectionBox: { |
15 |
| - padding: '10px', |
16 |
| - border: '1px solid #ddd', |
17 |
| - borderRadius: '8px', |
18 |
| - marginBottom: '20px', |
19 |
| - }, |
20 |
| - fieldset: { |
21 |
| - border: '1px solid #ccc', |
22 |
| - borderRadius: '5px', |
23 |
| - padding: '10px', |
24 |
| - marginBottom: '20px', |
25 |
| - position: 'relative', |
26 |
| - }, |
27 |
| - legendBox: { |
28 |
| - fontWeight: 'bold', |
29 |
| - color: '#0052bf', |
30 |
| - }, |
31 |
| - container: { |
32 |
| - border: '1px solid #ccc', |
33 |
| - borderRadius: '8px', |
34 |
| - padding: '16px', |
35 |
| - width: '350px', |
36 |
| - boxShadow: '0px 4px 8px rgba(0, 0, 0, 0.2)', |
37 |
| - fontFamily: 'Arial, sans-serif', |
38 |
| - backgroundColor: '#ffffff', |
39 |
| - display: 'flex', |
40 |
| - flexDirection: 'column', |
41 |
| - }, |
42 |
| - topSection: { |
43 |
| - display: 'flex', |
44 |
| - justifyContent: 'space-between', |
45 |
| - alignItems: 'center', |
46 |
| - }, |
47 |
| - iconWrapper: { |
48 |
| - display: 'inline-block', |
49 |
| - backgroundColor: '#d4f8e8', |
50 |
| - borderRadius: '50%', |
51 |
| - width: '40px', |
52 |
| - height: '40px', |
53 |
| - justifyContent: 'center', |
54 |
| - alignItems: 'center', |
55 |
| - marginRight: '10px', |
56 |
| - }, |
57 |
| - iconSvg: { |
58 |
| - width: '24px', |
59 |
| - height: '24px', |
60 |
| - color: '#146f5c', |
61 |
| - }, |
62 |
| - callInfo: { |
63 |
| - margin: 0, |
64 |
| - fontSize: '1.2em', |
65 |
| - color: '#333', |
66 |
| - }, |
67 |
| - aniText: { |
68 |
| - fontSize: '1.1em', |
69 |
| - fontWeight: 'bold', |
70 |
| - margin: '4px 0', |
71 |
| - color: '#146f5c', |
72 |
| - }, |
73 |
| - buttonsWrapper: { |
74 |
| - display: 'flex', |
75 |
| - flexDirection: 'column', |
76 |
| - alignItems: 'flex-end', |
77 |
| - marginLeft: '16px', |
78 |
| - }, |
79 |
| - answerButton: { |
80 |
| - padding: '8px 16px', |
81 |
| - border: 'none', |
82 |
| - borderRadius: '6px', |
83 |
| - fontSize: '0.9em', |
84 |
| - cursor: 'pointer', |
85 |
| - fontWeight: 'bold', |
86 |
| - backgroundColor: '#28a745', |
87 |
| - color: '#fff', |
88 |
| - marginBottom: '8px', |
89 |
| - }, |
90 |
| - declineButton: { |
91 |
| - padding: '8px 16px', |
92 |
| - border: 'none', |
93 |
| - borderRadius: '6px', |
94 |
| - fontSize: '0.9em', |
95 |
| - cursor: 'pointer', |
96 |
| - fontWeight: 'bold', |
97 |
| - backgroundColor: '#dc3545', |
98 |
| - color: '#fff', |
99 |
| - }, |
100 |
| - queueInfo: { |
101 |
| - fontSize: '0.9em', |
102 |
| - color: '#666', |
103 |
| - marginTop: '8px', |
104 |
| - }, |
105 |
| - timeElapsed: { |
106 |
| - color: '#28a745', |
107 |
| - fontWeight: 'bold', |
108 |
| - }, |
109 |
| - callDetails: { |
110 |
| - marginTop: '16px', |
111 |
| - fontSize: '0.9em', |
112 |
| - color: '#333', |
113 |
| - }, |
114 |
| - detailItem: { |
115 |
| - margin: '4px 0', |
116 |
| - }, |
117 |
| - detailLabel: { |
118 |
| - color: '#555', |
119 |
| - fontWeight: 'bold', |
120 |
| - }, |
121 |
| -}; |
| 3 | +import Task from '../Task'; |
122 | 4 |
|
123 | 5 | const IncomingTaskPresentational: React.FunctionComponent<IncomingTaskPresentationalProps> = (props) => {
|
124 | 6 | const {incomingTask, accept, decline, isBrowser} = props;
|
125 | 7 | if (!incomingTask) {
|
126 | 8 | return <></>; // hidden component
|
127 | 9 | }
|
128 | 10 |
|
129 |
| - const callAssociationDetails = incomingTask.data.interaction.callAssociatedDetails; |
130 |
| - const {ani, dn, virtualTeamName} = callAssociationDetails; |
131 |
| - const timeElapsed = ''; // TODO: Calculate time elapsed |
132 |
| - |
| 11 | + const callAssociationDetails = incomingTask?.data?.interaction?.callAssociatedDetails; |
| 12 | + const ani = callAssociationDetails?.ani; |
| 13 | + const virtualTeamName = callAssociationDetails?.virtualTeamName; |
| 14 | + // rona timeout is not always available in the callAssociatedDetails object |
| 15 | + const ronaTimeout = callAssociationDetails?.ronaTimeout ? Number(callAssociationDetails?.ronaTimeout) : null; |
| 16 | + const startTimeStamp = incomingTask?.data?.interaction?.createdTimestamp; |
133 | 17 | return (
|
134 |
| - <div style={styles.box}> |
135 |
| - <section style={styles.sectionBox}> |
136 |
| - <fieldset style={styles.fieldset}> |
137 |
| - <legend style={styles.legendBox}>Incoming Task</legend> |
138 |
| - <div data-testid="incoming-task-presentational" style={styles.container}> |
139 |
| - {/* Top Section - Call Info with Phone Icon */} |
140 |
| - <div style={styles.topSection}> |
141 |
| - <div style={{display: 'flex', alignItems: 'center'}}> |
142 |
| - <span style={styles.iconWrapper}> |
143 |
| - <svg |
144 |
| - xmlns="http://www.w3.org/2000/svg" |
145 |
| - viewBox="0 0 24 24" |
146 |
| - fill="none" |
147 |
| - stroke="currentColor" |
148 |
| - strokeWidth="2" |
149 |
| - strokeLinecap="round" |
150 |
| - strokeLinejoin="round" |
151 |
| - style={styles.iconSvg} |
152 |
| - > |
153 |
| - <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.86 19.86 0 0 1-8.63-2.73 19.5 19.5 0 0 1-6-6A19.86 19.86 0 0 1 3.08 4.18 2 2 0 0 1 5 2h3a2 2 0 0 1 2 1.72c.2 1.52.71 2.94 1.41 4.24a2 2 0 0 1-.45 2.31L9.91 11a16 16 0 0 0 6 6l1.73-1.05a2 2 0 0 1 2.31-.45 16.11 16.11 0 0 0 4.24 1.41A2 2 0 0 1 22 16.92z"></path> |
154 |
| - </svg> |
155 |
| - </span> |
156 |
| - <div> |
157 |
| - <h2 style={styles.callInfo}>Incoming Call</h2> |
158 |
| - <p data-testid="incoming-task-ani" style={styles.aniText}> |
159 |
| - {ani} |
160 |
| - </p> |
161 |
| - </div> |
162 |
| - </div> |
163 |
| - |
164 |
| - {isBrowser && ( |
165 |
| - <div style={styles.buttonsWrapper}> |
166 |
| - <ButtonPill style={styles.answerButton} onPress={accept}> |
167 |
| - Answer |
168 |
| - </ButtonPill> |
169 |
| - <ButtonPill style={styles.declineButton} onPress={decline}> |
170 |
| - Decline |
171 |
| - </ButtonPill> |
172 |
| - </div> |
173 |
| - )} |
174 |
| - </div> |
175 |
| - |
176 |
| - {/* Queue and Timer Info */} |
177 |
| - <p style={styles.queueInfo}> |
178 |
| - {virtualTeamName} - <span style={styles.timeElapsed}>{timeElapsed}</span> |
179 |
| - </p> |
180 |
| - |
181 |
| - {/* Call Details Section */} |
182 |
| - <div style={styles.callDetails}> |
183 |
| - <p style={styles.detailItem}> |
184 |
| - <strong style={styles.detailLabel}>Phone Number:</strong> {ani} |
185 |
| - </p> |
186 |
| - <p style={styles.detailItem}> |
187 |
| - <strong style={styles.detailLabel}>DNIS:</strong> {dn} |
188 |
| - </p> |
189 |
| - <p style={styles.detailItem}> |
190 |
| - <strong style={styles.detailLabel}>Queue Name:</strong> {virtualTeamName} |
191 |
| - </p> |
192 |
| - </div> |
193 |
| - </div> |
194 |
| - </fieldset> |
195 |
| - </section> |
196 |
| - </div> |
| 18 | + <Task |
| 19 | + title={ani} |
| 20 | + queue={virtualTeamName} |
| 21 | + isIncomingTask={true} |
| 22 | + isBrowser={isBrowser} |
| 23 | + acceptTask={accept} |
| 24 | + declineTask={decline} |
| 25 | + ronaTimeout={ronaTimeout} |
| 26 | + startTimeStamp={startTimeStamp} |
| 27 | + /> |
197 | 28 | );
|
198 | 29 | };
|
199 | 30 |
|
|
0 commit comments