From d35992e8c3d368468c6007f023bb7a86e5b14dcd 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 a374b0f4cb..0513bb5b14 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);