import React from 'react' import { useDispatch } from 'react-redux' import ReactSelect from 'react-select' import PlaceholderSVG from '@epicformbuilder/admin/images/settings/placeholder.svg?react' import { updateComponentProperty } from '@epicformbuilder/admin/data' import { SettingsTab, DataTag, Label, Placeholder, Hint, Required, HelpCenter } from '@epicformbuilder/admin/editor/components' import { userTime } from '../../../../services/time' function time (format) { return userTime({ timestamp: undefined, timezone: window.__EPICFORMBUILDER__.__USER__.settings.timezone, format: format }) } export default function Time ({ id, label, showLabel, placeholder, format, hint, showHint, tag, required, errorEmptyData }) { const tabs = { general: true, validation: true, advanced: true, help: true } const formats = { 'h:mm aa': time('h:mm aa') + ' (12h format)', 'h:mm aaaa': time('h:mm aaaa') + ' (12h format)', 'HH:mm': time('HH:mm') + ' (24h format)', } const dispatch = useDispatch() const onChange = (id, property) => event => { const booleanProperties = ['showLabel', 'showHint', 'required']; const value = 0 <= booleanProperties.indexOf(property) ?event.target.checked :event.target.value dispatch(updateComponentProperty(id, property, value)) } function handleFormatChange(option) { onChange(id, 'format')({ target: { value: option.value }}) } return (