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

fix(useDatePicker): fix onDateSelect type, export types #79

Merged
merged 3 commits into from
Oct 9, 2024

Conversation

Birkbjo
Copy link
Member

@Birkbjo Birkbjo commented Oct 8, 2024

Trying to destructure the object in onDateSelect causes a runtime error, because it can be null (and is null when using clear-button in UI, that consumes this hook. I've updated the parameter type of onDateSelect to include null. However I also noticed that the hooks actually just calls it with

   onDateSelect({
                calendarDateString: formatDate(zdt, undefined, date.format),
            })

, excluding the calendarDate. Should we update the type for the calendar to be optional, or the runtime code here?

I've also exported the types, as it's convenient for consumers to be able to import types callback and options. Previously you would need to do something like type UseDatePickerOptions = Parameters<typeof useDatePicker>[0]

Note that the UI needs to update to the new version to get this propagated to UI-types, but it shouldn't require code changes in UI.

@Birkbjo Birkbjo changed the base branch from main to alpha October 8, 2024 11:47
@Birkbjo Birkbjo requested a review from kabaros October 8, 2024 11:51
@codecov-commenter
Copy link

codecov-commenter commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.31%. Comparing base (9fb353a) to head (2b457d8).
Report is 1 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha      #79   +/-   ##
=======================================
  Coverage   91.31%   91.31%           
=======================================
  Files          56       56           
  Lines        1197     1197           
  Branches      328      330    +2     
=======================================
  Hits         1093     1093           
  Misses        102      102           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Birkbjo Birkbjo force-pushed the fix/useDatePicker-types branch from c424f6f to 5374d3f Compare October 9, 2024 15:22
@Birkbjo Birkbjo merged commit 94358d2 into alpha Oct 9, 2024
7 checks passed
dhis2-bot added a commit that referenced this pull request Oct 9, 2024
# [2.0.0-alpha.4](v2.0.0-alpha.3...v2.0.0-alpha.4) (2024-10-09)

### Bug Fixes

* **useDatePicker:** fix onDateSelect type, export types ([#79](#79)) ([94358d2](94358d2))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 2.0.0-alpha.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

dhis2-bot added a commit that referenced this pull request Nov 21, 2024
# [2.0.0](v1.3.2...v2.0.0) (2024-11-21)

### Bug Fixes

* use export type ([#81](#81)) ([eaa8cdb](eaa8cdb))
* **useDatePicker:** fix onDateSelect type, export types ([#79](#79)) ([94358d2](94358d2))
* add 'valid' property to validation result ([894e181](894e181))
* remove Temporal references from hook public API and clean up use date picker ([#75](#75)) ([fb31512](fb31512))
* update validation logic to expose error code and mirror RFF format ([001d236](001d236))
* use NepaliCalendar instance to validate dates ([9fb353a](9fb353a))

### BREAKING CHANGES

* Remove Temporal references from hook public API

* feat: remove validation details from result of useDatePicker

as they are available in exposed validate date string function

* feat: remove calendar date from use date picker

* refactor: remove calendarDate from onDateSelect callback

* refactor: remove zonedDateTime from week days array

* refactor: fix linting issues
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 2.0.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