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

fixes the date picker so it does not change the date after selecting it #855

Merged
merged 2 commits into from
Jan 4, 2024

Conversation

jasquat
Copy link
Contributor

@jasquat jasquat commented Jan 4, 2024

Fixes bug #853

This fixes the date picker by fixing the dateStringToYMDFormat function so that it if the date looks to already be in that format then do not touch it.

Summary by CodeRabbit

  • Bug Fixes
    • Improved date handling to recognize and accept dates already in yyyy-MM-dd format without additional processing.

Copy link
Contributor

coderabbitai bot commented Jan 4, 2024

Walkthrough

Walkthrough

The update to the system introduces a new validation step within the dateStringToYMDFormat function. This function now checks if the provided date string is already in the yyyy-MM-dd format. If the date string conforms to this format, the function returns it as is, without any additional processing.

Changes

File Path Change Summary
.../DateAndTimeService.tsx Added a format check to dateStringToYMDFormat to return the date string unchanged if it matches yyyy-MM-dd.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@jasquat jasquat mentioned this pull request Jan 4, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 6bafd7b and e6ed5e9.
Files selected for processing (1)
  • spiffworkflow-frontend/src/services/DateAndTimeService.tsx (1 hunks)
Additional comments: 2
spiffworkflow-frontend/src/services/DateAndTimeService.tsx (2)
  • 48-49: The logic after the new condition correctly parses and formats the date string if it does not match the yyyy-MM-dd format. This part of the code remains unchanged and is functioning as intended.

  • 41-50: Ensure that the change in the dateStringToYMDFormat function does not affect other functions that depend on it. It would be prudent to verify that all functions that use dateStringToYMDFormat are still receiving the expected format, especially convertDateAndTimeStringsToDate which directly uses the output.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between e6ed5e9 and ab07f04.
Files selected for processing (1)
  • spiffworkflow-frontend/src/services/DateAndTimeService.tsx (1 hunks)
Additional comments: 2
spiffworkflow-frontend/src/services/DateAndTimeService.tsx (2)
  • 48-49: The use of parse and format from date-fns for handling dates not in yyyy-MM-dd format is appropriate and follows best practices for date manipulation in JavaScript.

  • 43-50: Ensure that the modification to dateStringToYMDFormat does not impact other functions that depend on it, such as convertDateAndTimeStringsToDate. It's important to verify that these functions expect the date string to be in yyyy-MM-dd format after conversion.

Verification successful

The search results indicate that the dateStringToYMDFormat function is used in several places within the codebase:

  • It is defined in DateAndTimeService.tsx.
  • It is used within the same file to construct a new Date object.
  • It is exported from DateAndTimeService.tsx.
  • It is used in DateWidget.tsx to format a value.
  • It is used twice in DateRangePickerWidget.tsx to format the start and end dates.

Given this usage, the modification to return the input string directly if it matches the yyyy-MM-dd format should not negatively impact these usages, as they all seem to expect a date string in the yyyy-MM-dd format. However, without seeing the exact implementation of how the formatted date strings are used in DateWidget.tsx and DateRangePickerWidget.tsx, we cannot be completely certain.

To further verify the impact of the changes, we should check the usage of the formatted date strings in DateWidget.tsx and DateRangePickerWidget.tsx.


The new context from the shell scripts provides the following insights:

  1. In DateWidget.tsx, the dateStringToYMDFormat function is used to format a value, and then the result is passed to the onChange handler. This suggests that the onChange handler expects a date string in the yyyy-MM-dd format.

  2. In DateRangePickerWidget.tsx, the dateStringToYMDFormat function is used to format the start and end dates of a date range. The formatted dates are then concatenated with a delimiter to form a date range string, which is passed to the onChange handler. This also suggests that the onChange handler expects date strings in the yyyy-MM-dd format.

Given this usage, the modification to the dateStringToYMDFormat function to return the input string directly if it matches the yyyy-MM-dd format should be compatible with the expectations of the onChange handlers in both widgets. The change should not adversely affect these functions, as they are designed to work with date strings in the yyyy-MM-dd format.

Based on the provided context and the usage patterns observed in the codebase, the review comment concern appears to be addressed.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the dateStringToYMDFormat function is used consistently across the codebase.
rg --type ts "dateStringToYMDFormat"

Length of output: 833



Script:

#!/bin/bash
# Check the usage of dateStringToYMDFormat in DateWidget.tsx and DateRangePickerWidget.tsx
rg --type ts -A 5 "dateStringToYMDFormat" spiffworkflow-frontend/src/rjsf/carbon_theme/DateWidget/DateWidget.tsx
rg --type ts -A 5 "dateStringToYMDFormat" spiffworkflow-frontend/src/rjsf/custom_widgets/DateRangePicker/DateRangePickerWidget.tsx

Length of output: 845

@jasquat jasquat merged commit 4c20759 into main Jan 4, 2024
32 checks passed
@jasquat jasquat deleted the feature/date-picker-fix branch January 4, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants