IO-1708 Updated timezone for date fields.

This commit is contained in:
Patrick Fic
2022-02-10 16:21:10 -08:00
parent e9f4b48839
commit cdd3841d49

View File

@@ -29,14 +29,16 @@ export function FormDatePicker({
const handleChange = (newDate) => { const handleChange = (newDate) => {
if (value !== newDate && onChange) { if (value !== newDate && onChange) {
onChange(newDate); console.log(newDate.tz(bodyshop.timezone));
onChange(newDate.tz(bodyshop.timezone));
} }
}; };
const handleKeyDown = (e) => { const handleKeyDown = (e) => {
if (e.key.toLowerCase() === "t") { if (e.key.toLowerCase() === "t") {
if (onChange) { if (onChange) {
onChange(moment()); console.log(moment().tz(bodyshop.timezone));
onChange(moment().tz(bodyshop.timezone));
// if (ref.current && ref.current.blur) ref.current.blur(); // if (ref.current && ref.current.blur) ref.current.blur();
} }
} else if (e.key.toLowerCase() === "enter") { } else if (e.key.toLowerCase() === "enter") {
@@ -71,10 +73,11 @@ export function FormDatePicker({
<div onKeyDown={handleKeyDown}> <div onKeyDown={handleKeyDown}>
<DatePicker <DatePicker
ref={ref} ref={ref}
value={value ? moment(value) : null} value={value ? moment(value).tz(bodyshop.timezone) : null}
onChange={handleChange} onChange={handleChange}
format={dateFormat} format={dateFormat}
onBlur={onBlur || handleBlur} onBlur={onBlur || handleBlur}
showToday={false}
disabledTime disabledTime
{...(onlyFuture && { {...(onlyFuture && {
disabledDate: (d) => moment().subtract(1, "day").isAfter(d), disabledDate: (d) => moment().subtract(1, "day").isAfter(d),