feature/IO-2979-DST - Finish DST Stuff
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -4,19 +4,37 @@ import React, { useCallback, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import dayjs from "../../utils/day";
|
import dayjs from "../../utils/day";
|
||||||
import { fuzzyMatchDate } from "./formats.js";
|
import { fuzzyMatchDate } from "./formats.js";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { selectBodyshop } from "../../redux/user/user.selectors.js";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
const DateTimePicker = ({ value, onChange, onBlur, id, onlyFuture, onlyToday, isDateOnly = false, ...restProps }) => {
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
bodyshop: selectBodyshop
|
||||||
|
});
|
||||||
|
|
||||||
|
const DateTimePicker = ({
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
onBlur,
|
||||||
|
id,
|
||||||
|
onlyFuture,
|
||||||
|
onlyToday,
|
||||||
|
isDateOnly = false,
|
||||||
|
bodyshop,
|
||||||
|
...restProps
|
||||||
|
}) => {
|
||||||
const [isManualInput, setIsManualInput] = useState(false);
|
const [isManualInput, setIsManualInput] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleChange = useCallback(
|
const handleChange = useCallback(
|
||||||
(newDate) => {
|
(newDate) => {
|
||||||
|
if (!newDate) return;
|
||||||
if (onChange) {
|
if (onChange) {
|
||||||
onChange(newDate || null);
|
onChange(bodyshop?.timezone ? dayjs(newDate).tz(bodyshop.timezone, true) : newDate);
|
||||||
}
|
}
|
||||||
setIsManualInput(false);
|
setIsManualInput(false);
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange, bodyshop?.timezone]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleBlur = useCallback(
|
const handleBlur = useCallback(
|
||||||
@@ -102,4 +120,4 @@ DateTimePicker.propTypes = {
|
|||||||
isDateOnly: PropTypes.bool
|
isDateOnly: PropTypes.bool
|
||||||
};
|
};
|
||||||
|
|
||||||
export default React.memo(DateTimePicker);
|
export default connect(mapStateToProps, null)(DateTimePicker);
|
||||||
|
|||||||
@@ -119,19 +119,7 @@ var formats = {
|
|||||||
agendaTimeRangeFormat: timeRangeFormat
|
agendaTimeRangeFormat: timeRangeFormat
|
||||||
};
|
};
|
||||||
|
|
||||||
const localizer = (dayjsLib, timezone) => {
|
const localizer = (dayjsLib) => {
|
||||||
// load dayjs plugins
|
|
||||||
dayjsLib.extend(isBetween);
|
|
||||||
dayjsLib.extend(isSameOrAfter);
|
|
||||||
dayjsLib.extend(isSameOrBefore);
|
|
||||||
dayjsLib.extend(localeData);
|
|
||||||
dayjsLib.extend(localizedFormat);
|
|
||||||
dayjsLib.extend(minMax);
|
|
||||||
dayjsLib.extend(utc);
|
|
||||||
|
|
||||||
dayjsLib.locale("en");
|
|
||||||
dayjsLib.tz.setDefault(timezone);
|
|
||||||
|
|
||||||
var locale = function locale(dj, c) {
|
var locale = function locale(dj, c) {
|
||||||
return c ? dj.locale(c) : dj;
|
return c ? dj.locale(c) : dj;
|
||||||
};
|
};
|
||||||
@@ -140,9 +128,9 @@ const localizer = (dayjsLib, timezone) => {
|
|||||||
// then use the timezone aware version
|
// then use the timezone aware version
|
||||||
|
|
||||||
//TODO This was the issue entirely...
|
//TODO This was the issue entirely...
|
||||||
var dayjs = dayjsLib.tz ? dayjsLib.tz : dayjsLib;
|
// var dayjs = dayjsLib.tz ? dayjsLib.tz : dayjsLib;
|
||||||
|
|
||||||
// var dayjs = dayjsLib;
|
var dayjs = dayjsLib;
|
||||||
|
|
||||||
function getTimezoneOffset(date) {
|
function getTimezoneOffset(date) {
|
||||||
// ensures this gets cast to timezone
|
// ensures this gets cast to timezone
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import dayjs from "../../utils/day";
|
import dayjs from "../../utils/day";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Calendar, dayjsLocalizer } from "react-big-calendar";
|
import { Calendar } from "react-big-calendar";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link, useLocation, useNavigate } from "react-router-dom";
|
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
@@ -14,13 +14,14 @@ import { selectProblemJobs } from "../../redux/application/application.selectors
|
|||||||
import { Alert, Collapse, Space } from "antd";
|
import { Alert, Collapse, Space } from "antd";
|
||||||
import { Trans, useTranslation } from "react-i18next";
|
import { Trans, useTranslation } from "react-i18next";
|
||||||
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
import InstanceRenderManager from "../../utils/instanceRenderMgr";
|
||||||
|
import local from "./localizer";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
problemJobs: selectProblemJobs
|
problemJobs: selectProblemJobs
|
||||||
});
|
});
|
||||||
|
|
||||||
const localizer = dayjsLocalizer(dayjs);
|
const localizer = local(dayjs);
|
||||||
|
|
||||||
export function ScheduleCalendarWrapperComponent({
|
export function ScheduleCalendarWrapperComponent({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
|
|||||||
Reference in New Issue
Block a user