@tap-payments/os-micro-frontend-shared 0.0.188 → 0.0.189
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.
|
@@ -15,7 +15,7 @@ import ClickAwayListener from '@mui/material/ClickAwayListener';
|
|
|
15
15
|
import Popper from '@mui/material/Popper';
|
|
16
16
|
import { useTranslation } from 'react-i18next';
|
|
17
17
|
import { Calendar as MDPicker, DateObject } from 'react-multi-date-picker';
|
|
18
|
-
import TimePicker, { getDefaultHour, getDefaultMinute } from '../Timepicker';
|
|
18
|
+
import TimePicker, { getDefaultHour, getDefaultMinute, convertTo12Hour } from '../Timepicker';
|
|
19
19
|
import { darkLeftArrowIcon, darkRightArrowIcon } from '../../constants/index.js';
|
|
20
20
|
import { ArrowButton, CalenderWrapper, SelectedDate, Wrapper, ButtonsWrapper, CancelButton, OkayButton, FooterButtonsWrapper } from './style';
|
|
21
21
|
const weekDays = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
@@ -25,8 +25,8 @@ function Calender(_a) {
|
|
|
25
25
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
26
26
|
const [date, setDate] = useState(value ? new DateObject(new Date(value.toLocaleString())) : new DateObject(new Date()));
|
|
27
27
|
const [tempDate, setTempDate] = useState(value ? new DateObject(new Date(value.toLocaleString())) : new DateObject(new Date()));
|
|
28
|
-
const defaultHour = (value === null || value === void 0 ? void 0 : value.hour)
|
|
29
|
-
const [time, setTime] = useState({ hour: defaultHour
|
|
28
|
+
const defaultHour = (value === null || value === void 0 ? void 0 : value.hour) ? convertTo12Hour(value.hour) : getDefaultHour();
|
|
29
|
+
const [time, setTime] = useState({ hour: defaultHour, minute: (_b = value === null || value === void 0 ? void 0 : value.minute) !== null && _b !== void 0 ? _b : getDefaultMinute() });
|
|
30
30
|
const { t } = useTranslation();
|
|
31
31
|
const open = Boolean(anchorEl);
|
|
32
32
|
const getArrow = (direction) => {
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
export const convertTo12Hour = (hour24) => {
|
|
2
|
+
if (hour24 === 0)
|
|
3
|
+
return 12;
|
|
4
|
+
if (hour24 <= 12)
|
|
5
|
+
return hour24;
|
|
6
|
+
return hour24 - 12;
|
|
7
|
+
};
|
|
1
8
|
export const getDefaultMinute = () => new Date().getMinutes();
|
|
2
|
-
export const getDefaultHour = () =>
|
|
9
|
+
export const getDefaultHour = () => {
|
|
10
|
+
const currentHour = new Date().getHours();
|
|
11
|
+
return convertTo12Hour(currentHour);
|
|
12
|
+
};
|
package/package.json
CHANGED