Skip to content

Commit

Permalink
feat: add generate data for score
Browse files Browse the repository at this point in the history
  • Loading branch information
guz86 committed Sep 25, 2024
1 parent c81da44 commit 796d5dd
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 16 deletions.
13 changes: 0 additions & 13 deletions app/src/components/AudioRow/AudioRow.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,3 @@
.row-call-image {
padding: 6px;
}

.row-score-element {
padding: 6px 8px;
border: 1px solid rgb(40, 168, 121);
border-radius: 4px;
background: rgb(219, 248, 239);
width: 70px;
color: rgb(0, 167, 117);
font-size: 14px;
font-weight: 400;
line-height: 100%;
text-align: left;
}
50 changes: 50 additions & 0 deletions app/src/components/TableRow/TableRow.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,53 @@
justify-content: flex-end;
width: 28.9%;
}

.row-score-element-green {
padding: 6px 8px;
border: 1px solid rgb(40, 168, 121);
border-radius: 4px;
background: rgb(219, 248, 239);
width: 70px;
color: rgb(0, 167, 117);
font-size: 14px;
font-weight: 400;
line-height: 100%;
text-align: left;
}

.row-score-element-yellow {
padding: 6px 8px;
border: 1px solid rgb(173, 191, 223);
border-radius: 4px;
background: rgb(216, 228, 251);
border-radius: 4px;
width: 66px;
color: rgb(18, 41, 69);
font-size: 14px;
font-weight: 400;
line-height: 100%;
text-align: left;
}

.row-score-element-red {
padding: 6px 8px;
border: 1px solid rgb(234, 26, 79);
border-radius: 4px;
background: rgb(254, 233, 239);
width: 56px;
font-size: 14px;
font-weight: 400;
line-height: 100%;
text-align: left;
color: rgb(234, 26, 79);
}

.row-score-element {
padding: 6px 8px;
color: rgb(234, 26, 79);
width: 200px;
font-size: 14px;
font-weight: 400;
line-height: 100%;
text-align: left;
}
21 changes: 20 additions & 1 deletion app/src/components/TableRow/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ const TableRow: React.FC<TableRowProps> = ({
}) => {
const [isHovered, setIsHovered] = useState(false);

const getScoreDetails = () => {
switch (score) {
case 'Excellent':
return { className: 'row-score-element-green', text: 'Отлично' };
case 'Good':
return { className: 'row-score-element-yellow', text: 'Хорошо' };
case 'Bad':
return { className: 'row-score-element-red', text: 'Плохо' };
case 'Not Used':
default:
return {
className: 'row-score-element',
text: 'Скрипт не использован',
};
}
};

const { className, text } = getScoreDetails();

return (
<div
className="row"
Expand All @@ -43,7 +62,7 @@ const TableRow: React.FC<TableRowProps> = ({
<div className="row-phone">{phone}</div>
<div className="row-source">{source}</div>
<div className="row-score">
<div className="row-score-element">{score}</div>
<div className={className}>{text}</div>
</div>
<div className="row-length">
<AudioRow
Expand Down
11 changes: 9 additions & 2 deletions app/src/utils/formatCalls.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Call } from './api';

const scores = ['Good', 'Excellent', 'Bad', 'Not Used'];
const sources = ['', 'Rabota.ru', 'Санкт-Петербург', 'Google', 'Yandex'];

export const formatCalls = (calls: Call[]) => {
return calls.map((call) => {
const time = call.date.split(' ')[1];
Expand All @@ -21,13 +24,17 @@ export const formatCalls = (calls: Call[]) => {
const callLength =
call.time > 0 ? `${formattedMinutes}:${formattedSeconds}` : '';

const score = scores[Math.floor(Math.random() * scores.length)];

const source = sources[Math.floor(Math.random() * sources.length)];

return {
typeImage,
time: `${hours}:${minutes}`,
avatar: call.person_avatar || 'https://lk.skilla.ru/img/noavatar.jpg',
phone: call.from_number,
source: call.source || '',
score: 'Отлично',
source,
score,
length: callLength,
record: call.record,
partnership_id: call.partnership_id,
Expand Down

0 comments on commit 796d5dd

Please sign in to comment.