From eed11fd96cf1458a7a91659cdf5efafbadda1b2b Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 20 Mar 2021 18:44:58 +0100 Subject: more event api --- components/notificationsArea.tsx | 73 +++++++++++++++++++++++++++++----------- 1 file changed, 53 insertions(+), 20 deletions(-) (limited to 'components/notificationsArea.tsx') diff --git a/components/notificationsArea.tsx b/components/notificationsArea.tsx index 1e92493..7d2fa49 100644 --- a/components/notificationsArea.tsx +++ b/components/notificationsArea.tsx @@ -1,7 +1,7 @@ import { CSSProperties, ReactNode, useState } from 'react'; import axios from 'axios'; -import { userInfo } from "../api/api"; +import { userInfo, gameInfo } from "../api/api"; import { AccountAvatar } from "./account"; import { Bubble, Vierkant, IconLabelButton } from './ui'; @@ -11,7 +11,14 @@ import CloseIcon from '@material-ui/icons/Close'; export function NotificationsArea(props: { visible?: boolean; friendRequests?: Array; + gameInvites?: Array; + rerender: () => void; }) { + var messages = ( + (props.friendRequests ? props.friendRequests.length : 0) + + (props.gameInvites ? props.gameInvites.length : 0) + ) + return props.visible && - { /* here should be the game invites */ } - { props.friendRequests?.map(user => ) } + { props.gameInvites?.map(game => ) } + { props.friendRequests?.map(user => ) } + { + messages == 0 && +
+

Geen meldingen

+
+ }
} @@ -83,9 +109,15 @@ function Acceptable(props: { function FriendRequest(props: { user: userInfo; + hide: () => void; }) { var [ gone, setGone ] = useState(false); + var hide = () => { + setGone(true); + props.hide(); + } + return !gone && { axios.request({ method: "post", @@ -93,7 +125,7 @@ function FriendRequest(props: { headers: {"content-type": "application/json"}, data: { "id": props.user?.id } }) - .then(() => setGone(true)); + .then(hide); }} onDeny={() => { axios.request({ method: "post", @@ -101,7 +133,7 @@ function FriendRequest(props: { headers: {"content-type": "application/json"}, data: { "id": props.user?.id } }) - .then(() => setGone(true)); + .then(hide); }}> @@ -117,19 +149,20 @@ function FriendRequest(props: { } -/* function GameInvite(props: { */ -/* game: gameInfo; */ -/* }) { */ -/* return */ -/* */ -/*
*/ -/* Partijuitnodiging */ -/*

{props.game.opponent?.username} wil een potje 4 op een rij spelen!

*/ -/*
*/ -/* */ -/* */ -/* } */ +function GameInvite(props: { + game: gameInfo; + hide: () => void; +}) { + return + +
+ Partijuitnodiging +

{props.game.opponent?.username} wil een potje 4 op een rij spelen!

+
+ +
+} -- cgit v1.2.3