Skip to content
GitLab
Explore
Sign in
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
094fc252
Commit
094fc252
authored
3 months ago
by
Dima Rifai
Committed by
mcfarhat
3 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#409
- Add Error Message Component
parent
da15bc4a
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/ErrorMessage.tsx
+37
-0
37 additions, 0 deletions
components/ErrorMessage.tsx
with
37 additions
and
0 deletions
components/ErrorMessage.tsx
0 → 100644
+
37
−
0
View file @
094fc252
import
React
,
{
useEffect
}
from
'
react
'
;
import
{
AlertTriangleIcon
}
from
'
lucide-react
'
;
interface
ErrorMessageProps
{
message
:
string
|
null
;
onClose
?:
()
=>
void
;
timeout
?:
number
;
// Timeout duration in milliseconds
}
const
ErrorMessage
:
React
.
FC
<
ErrorMessageProps
>
=
({
message
,
onClose
,
timeout
=
3000
})
=>
{
useEffect
(()
=>
{
if
(
message
&&
timeout
)
{
const
timer
=
setTimeout
(()
=>
{
if
(
onClose
)
onClose
();
// Automatically close the error message after timeout
},
timeout
);
// Cleanup timer when component is unmounted or message changes
return
()
=>
clearTimeout
(
timer
);
}
},
[
message
,
timeout
,
onClose
]);
if
(
!
message
)
return
null
;
// Don't render anything if there's no message
return
(
<
div
className
=
"error-message flex"
>
<
AlertTriangleIcon
color
=
"red"
/>
<
span
className
=
"ml-2"
>
{
message
}
</
span
>
{
onClose
&&
(
<
button
className
=
"ml-2 close-btn"
onClick
=
{
onClose
}
>
×
</
button
>
)
}
</
div
>
);
};
export
default
ErrorMessage
;
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