pcm-shared-components 2.0.88 → 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,17 +18,16 @@ export const PricingCalendar = props => {
|
|
|
18
18
|
i18next,
|
|
19
19
|
startDate,
|
|
20
20
|
endDate,
|
|
21
|
-
|
|
21
|
+
rateObject,
|
|
22
22
|
RenderDay
|
|
23
23
|
} = props;
|
|
24
|
-
console.log('debug props', props);
|
|
25
24
|
const [month, setMonth] = useState(moment().toDate());
|
|
26
25
|
useEffect(() => {
|
|
27
26
|
setMonth(moment(startDate).toDate());
|
|
28
27
|
}, [startDate]);
|
|
29
28
|
const DefaultRenderDayComponent = ({
|
|
30
29
|
date,
|
|
31
|
-
|
|
30
|
+
foundRate
|
|
32
31
|
}) => {
|
|
33
32
|
let dayStyle;
|
|
34
33
|
if (date.getDay() === 6 || date.getDay() === 0) {
|
|
@@ -40,13 +39,13 @@ export const PricingCalendar = props => {
|
|
|
40
39
|
className: `flex flex-col justify-start h-full w-full ${dayStyle}`
|
|
41
40
|
}, /*#__PURE__*/React.createElement("div", {
|
|
42
41
|
className: `flex flex-row m-4 justify-between h-auto w-auto text-left font-800 text-14`
|
|
43
|
-
}, /*#__PURE__*/React.createElement("div", null, date.getDate())),
|
|
42
|
+
}, /*#__PURE__*/React.createElement("div", null, date.getDate())), foundRate && /*#__PURE__*/React.createElement("div", {
|
|
44
43
|
className: "w-full text-center my-auto text-1xl font-bold"
|
|
45
44
|
}, Intl.NumberFormat('en-US', {
|
|
46
45
|
style: 'currency',
|
|
47
46
|
currency: 'USD',
|
|
48
47
|
minimumFractionDigits: 0
|
|
49
|
-
}).format(
|
|
48
|
+
}).format(foundRate.rate)));
|
|
50
49
|
};
|
|
51
50
|
function findObjectByDate(objectArray, dateString) {
|
|
52
51
|
// Generated by AI and is much faster then using the .find method.
|
|
@@ -64,17 +63,17 @@ export const PricingCalendar = props => {
|
|
|
64
63
|
const handleDayRender = ({
|
|
65
64
|
date
|
|
66
65
|
}) => {
|
|
67
|
-
// const
|
|
68
|
-
const
|
|
69
|
-
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) {
|
|
70
69
|
return /*#__PURE__*/React.createElement(RenderDay, {
|
|
71
70
|
date: date,
|
|
72
|
-
|
|
71
|
+
foundRate: foundRate
|
|
73
72
|
});
|
|
74
73
|
} else {
|
|
75
74
|
return /*#__PURE__*/React.createElement(DefaultRenderDayComponent, {
|
|
76
75
|
date: date,
|
|
77
|
-
|
|
76
|
+
foundRate: foundRate ? foundRate : undefined
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
79
|
};
|
|
@@ -96,16 +95,16 @@ export const PricingCalendar = props => {
|
|
|
96
95
|
export default PricingCalendar;
|
|
97
96
|
PricingCalendar.defaultProps = {
|
|
98
97
|
RenderDay: undefined,
|
|
99
|
-
|
|
98
|
+
rateObject: [],
|
|
100
99
|
startDate: moment(),
|
|
101
100
|
endDate: moment().add(1, 'days'),
|
|
102
101
|
i18next: undefined
|
|
103
102
|
};
|
|
104
103
|
PricingCalendar.propTypes = {
|
|
105
|
-
/** 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*/
|
|
106
105
|
RenderDay: PropTypes.elementType,
|
|
107
|
-
/** The daily
|
|
108
|
-
|
|
106
|
+
/** The daily rate object */
|
|
107
|
+
rateObject: PropTypes.array,
|
|
109
108
|
/** The start date of the calendar */
|
|
110
109
|
startDate: PropTypes.instanceOf(Date),
|
|
111
110
|
/** The end date of the calendar */
|