PromucFlow_constructor/app/client/src/components/propertyControls/TimezoneControl.tsx

34 lines
958 B
TypeScript
Raw Normal View History

2019-11-06 12:12:41 +00:00
import React from "react";
import BaseControl, { ControlProps } from "./BaseControl";
import { StyledTimeZonePicker } from "./StyledControls";
2019-11-25 05:07:27 +00:00
import { ControlType } from "constants/PropertyControlConstants";
2019-11-06 12:12:41 +00:00
import moment from "moment-timezone";
import "../../../node_modules/@blueprintjs/timezone/lib/css/blueprint-timezone.css";
class TimeZoneControl extends BaseControl<TimeZoneControlProps> {
render() {
return (
<StyledTimeZonePicker
onChange={this.onTimeZoneSelected}
valueDisplayFormat={"composite"}
showLocalTimezone={true}
value={this.props.propertyValue || moment.tz.guess()}
/>
2019-11-06 12:12:41 +00:00
);
}
onTimeZoneSelected = (timezone: string): void => {
this.updateProperty(this.props.propertyName, timezone);
};
getControlType(): ControlType {
return "TIME_ZONE";
}
}
export interface TimeZoneControlProps extends ControlProps {
propertyValue: string;
}
export default TimeZoneControl;