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

Commit c228666

Browse files
authored
Merge branch 'dev' into feature/work-periods-part-2
2 parents 729841d + 2930211 commit c228666

File tree

10 files changed

+36
-40
lines changed

10 files changed

+36
-40
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: #ef476f;
77+
background: #efc847;
7878
}
7979

8080
.error {

src/constants/workPeriods.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,19 @@ export const SORT_BY_MAP = {
6565
};
6666

6767
export const PAYMENT_STATUS_LABELS = {
68-
[PAYMENT_STATUS.CANCELLED]: "Cancelled",
69-
[PAYMENT_STATUS.FAILED]: "Failed",
70-
[PAYMENT_STATUS.PAID]: "Paid",
68+
[PAYMENT_STATUS.NO_DAYS]: "No Days",
69+
[PAYMENT_STATUS.COMPLETED]: "Completed",
70+
[PAYMENT_STATUS.PARTIALLY_COMPLETED]: "Partially Completed",
7171
[PAYMENT_STATUS.PENDING]: "Pending",
7272
[PAYMENT_STATUS.IN_PROGRESS]: "In Progress",
73-
[PAYMENT_STATUS.UNDEFINED]: "NA",
7473
};
7574

7675
export const PAYMENT_STATUS_MAP = {
77-
[PAYMENT_STATUS.CANCELLED]: API_PAYMENT_STATUS.CANCELLED,
78-
[PAYMENT_STATUS.FAILED]: API_PAYMENT_STATUS.FAILED,
79-
[PAYMENT_STATUS.PAID]: API_PAYMENT_STATUS.COMPLETED,
76+
[PAYMENT_STATUS.NO_DAYS]: API_PAYMENT_STATUS.NO_DAYS,
77+
[PAYMENT_STATUS.COMPLETED]: API_PAYMENT_STATUS.COMPLETED,
78+
[PAYMENT_STATUS.PARTIALLY_COMPLETED]: API_PAYMENT_STATUS.PARTIALLY_COMPLETED,
8079
[PAYMENT_STATUS.PENDING]: API_PAYMENT_STATUS.PENDING,
81-
[PAYMENT_STATUS.IN_PROGRESS]: API_PAYMENT_STATUS.PARTIALLY_COMPLETED,
80+
[PAYMENT_STATUS.IN_PROGRESS]: API_PAYMENT_STATUS.IN_PROGRESS,
8281
};
8382

8483
export const API_PAYMENT_STATUS_MAP = (function () {
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";
5-
export const FAILED = "failed";
4+
export const NO_DAYS = "no-days";
5+
export const IN_PROGRESS = "in-progress";
+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

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
color: #fff;
1515
}
1616

17-
.paid {
17+
.completed {
1818
background: #0ab88a;
1919
}
2020

21-
.pending {
22-
background: #ef476f;
21+
.partially_completed {
22+
background: #efd047;
2323
}
2424

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

29-
.cancelled {
30-
background: #999;
29+
.no_days {
30+
background: #aaa;
3131
}
3232

33-
.failed {
34-
background: #da0000;
33+
.pending {
34+
background: #ef476f;
3535
}
3636

3737
.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/routes/WorkPeriods/components/ToastPaymentsWarning/index.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const ToastPaymentsWarning = ({
3333
</div>
3434
<div className={styles.sectionFailed}>
3535
<div className={styles.sectionTitle}>
36-
Failed to schedule payment for {resourcesFailedCount} resources:
36+
Failed to schedule payment for {resourcesFailedCount} resources
37+
{resourcesFailed && resourcesFailed.length ? ":" : ""}
3738
</div>
3839
{resourcesFailed && resourcesFailed.length && (
3940
<div className={styles.periodsFailed}>

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,
@@ -28,11 +27,7 @@ const initPagination = () => ({
2827

2928
const initFilters = () => ({
3029
dateRange: getWeekByDate(moment()),
31-
paymentStatuses: {
32-
[PAYMENT_STATUS.PAID]: true,
33-
[PAYMENT_STATUS.PENDING]: true,
34-
[PAYMENT_STATUS.IN_PROGRESS]: true,
35-
},
30+
paymentStatuses: {}, // all disabled by default
3631
userHandle: "",
3732
});
3833

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 = {};
@@ -99,7 +95,7 @@ export function normalizeDetailsPeriodItems(items) {
9995
}
10096

10197
export function normalizePaymentStatus(paymentStatus) {
102-
return API_PAYMENT_STATUS_MAP[paymentStatus] || PAYMENT_STATUS.UNDEFINED;
98+
return API_PAYMENT_STATUS_MAP[paymentStatus];
10399
}
104100

105101
export function sortByStartDate(itemA, itemB) {

0 commit comments

Comments
 (0)