source: components/admin/LiveGames.jsx@ e903234

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

Added an admin panel, and the admin can now answer complaints

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[e903234]1import React from 'react'
2
3import { useEffect } from 'react';
4
5import { useSelector, useDispatch } from 'react-redux'
6
7import axios from 'axios';
8import { setAdminInformation } from '../../redux/reducers/adminInformationSlice';
9import { setAdmin } from '../../redux/reducers/adminSlice';
10
11const LiveGames = () => {
12 const dispatch = useDispatch();
13
14 const adminState = useSelector(state => state.admin);
15 const adminInformationState = useSelector(state => state.adminInformation);
16
17 useEffect(() => {
18 axios.get(`/api/postgre?action=get_live_games_as_admin&admin_id=${localStorage.CAESSINO_ADMIN_ID}`).then(res => {
19 if (res.data?.success) {
20 dispatch(setAdminInformation({
21 ...adminInformationState.adminInformation,
22 complaints: res.data?.complaints,
23 }))
24 }
25 })
26 }, [])
27
28 function hideLiveGamesScreen() {
29 dispatch(setAdmin({
30 ...adminState.admin,
31 displays: {
32 ...adminState.admin.displays,
33 liveGamesScreen: false,
34 }
35 }))
36 }
37
38 return (
39 <div className="fullscreen top-to-bottom-centered admin complaintsScreen">
40 <div>
41 <p className="link" onClick={() => hideLiveGamesScreen()}>⬅ Go Back</p>
42
43 <h3>These are the current live games. You can click on one to see more details about it.</h3>
44
45 { adminInformationState.complaints?.map(complaint => (
46 <div key={complaint.by + complaint.description.substr(0, 20)}>
47 { complaint.by }
48 { complaint.description }
49 </div>
50 )) }
51 </div>
52 </div>
53 )
54}
55
56export default LiveGames
Note: See TracBrowser for help on using the repository browser.