Skip to content

Commit

Permalink
fix: goal date settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alaca committed May 14, 2024
1 parent 3ee3383 commit cca6258
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,15 @@ export default ({

const popoverRef = useRef();

const [date, setDate] = useState<string>(value);
const [date, setDate] = useState<string>(value || new Date().toISOString().slice(0, 19));
const [isVisible, setIsVisible] = useState<boolean>(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);
};

Expand Down Expand Up @@ -99,15 +94,15 @@ export default ({
{showTimeSelector ? (
<DateTimePicker
is12Hour={is12Hour}
currentDate={value}
currentDate={date}
isInvalidDate={(date) => checkDate(date)}
onChange={(date) => {
setDate(date);
}}
/>
) : (
<DatePicker
currentDate={value}
currentDate={date}
isInvalidDate={(date) => checkDate(date)}
onChange={(date) => {
setDate(date);
Expand Down

0 comments on commit cca6258

Please sign in to comment.