File tree Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change 84
84
"createdAt" : 1647211568779 ,
85
85
"id" : 15
86
86
},
87
- {
88
- "title" : " " ,
89
- "body" : " " ,
90
- "publish" : false ,
91
- "createdAt" : 1653628899948 ,
92
- "id" : 16
93
- },
94
87
{
95
88
"title" : " tetet" ,
96
89
"body" : " body" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import LoadingSpinner from '../components/LoadingSpinner';
6
6
import Pagination from './Pagination' ;
7
7
import { useLocation } from 'react-router-dom' ;
8
8
import propTypes from 'prop-types' ;
9
+ import Toast from '../components/Toast' ;
9
10
10
11
const BlogList = ( { isAdmin } ) => {
11
12
const history = useHistory ( ) ;
@@ -102,6 +103,12 @@ const BlogList = ({ isAdmin }) => {
102
103
103
104
return (
104
105
< div >
106
+ < Toast
107
+ toasts = { [
108
+ { text : 'error' } ,
109
+ { text : 'success' , type : 'success' } ,
110
+ ] }
111
+ />
105
112
< input
106
113
type = "text"
107
114
placeholder = "Search.."
Original file line number Diff line number Diff line change
1
+ import propTypes from "prop-types" ;
2
+
3
+ const Toast = ( { toasts } ) => {
4
+ return (
5
+ < div className = "position-fixed bottom-0 end-0 p-2" >
6
+ { toasts . map ( toast => {
7
+ return (
8
+ < div className = { `alert alert-${ toast . type || 'success' } m-0 py-2 mt-2` } >
9
+ { toast . text }
10
+ </ div >
11
+ ) ;
12
+ } ) }
13
+ </ div >
14
+ ) ;
15
+ }
16
+
17
+ Toast . propTypes = {
18
+ toasts : propTypes . arrayOf ( propTypes . shape ( {
19
+ text : propTypes . string ,
20
+ type : propTypes . string
21
+ } ) ) . isRequired
22
+ }
23
+
24
+ Toast . defaultProps = {
25
+ toasts : [ ]
26
+ }
27
+
28
+ export default Toast ;
You can’t perform that action at this time.
0 commit comments