import { getErrorMessage } from "@dashboard/components/Attributes/utils"; import { PageErrorWithAttributesFragment, ProductErrorWithAttributesFragment, } from "@dashboard/graphql"; import { commonMessages } from "@dashboard/intl"; import { joinDateTime, splitDateTime } from "@dashboard/misc"; import { TextField } from "@material-ui/core"; import { TextFieldProps } from "@material-ui/core/TextField"; import { Box } from "@saleor/macaw-ui/next"; import React from "react"; import { useIntl } from "react-intl"; type DateTimeFieldProps = Omit & { onChange: (value: string) => void; error: ProductErrorWithAttributesFragment | PageErrorWithAttributesFragment; value: string; }; export const DateTimeField: React.FC = ({ disabled, error, name, onChange, value, }) => { const intl = useIntl(); const parsedValue = value ? splitDateTime(value) : { date: "", time: "" }; return ( { const date = event.target.value; onChange(joinDateTime(date, parsedValue.time)); }} type="date" value={parsedValue.date} InputLabelProps={{ shrink: true }} /> { const time = event.target.value; onChange(joinDateTime(parsedValue.date, time)); }} type="time" value={parsedValue.time} InputLabelProps={{ shrink: true }} /> ); };