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

Commit 4b30af8

Browse files
committed
fix: various improvements
- support new list of WP paymentStatus - change yellow color for warning Toastr - update label colors for payment status - fix getting all the Work Periods inside the history - don't select any status in the filter by default
1 parent 961b1a4 commit 4b30af8

File tree

9 files changed

+34
-36
lines changed

9 files changed

+34
-36
lines changed

src/components/ToastrMessage/styles.module.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
}
7575

7676
.warning {
77-
background: #efaf47;
77+
background: #efc847;
7878
}
7979

8080
.error {

src/constants/workPeriods.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,17 @@ export const SORT_BY_MAP = {
6262
};
6363

6464
export const PAYMENT_STATUS_LABELS = {
65-
[PAYMENT_STATUS.CANCELLED]: "Cancelled",
66-
[PAYMENT_STATUS.FAILED]: "Failed",
67-
[PAYMENT_STATUS.PAID]: "Paid",
65+
[PAYMENT_STATUS.NO_DAYS]: "No Days",
66+
[PAYMENT_STATUS.COMPLETED]: "Completed",
67+
[PAYMENT_STATUS.PARTIALLY_COMPLETED]: "Partially Completed",
6868
[PAYMENT_STATUS.PENDING]: "Pending",
6969
[PAYMENT_STATUS.IN_PROGRESS]: "In Progress",
70-
[PAYMENT_STATUS.UNDEFINED]: "NA",
7170
};
7271

7372
export const PAYMENT_STATUS_MAP = {
74-
[PAYMENT_STATUS.CANCELLED]: API_PAYMENT_STATUS.CANCELLED,
75-
[PAYMENT_STATUS.FAILED]: API_PAYMENT_STATUS.FAILED,
76-
[PAYMENT_STATUS.PAID]: API_PAYMENT_STATUS.COMPLETED,
73+
[PAYMENT_STATUS.NO_DAYS]: API_PAYMENT_STATUS.NO_DAYS,
74+
[PAYMENT_STATUS.COMPLETED]: API_PAYMENT_STATUS.COMPLETED,
75+
[PAYMENT_STATUS.PARTIALLY_COMPLETED]: API_PAYMENT_STATUS.PARTIALLY_COMPLETED,
7776
[PAYMENT_STATUS.PENDING]: API_PAYMENT_STATUS.PENDING,
7877
[PAYMENT_STATUS.IN_PROGRESS]: API_PAYMENT_STATUS.PARTIALLY_COMPLETED,
7978
};
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const PENDING = "pending";
22
export const PARTIALLY_COMPLETED = "partially-completed";
33
export const COMPLETED = "completed";
4-
export const CANCELLED = "cancelled";
4+
export const NO_DAYS = "no-days";
55
export const FAILED = "failed";
+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export const PAID = "PAID";
1+
export const PARTIALLY_COMPLETED = "PARTIALLY_COMPLETED";
2+
export const COMPLETED = "COMPLETED";
23
export const PENDING = "PENDING";
34
export const IN_PROGRESS = "IN_PROGRESS";
4-
export const CANCELLED = "CANCELLED";
5-
export const FAILED = "FAILED";
6-
export const UNDEFINED = "UNDEFINED";
5+
export const NO_DAYS = "NO_DAYS";

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@
1313
color: #fff;
1414
}
1515

16-
.paid {
16+
.completed {
1717
background: #0ab88a;
1818
}
1919

20-
.pending {
21-
background: #ef476f;
20+
.partially_completed {
21+
background: #ecef47;
2222
}
2323

2424
.in_progress {
2525
background: #9d41c9;
2626
}
2727

28-
.cancelled,
29-
.failed {
30-
background: #da0000;
28+
.no_days {
29+
background: #aaa;
30+
}
31+
32+
.pending {
33+
background: #ef476f;
3134
}
3235

3336
.undefined {

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,10 @@ PeriodFilters.propTypes = {
9797

9898
const PAYMENT_STATUS_OPTIONS = [
9999
{ value: PAYMENT_STATUS.PENDING, label: "Pending" },
100-
{ value: PAYMENT_STATUS.PAID, label: "Paid" },
100+
{ value: PAYMENT_STATUS.COMPLETED, label: "Completed" },
101+
{ value: PAYMENT_STATUS.PARTIALLY_COMPLETED, label: "Partially Completed" },
101102
{ value: PAYMENT_STATUS.IN_PROGRESS, label: "In Progress" },
102-
// { value: PAYMENT_STATUS.FAILED, label: "Failed" },
103+
{ value: PAYMENT_STATUS.NO_DAYS, label: "No Days" },
103104
];
104105

105106
export default PeriodFilters;

src/services/workPeriods.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,14 @@ export const fetchWorkPeriods = (rbId, source) => {
7676
}
7777
return [
7878
axios
79-
.get(`${WORK_PERIODS_API_URL}/?resourceBookingIds=${rbId}`, {
80-
cancelToken: source.token,
81-
})
79+
// sort by `startDate` just for comfort - so it's easier to check request in the Dev Tools
80+
// we get 10000 records to see all the records for now, but we have to improve this
81+
.get(
82+
`${WORK_PERIODS_API_URL}/?resourceBookingIds=${rbId}&sortBy=startDate&sortOrder=asc&perPage=10000`,
83+
{
84+
cancelToken: source.token,
85+
}
86+
)
8287
.then(extractResponseData),
8388
source,
8489
];

src/store/reducers/workPeriods.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import * as ACTION_TYPE from "store/actionTypes/workPeriods";
33
import {
44
SORT_BY_DEFAULT,
55
SORT_ORDER_DEFAULT,
6-
PAYMENT_STATUS,
76
JOB_NAME_ERROR,
87
BILLING_ACCOUNTS_NONE,
98
JOB_NAME_LOADING,
@@ -26,11 +25,7 @@ const initPagination = () => ({
2625

2726
const initFilters = () => ({
2827
dateRange: getWeekByDate(moment()),
29-
paymentStatuses: {
30-
[PAYMENT_STATUS.PAID]: true,
31-
[PAYMENT_STATUS.PENDING]: true,
32-
[PAYMENT_STATUS.IN_PROGRESS]: true,
33-
},
28+
paymentStatuses: {}, // all disabled by default
3429
userHandle: "",
3530
});
3631

src/utils/workPeriods.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import moment from "moment";
2-
import {
3-
API_PAYMENT_STATUS_MAP,
4-
DATE_FORMAT_UI,
5-
PAYMENT_STATUS,
6-
} from "constants/workPeriods";
2+
import { API_PAYMENT_STATUS_MAP, DATE_FORMAT_UI } from "constants/workPeriods";
73

84
export function normalizePeriodItems(items) {
95
const empty = {};
@@ -83,7 +79,7 @@ export function normalizeDetailsPeriodItems(items) {
8379
}
8480

8581
export function normalizePaymentStatus(paymentStatus) {
86-
return API_PAYMENT_STATUS_MAP[paymentStatus] || PAYMENT_STATUS.UNDEFINED;
82+
return API_PAYMENT_STATUS_MAP[paymentStatus];
8783
}
8884

8985
export function sortByStartDate(itemA, itemB) {

0 commit comments

Comments
 (0)