pcm-shared-components 2.0.89 → 2.0.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,7 +18,7 @@ export const PricingCalendar = props => {
|
|
|
18
18
|
i18next,
|
|
19
19
|
startDate,
|
|
20
20
|
endDate,
|
|
21
|
-
|
|
21
|
+
rateObject,
|
|
22
22
|
RenderDay
|
|
23
23
|
} = props;
|
|
24
24
|
const [month, setMonth] = useState(moment().toDate());
|
|
@@ -27,7 +27,7 @@ export const PricingCalendar = props => {
|
|
|
27
27
|
}, [startDate]);
|
|
28
28
|
const DefaultRenderDayComponent = ({
|
|
29
29
|
date,
|
|
30
|
-
|
|
30
|
+
foundRate
|
|
31
31
|
}) => {
|
|
32
32
|
let dayStyle;
|
|
33
33
|
if (date.getDay() === 6 || date.getDay() === 0) {
|
|
@@ -39,13 +39,13 @@ export const PricingCalendar = props => {
|
|
|
39
39
|
className: `flex flex-col justify-start h-full w-full ${dayStyle}`
|
|
40
40
|
}, /*#__PURE__*/React.createElement("div", {
|
|
41
41
|
className: `flex flex-row m-4 justify-between h-auto w-auto text-left font-800 text-14`
|
|
42
|
-
}, /*#__PURE__*/React.createElement("div", null, date.getDate())),
|
|
42
|
+
}, /*#__PURE__*/React.createElement("div", null, date.getDate())), foundRate && /*#__PURE__*/React.createElement("div", {
|
|
43
43
|
className: "w-full text-center my-auto text-1xl font-bold"
|
|
44
44
|
}, Intl.NumberFormat('en-US', {
|
|
45
45
|
style: 'currency',
|
|
46
46
|
currency: 'USD',
|
|
47
47
|
minimumFractionDigits: 0
|
|
48
|
-
}).format(
|
|
48
|
+
}).format(foundRate.rate)));
|
|
49
49
|
};
|
|
50
50
|
function findObjectByDate(objectArray, dateString) {
|
|
51
51
|
// Generated by AI and is much faster then using the .find method.
|
|
@@ -63,17 +63,17 @@ export const PricingCalendar = props => {
|
|
|
63
63
|
const handleDayRender = ({
|
|
64
64
|
date
|
|
65
65
|
}) => {
|
|
66
|
-
// const
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
66
|
+
// const foundRate = rateObject.find((item)=> moment(date).isSame(item.date, "day") );
|
|
67
|
+
const foundRate = findObjectByDate(rateObject, moment(date).format('YYYY-MM-DD'));
|
|
68
|
+
if (foundRate && RenderDay) {
|
|
69
69
|
return /*#__PURE__*/React.createElement(RenderDay, {
|
|
70
70
|
date: date,
|
|
71
|
-
|
|
71
|
+
foundRate: foundRate
|
|
72
72
|
});
|
|
73
73
|
} else {
|
|
74
74
|
return /*#__PURE__*/React.createElement(DefaultRenderDayComponent, {
|
|
75
75
|
date: date,
|
|
76
|
-
|
|
76
|
+
foundRate: foundRate ? foundRate : undefined
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
};
|
|
@@ -95,16 +95,16 @@ export const PricingCalendar = props => {
|
|
|
95
95
|
export default PricingCalendar;
|
|
96
96
|
PricingCalendar.defaultProps = {
|
|
97
97
|
RenderDay: undefined,
|
|
98
|
-
|
|
98
|
+
rateObject: [],
|
|
99
99
|
startDate: moment(),
|
|
100
100
|
endDate: moment().add(1, 'days'),
|
|
101
101
|
i18next: undefined
|
|
102
102
|
};
|
|
103
103
|
PricingCalendar.propTypes = {
|
|
104
|
-
/** The component to render the day, receives one prop date and the
|
|
104
|
+
/** The component to render the day, receives one prop date and the rateObject if a match was found*/
|
|
105
105
|
RenderDay: PropTypes.elementType,
|
|
106
|
-
/** The daily
|
|
107
|
-
|
|
106
|
+
/** The daily rate object */
|
|
107
|
+
rateObject: PropTypes.array,
|
|
108
108
|
/** The start date of the calendar */
|
|
109
109
|
startDate: PropTypes.instanceOf(Date),
|
|
110
110
|
/** The end date of the calendar */
|