source: components/Notification.jsx@ b13f93b

main
Last change on this file since b13f93b was b13f93b, checked in by anastasovv <simon@…>, 2 years ago

Made poker tables system and round 1

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[87614a5]1import React from 'react'
2
3import { AiOutlineClose } from 'react-icons/ai';
4
5import { useDispatch, useSelector } from 'react-redux';
6import { setStyle } from '../redux/reducers/styleSlice';
7
8const Notification = () => {
9 const styleState = useSelector(state => state.style);
10
11 const dispatch = useDispatch();
12
13 const display = styleState.style.notification.show === true ? 'flex' : 'none';
14 const bg = styleState.style.notification.status === 'success' ? 'rgba(0, 200, 255, 0.8)' : 'rgba(255, 0, 0, 0.8)';
15
16 function close() {
17 dispatch(setStyle({
18 ...styleState.style,
19 notification: {
20 ...styleState.style.notification,
21 show: false,
22 }
23 }))
24 }
25
[b13f93b]26 if (styleState.style.notification.show === true) {
27 setTimeout(() => {
28 close();
29 }, 3000);
30 }
31
[87614a5]32 return (
33 <div className="notification" style={{display: display, backgroundColor: bg}}>
34 <AiOutlineClose onClick={() => close()}/>
35 <div>
36 {styleState.style.notification.text}
37 </div>
38 </div>
39 )
40}
41
42export default Notification
Note: See TracBrowser for help on using the repository browser.