-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Fixed relative date filter initalization #12811
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,4 +7,14 @@ export const computeVariableDateViewFilterValue = ( | |||||
direction: VariableDateViewFilterValueDirection, | ||||||
amount: number | undefined, | ||||||
unit: VariableDateViewFilterValueUnit, | ||||||
) => `${direction}_${amount?.toString()}_${unit}`; | ||||||
) => { | ||||||
if (direction === 'THIS') { | ||||||
return `THIS_1_${unit}`; | ||||||
} else if (amount === undefined || amount <= 0) { | ||||||
throw new Error( | ||||||
'Amount must be defined and greater than 0 for relative date filters', | ||||||
); | ||||||
} | ||||||
Comment on lines
+13
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Good validation, but error message could be more user-friendly. Consider extracting to a constant and making it less technical. |
||||||
|
||||||
return `${direction}_${amount.toString()}_${unit}`; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: toString() call unnecessary since template literals automatically convert to string. Remove for cleaner code.
Suggested change
|
||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider extracting defaultRelativeDate as a constant since it represents default configuration values