Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Block Explorer UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
Block Explorer UI
Commits
3d56e60a
Commit
3d56e60a
authored
3 months ago
by
Dima Rifai
Committed by
mcfarhat
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#409
- Validate toBlock is greate than FromBlock
parent
0233f1f3
No related branches found
No related tags found
1 merge request
!509
Delrifai/#409 error handling for tofrom block
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/searchRanges/SearchRanges.tsx
+21
-2
21 additions, 2 deletions
components/searchRanges/SearchRanges.tsx
with
21 additions
and
2 deletions
components/searchRanges/SearchRanges.tsx
+
21
−
2
View file @
3d56e60a
import
React
,
{
useEffect
}
from
"
react
"
;
import
React
,
{
useEffect
,
useState
}
from
"
react
"
;
import
moment
from
"
moment
"
;
import
{
SearchRangesResult
}
from
"
../../hooks/common/useSearchRanges
"
;
import
{
Select
,
SelectContent
,
SelectTrigger
,
SelectItem
}
from
"
../ui/select
"
;
import
{
Input
}
from
"
../ui/input
"
;
import
DateTimePicker
from
"
../DateTimePicker
"
;
import
ErrorMessage
from
"
../ErrorMessage
"
;
// Import the ErrorMessage component
interface
SearchRangesProps
{
rangesProps
:
SearchRangesResult
;
...
...
@@ -77,6 +78,8 @@ const SearchRanges: React.FC<SearchRangesProps> = ({
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
startDate
,
endDate
]);
const
[
blockRangeError
,
setBlockRangeError
]
=
useState
<
string
|
null
>
(
null
);
// Error state for block range validation
return
(
<
div
className
=
"py-2 flex flex-col gap-y-2"
>
<
Select
...
...
@@ -184,13 +187,29 @@ const SearchRanges: React.FC<SearchRangesProps> = ({
type
=
"text"
value
=
{
toBlock
||
""
}
onChange
=
{
(
e
)
=>
handleNumericInput
(
e
.
target
.
value
,
setToBlock
)
handleNumericInput
(
e
.
target
.
value
,
setToBlock
)
}
placeholder
=
{
"
To
"
}
onBlur
=
{
()
=>
{
// Validate if 'toBlock' is greater than 'fromBlock'
if
(
toBlock
&&
fromBlock
&&
toBlock
<
fromBlock
)
{
setBlockRangeError
(
"
To block must be greater than From block
"
);
setToBlock
(
undefined
);
// Clear the 'toBlock' field
}
else
{
setBlockRangeError
(
null
);
// Clear the error message immediately if 'toBlock' is valid
}
}
}
/>
</
div
>
</
div
>
)
}
{
blockRangeError
&&
(
<
ErrorMessage
message
=
{
blockRangeError
}
onClose
=
{
()
=>
setBlockRangeError
(
null
)
}
// Close the error message
timeout
=
{
3000
}
/>
)
}
{
rangeSelectKey
===
"
timeRange
"
&&
(
<
div
className
=
"flex flex-col mt-5"
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment