From 712b3580be3109e5509dad3aea86034739605ae9 Mon Sep 17 00:00:00 2001 From: Ante Laca Date: Tue, 14 May 2024 21:32:34 +0200 Subject: [PATCH] Fix: goal date settings (#7388) --- .../src/components/DatePicker/index.tsx | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/FormBuilder/resources/js/form-builder/src/components/DatePicker/index.tsx b/src/FormBuilder/resources/js/form-builder/src/components/DatePicker/index.tsx index bfd460da26..d78923aa34 100644 --- a/src/FormBuilder/resources/js/form-builder/src/components/DatePicker/index.tsx +++ b/src/FormBuilder/resources/js/form-builder/src/components/DatePicker/index.tsx @@ -32,20 +32,15 @@ export default ({ const popoverRef = useRef(); - const [date, setDate] = useState(value); + const [date, setDate] = useState(value || new Date().toISOString().slice(0, 19)); const [isVisible, setIsVisible] = useState(false); - const convertJsDateToMySQLDate = (dateTime: string) => { - const [date, time] = dateTime.split('T'); - return `${date} ${time}`; - }; - const toggleVisible = () => { setIsVisible((state) => !state); }; const onSelectDate = () => { - onSelect(convertJsDateToMySQLDate(date)); + onSelect(date.replace('T', ' ')); setIsVisible(false); }; @@ -99,7 +94,7 @@ export default ({ {showTimeSelector ? ( checkDate(date)} onChange={(date) => { setDate(date); @@ -107,7 +102,7 @@ export default ({ /> ) : ( checkDate(date)} onChange={(date) => { setDate(date);