Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit c05a8ef

Browse files
committed
Added more info into period's payments' popover.
1 parent 7179cc7 commit c05a8ef

File tree

11 files changed

+165
-61
lines changed

11 files changed

+165
-61
lines changed

src/constants/workPeriods.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ export const API_PAYMENT_STATUS_MAP = (function () {
9090
return obj;
9191
})();
9292

93+
export const API_CHALLENGE_PAYMENT_STATUS_MAP = {
94+
cancelled: PAYMENT_STATUS.CANCELLED,
95+
completed: PAYMENT_STATUS.COMPLETED,
96+
failed: PAYMENT_STATUS.FAILED,
97+
"in-progress": PAYMENT_STATUS.IN_PROGRESS,
98+
scheduled: PAYMENT_STATUS.SCHEDULED,
99+
};
100+
93101
export const JOB_NAME_LOADING = "Loading...";
94102
export const JOB_NAME_NONE = "<Job is not assigned>";
95103
export const JOB_NAME_ERROR = "<Error loading job>";

src/constants/workPeriods/paymentStatus.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ export const COMPLETED = "COMPLETED";
33
export const PENDING = "PENDING";
44
export const IN_PROGRESS = "IN_PROGRESS";
55
export const NO_DAYS = "NO_DAYS";
6+
export const SCHEDULED = "SCHEDULED";
7+
export const FAILED = "FAILED";
8+
export const CANCELLED = "CANCELLED";
9+
export const UNDEFINED = "UNDEFINED";

src/routes/WorkPeriods/components/PaymentStatus/styles.module.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
background: #efd047;
2323
}
2424

25-
.in_progress {
25+
.in_progress,
26+
.scheduled {
2627
background: #9d41c9;
2728
}
2829

30+
.cancelled,
2931
.no_days {
3032
background: #aaa;
3133
}
@@ -34,6 +36,10 @@
3436
background: #ef476f;
3537
}
3638

39+
.failed {
40+
background: #e90c5a;
41+
}
42+
3743
.undefined {
3844
padding: 0;
3945
@include roboto-regular;

src/routes/WorkPeriods/components/PaymentsListItem/index.jsx

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
/* eslint-disable jsx-a11y/no-static-element-interactions */
33
import React, { useCallback, useRef } from "react";
44
import PT from "prop-types";
5-
import cn from "classnames";
65
import styles from "./styles.module.scss";
7-
import { formatChallengeUrl } from "utils/formatters";
6+
import { currencyFormatter, formatChallengeUrl } from "utils/formatters";
7+
import PaymentStatus from "../PaymentStatus";
88

9-
const PaymentsListItem = ({ className, item }) => {
9+
const PaymentsListItem = ({ item }) => {
1010
const inputRef = useRef();
1111

1212
const onCopyLinkClick = useCallback(() => {
@@ -16,32 +16,50 @@ const PaymentsListItem = ({ className, item }) => {
1616
}, []);
1717

1818
return (
19-
<div className={cn(styles.container, className)}>
20-
<span className={styles.iconLink}></span>
21-
<input
22-
readOnly
23-
ref={inputRef}
24-
type="text"
25-
value={item.challengeId || "0"}
26-
/>
27-
<span className={styles.iconCopyLink} onClick={onCopyLinkClick}></span>
28-
<a
29-
className={styles.iconOpenLink}
30-
href={formatChallengeUrl(item.challengeId)}
31-
target="_blank"
32-
rel="noreferrer"
33-
>
34-
<span className={styles.hidden}>{item.id}</span>
35-
</a>
36-
</div>
19+
<tr>
20+
<td>
21+
<div className={styles.challengeId}>
22+
<span className={styles.iconLink}></span>
23+
<input
24+
readOnly
25+
ref={inputRef}
26+
type="text"
27+
value={item.challengeId || "0"}
28+
/>
29+
<span
30+
className={styles.iconCopyLink}
31+
onClick={onCopyLinkClick}
32+
></span>
33+
<a
34+
className={styles.iconOpenLink}
35+
href={formatChallengeUrl(item.challengeId)}
36+
target="_blank"
37+
rel="noreferrer"
38+
>
39+
<span className={styles.hidden}>{item.id}</span>
40+
</a>
41+
</div>
42+
</td>
43+
<td className={styles.weeklyRate}>
44+
{currencyFormatter.format(item.memberRate)}
45+
</td>
46+
<td className={styles.days}>{item.days}</td>
47+
<td className={styles.amount}>{currencyFormatter.format(item.amount)}</td>
48+
<td>
49+
<PaymentStatus status={item.status} />
50+
</td>
51+
</tr>
3752
);
3853
};
3954

4055
PaymentsListItem.propTypes = {
41-
className: PT.string,
4256
item: PT.shape({
43-
id: PT.oneOfType([PT.string, PT.number]),
57+
id: PT.oneOfType([PT.string, PT.number]).isRequired,
58+
amount: PT.number.isRequired,
4459
challengeId: PT.oneOfType([PT.string, PT.number]),
60+
days: PT.number.isRequired,
61+
memberRate: PT.number.isRequired,
62+
status: PT.string.isRequired,
4563
}),
4664
};
4765

src/routes/WorkPeriods/components/PaymentsListItem/styles.module.scss

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
@import "styles/mixins";
22

3-
.container {
4-
display: flex;
5-
align-items: center;
3+
.challengeId {
4+
display: inline-block;
65

76
input {
8-
display: block;
7+
display: inline-block;
98
margin: 0;
10-
border: none;
9+
border: none !important;
1110
padding: 0;
12-
max-width: 70px;
11+
width: 70px;
1312
height: 22px;
1413
background: #fff;
1514
@include roboto-medium;
1615
line-height: 22px;
16+
overflow: hidden;
17+
text-overflow: ellipsis;
18+
white-space: nowrap;
1719
outline: none !important;
20+
box-shadow: none !important;
21+
pointer-events: none;
1822
color: #0d61bf;
1923
}
2024
}
2125

2226
.iconLink {
23-
flex: 0 0 auto;
2427
display: inline-block;
28+
vertical-align: -2px;
2529
margin-right: 5px;
2630
width: 16px;
2731
height: 16px;
@@ -32,8 +36,8 @@
3236
}
3337

3438
.iconCopyLink {
35-
flex: 0 0 auto;
3639
display: inline-block;
40+
vertical-align: -2px;
3741
margin-left: 18px;
3842
width: 16px;
3943
height: 16px;
@@ -45,8 +49,8 @@
4549
}
4650

4751
.iconOpenLink {
48-
flex: 0 0 auto;
4952
display: inline-block;
53+
vertical-align: -2px;
5054
margin-left: 16px;
5155
width: 16px;
5256
height: 16px;
@@ -57,6 +61,12 @@
5761
background-image: url("./../../../../assets/images/icon-open-outside.png");
5862
}
5963

64+
.weeklyRate,
65+
.days,
66+
.amount {
67+
text-align: right;
68+
}
69+
6070
.hidden {
6171
display: none;
6272
}

src/routes/WorkPeriods/components/PaymentsPopup/index.jsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,23 @@ import PaymentsListItem from "../PaymentsListItem";
1313
const PaymentsPopup = ({ className, payments }) => {
1414
return (
1515
<form className={cn(styles.container, className)} action="#">
16-
<div className={styles.title}>Challenges for Payments</div>
17-
<div className={styles.paymentsList}>
18-
{payments.map((payment) => (
19-
<PaymentsListItem key={payment.id} item={payment} />
20-
))}
21-
</div>
16+
{/* <div className={styles.title}>Challenges for Payments</div> */}
17+
<table className={styles.paymentsList}>
18+
<thead>
19+
<tr>
20+
<th>Challenge ID</th>
21+
<th>Weekly Rate</th>
22+
<th>Days</th>
23+
<th>Amount</th>
24+
<th>Status</th>
25+
</tr>
26+
</thead>
27+
<tbody>
28+
{payments.map((payment) => (
29+
<PaymentsListItem key={payment.id} item={payment} />
30+
))}
31+
</tbody>
32+
</table>
2233
</form>
2334
);
2435
};

src/routes/WorkPeriods/components/PaymentsPopup/styles.module.scss

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.container {
44
position: relative;
55
border-radius: 8px;
6-
padding: 25px 30px 25px 23px;
6+
padding: 18px 25px;
77
box-shadow: 0 5px 35px 5px rgba(21, 21, 22, 0.1),
88
0 10px 14px 0 rgba(21, 21, 22, 0.3);
99
background: #fff;
@@ -15,6 +15,32 @@
1515
white-space: nowrap;
1616
}
1717

18-
.paymentsList {
18+
table.paymentsList {
1919
margin-top: 5px;
20+
21+
th {
22+
@include roboto-bold;
23+
padding: 10px 7px;
24+
font-size: 12px;
25+
line-height: 16px;
26+
white-space: nowrap;
27+
text-align: right;
28+
background: #f4f4f4;
29+
30+
&:first-child,
31+
&:last-child {
32+
text-align: left;
33+
}
34+
35+
&:first-child {
36+
padding-left: 28px;
37+
}
38+
}
39+
40+
tr {
41+
td {
42+
padding: 5px 7px;
43+
white-space: nowrap;
44+
}
45+
}
2046
}

src/routes/WorkPeriods/components/PeriodsHistoryItem/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const PeriodsHistoryItem = ({ isDisabled, item, data, currentStartDate }) => {
7474
<PaymentStatus status={data.paymentStatus} />
7575
</td>
7676
<td className={styles.daysWorked}>
77-
{data.paymentStatus === PAYMENT_STATUS.PAID ? (
77+
{data.paymentStatus === PAYMENT_STATUS.COMPLETED ? (
7878
`${daysWorked} ${daysWorked === 1 ? "Day" : "Days"}`
7979
) : (
8080
<IntegerField

src/routes/WorkPeriods/components/PeriodsHistoryPaymentTotal/index.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,19 @@ const PeriodsHistoryPaymentTotal = ({
4343

4444
return (
4545
<div className={cn(compStyles.container, className)} ref={containerRef}>
46-
<div
47-
className={cn(compStyles.paymentTotal, {
48-
[compStyles.hasPayments]: hasPayments,
49-
})}
50-
ref={setReferenceElement}
51-
onClick={onWeeklyRateClick}
52-
>
53-
<span className={compStyles.paymentTotalSum}>
54-
{currencyFormatter.format(paymentTotal)}
46+
<div className={compStyles.paymentTotal}>
47+
<span
48+
className={cn(compStyles.paymentTotalText, {
49+
[compStyles.hasPayments]: hasPayments,
50+
})}
51+
ref={setReferenceElement}
52+
onClick={onWeeklyRateClick}
53+
>
54+
<span className={compStyles.paymentTotalSum}>
55+
{currencyFormatter.format(paymentTotal)}
56+
</span>
57+
<span className={compStyles.daysPaid}> ({daysPaid})</span>
5558
</span>
56-
<span className={compStyles.daysPaid}> ({daysPaid})</span>
5759
</div>
5860
{hasPayments && isShowPopup && (
5961
<div
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@import "styles/variables";
2+
13
.container {
24
position: relative;
35

@@ -7,23 +9,25 @@
79
}
810

911
.paymentTotal {
12+
width: 90px;
13+
text-align: right;
1014
white-space: nowrap;
1115
}
1216

13-
.paymentTotalSum {
17+
.paymentTotalText {
1418
display: inline-block;
15-
width: 70px;
16-
text-align: right;
19+
line-height: 16px;
20+
21+
&.hasPayments {
22+
border-bottom: 1px dashed $text-color;
23+
cursor: pointer;
24+
}
1725
}
1826

1927
.daysPaid {
2028
color: #aaa;
2129
}
2230

23-
.hasPayments {
24-
cursor: pointer;
25-
}
26-
2731
.popup {
2832
z-index: 1;
2933
}

src/utils/workPeriods.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import moment from "moment";
2-
import { API_PAYMENT_STATUS_MAP, DATE_FORMAT_UI } from "constants/workPeriods";
2+
import {
3+
API_CHALLENGE_PAYMENT_STATUS_MAP,
4+
API_PAYMENT_STATUS_MAP,
5+
DATE_FORMAT_UI,
6+
PAYMENT_STATUS,
7+
} from "constants/workPeriods";
38

49
export function normalizePeriodItems(items) {
510
const empty = {};
@@ -81,11 +86,12 @@ export function createAssignedBillingAccountOption(accountId) {
8186
export function normalizeDetailsPeriodItems(items) {
8287
const periods = [];
8388
for (let item of items) {
89+
let payments = item.payments || [];
8490
periods.push({
8591
id: item.id,
8692
startDate: item.startDate ? moment(item.startDate).valueOf() : 0,
8793
endDate: item.endDate ? moment(item.endDate).valueOf() : 0,
88-
payments: item.payments || [],
94+
payments: payments.length ? normalizeDetailsPayments(payments) : payments,
8995
weeklyRate: item.memberRate,
9096
data: normalizePeriodData(item),
9197
});
@@ -94,6 +100,15 @@ export function normalizeDetailsPeriodItems(items) {
94100
return periods;
95101
}
96102

103+
function normalizeDetailsPayments(payments) {
104+
for (let payment of payments) {
105+
payment.status =
106+
API_CHALLENGE_PAYMENT_STATUS_MAP[payment.status] ||
107+
PAYMENT_STATUS.UNDEFINED;
108+
}
109+
return payments;
110+
}
111+
97112
export function normalizePaymentStatus(paymentStatus) {
98113
return API_PAYMENT_STATUS_MAP[paymentStatus];
99114
}

0 commit comments

Comments
 (0)