Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [DHIS2-18081] Problem with date format when scheduling an event #3816

Conversation

henrikmv
Copy link
Contributor

@henrikmv henrikmv commented Sep 27, 2024

DHIS2-18081

  • Converts date to server format YYYY-MM-DD.
  • Format of date stored in the scheduleDate-state is based on the system settings.

@henrikmv henrikmv marked this pull request as ready for review September 27, 2024 13:39
@henrikmv henrikmv requested a review from a team as a code owner September 27, 2024 13:39
@eirikhaugstulen
Copy link
Contributor

Hey @henrikmv - I like the changes you've made here.

However, I think we should keep the scheduleDate-state in the same format as would be displayed in the input field. Right now, it's always stored in the server format. Can you take a look to see if you can get this state to store either YYYY-MM-DD or DD-MM-YYYY based on the system settings instead? This is what we're doing other places in the app. Let's have a chat about it tomorrow! 😊

@@ -45,13 +46,15 @@ export const WidgetEventSchedule = ({
});
const { currentUser, noteId } = useNoteDetails();
const [scheduleDate, setScheduleDate] = useState('');
const dateFormat = systemSettingsStore.get().dateFormat;
const formatDateForServer = date => moment(date, dateFormat).format('YYYY-MM-DD');
const formattedScheduleDate = formatDateForServer(scheduleDate);
Copy link
Contributor

@simonadomnisoru simonadomnisoru Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @henrikmv
Can you use existing converters instead, in the same way as is currently done elsewhere, i.e. getConvertedRelatedStageEvent?

const convertFn = pipe(convertFormToClient, convertClientToServer);
const serverScheduleDate = convertFn(scheduleDate, dataElementTypes.DATE);

Thanks!

…/fix/DHIS2-18081_DataFormatErrorWhenSchedulingAnEvent
Copy link
Contributor

@simonadomnisoru simonadomnisoru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link

github-actions bot commented Oct 8, 2024

Copy link

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully on 2.41.2,2.40.6,2.39.8 versions

Copy link
Contributor

@eirikhaugstulen eirikhaugstulen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, Henrik!

@eirikhaugstulen eirikhaugstulen merged commit e12e561 into master Oct 8, 2024
80 checks passed
@eirikhaugstulen eirikhaugstulen deleted the hv/fix/DHIS2-18081_DataFormatErrorWhenSchedulingAnEvent branch October 8, 2024 15:16
dhis2-bot added a commit that referenced this pull request Oct 8, 2024
# [101.8.0](v101.7.4...v101.8.0) (2024-10-08)

### Features

* [DHIS2-18081] Problem with date format when scheduling an event ([#3816](#3816)) ([e12e561](e12e561))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 101.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants