Use time format on event details
This commit is contained in:
parent
26c4b6629d
commit
53c1921a87
|
|
@ -34,6 +34,7 @@ import {
|
||||||
} from './eventStyle';
|
} from './eventStyle';
|
||||||
|
|
||||||
import api from 'services';
|
import api from 'services';
|
||||||
|
import { useSettingsStore } from 'stores';
|
||||||
|
|
||||||
import logo from 'res/logo.svg';
|
import logo from 'res/logo.svg';
|
||||||
import timezones from 'res/timezones.json';
|
import timezones from 'res/timezones.json';
|
||||||
|
|
@ -43,6 +44,8 @@ dayjs.extend(timezone);
|
||||||
dayjs.extend(customParseFormat);
|
dayjs.extend(customParseFormat);
|
||||||
|
|
||||||
const Event = (props) => {
|
const Event = (props) => {
|
||||||
|
const timeFormat = useSettingsStore(state => state.timeFormat);
|
||||||
|
|
||||||
const { register, handleSubmit } = useForm();
|
const { register, handleSubmit } = useForm();
|
||||||
const { id } = props.match.params;
|
const { id } = props.match.params;
|
||||||
const [timezone, setTimezone] = useState(Intl.DateTimeFormat().resolvedOptions().timeZone);
|
const [timezone, setTimezone] = useState(Intl.DateTimeFormat().resolvedOptions().timeZone);
|
||||||
|
|
@ -152,17 +155,17 @@ const Event = (props) => {
|
||||||
if (allTimes.length - 1 === i) return [
|
if (allTimes.length - 1 === i) return [
|
||||||
...labels,
|
...labels,
|
||||||
{ label: '', time },
|
{ label: '', time },
|
||||||
{ label: dayjs(time, 'HHmm').add(1, 'hour').format('h A'), time: null }
|
{ label: dayjs(time, 'HHmm').add(1, 'hour').format(timeFormat === '12h' ? 'h A' : 'HH'), time: null }
|
||||||
];
|
];
|
||||||
if (allTimes.length - 1 > i && parseInt(allTimes[i+1].substring(0, 2))-1 > parseInt(time.substring(0, 2))) return [
|
if (allTimes.length - 1 > i && parseInt(allTimes[i+1].substring(0, 2))-1 > parseInt(time.substring(0, 2))) return [
|
||||||
...labels,
|
...labels,
|
||||||
{ label: '', time },
|
{ label: '', time },
|
||||||
{ label: dayjs(time, 'HHmm').add(1, 'hour').format('h A'), time: 'space' },
|
{ label: dayjs(time, 'HHmm').add(1, 'hour').format(timeFormat === '12h' ? 'h A' : 'HH'), time: 'space' },
|
||||||
{ label: '', time: 'space' },
|
{ label: '', time: 'space' },
|
||||||
{ label: '', time: 'space' },
|
{ label: '', time: 'space' },
|
||||||
];
|
];
|
||||||
if (time.substring(2) !== '00') return [...labels, { label: '', time }];
|
if (time.substring(2) !== '00') return [...labels, { label: '', time }];
|
||||||
return [...labels, { label: dayjs(time, 'HHmm').format('h A'), time }];
|
return [...labels, { label: dayjs(time, 'HHmm').format(timeFormat === '12h' ? 'h A' : 'HH'), time }];
|
||||||
}, []));
|
}, []));
|
||||||
|
|
||||||
setDates(times.reduce((allDates, time) => {
|
setDates(times.reduce((allDates, time) => {
|
||||||
|
|
@ -172,7 +175,7 @@ const Event = (props) => {
|
||||||
return [...allDates, date];
|
return [...allDates, date];
|
||||||
}, []));
|
}, []));
|
||||||
}
|
}
|
||||||
}, [times]);
|
}, [times, timeFormat]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchUser = async () => {
|
const fetchUser = async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue