import { useState } from "react"; // types import { Props } from "./types"; import { renderDateFormat } from "helpers/date-time.helper"; export const CustomDateTimeAttribute: React.FC = ({ onChange, value, }) => { const [isEditing, setIsEditing] = useState(false); const handleUpdateDateTime = (val: string) => { setIsEditing(false); onChange(new Date(val)); }; return (
{!isEditing && (value ? (
setIsEditing(true)} > {renderDateFormat(value)}
) : (
setIsEditing(true)}> Empty
))} {isEditing && ( handleUpdateDateTime(e.target.value)} /> )}
); };