Skip to content

Commit

Permalink
Fix the DateTime picker (#15)
Browse files Browse the repository at this point in the history
* Fix the DateTime picker
* Bump libwebp version for releases
  • Loading branch information
IngmarStein authored Feb 25, 2025
1 parent 86f3781 commit 9b7b9b1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/set-libwebp-version.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

export LIBWEBP_VERSION="libwebp-1.2.2-rc1"
export LIBWEBP_VERSION="libwebp-1.5.0"
7 changes: 4 additions & 3 deletions src/features/schema/fields/DateTime.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import dayjs from 'dayjs';

import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
Expand All @@ -10,19 +11,19 @@ import { set, remove } from '../../config/configSlice'


export default function DateTime({ field }) {
const [dateTime, setDateTime] = useState(new Date());
const [dateTime, setDateTime] = useState(dayjs());
const config = useSelector(state => state.config);
const dispatch = useDispatch();

useEffect(() => {
if (field.id in config) {
setDateTime(new Date(config[field.id].value));
setDateTime(dayjs(config[field.id].value));
}
}, [config]);

const onChange = (timestamp) => {
if (!timestamp) {
setDateTime(new Date());
setDateTime(dayjs());
dispatch(remove(field.id));
return;
}
Expand Down

0 comments on commit 9b7b9b1

Please sign in to comment.