|
Last change
on this file was cb0881d, checked in by MBK <marija.karapandzova@…>, 4 months ago |
|
Set up React frontend and add design styles
|
-
Property mode
set to
100644
|
|
File size:
591 bytes
|
| Line | |
|---|
| 1 | import React, { useEffect } from 'react';
|
|---|
| 2 |
|
|---|
| 3 | function SuccessAlert({ message, onClose, duration = 3000 }) {
|
|---|
| 4 | useEffect(() => {
|
|---|
| 5 | if (duration > 0) {
|
|---|
| 6 | const timer = setTimeout(onClose, duration);
|
|---|
| 7 | return () => clearTimeout(timer);
|
|---|
| 8 | }
|
|---|
| 9 | }, [duration, onClose]);
|
|---|
| 10 |
|
|---|
| 11 | return (
|
|---|
| 12 | <div className="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded mb-4 flex justify-between items-center">
|
|---|
| 13 | <span>{message}</span>
|
|---|
| 14 | <button onClick={onClose} className="font-bold text-green-700">
|
|---|
| 15 | ×
|
|---|
| 16 | </button>
|
|---|
| 17 | </div>
|
|---|
| 18 | );
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | export default SuccessAlert;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.