import axios from 'axios'; import { CSSProperties, ReactNode, useContext, useEffect, useState } from 'react'; import { gameInfo, userInfo } from '../api/api'; import { AccountAvatar } from './account'; import { ToastContext } from './toast'; import { Bubble, IconLabelButton, Vierkant } from './ui'; import CloseIcon from '@material-ui/icons/Close'; import DoneIcon from '@material-ui/icons/Done'; import NotificationsActiveOutlinedIcon from '@material-ui/icons/NotificationsActiveOutlined'; export function NotificationsArea(props: { visible?: boolean; friendRequests?: Array; gameInvites?: Array; rerender: () => void; }) { var { toast } = useContext(ToastContext); var [previousMessages, setPreviousMessages] = useState(0); var messages = ( (props.friendRequests ? props.friendRequests.length : 0) + (props.gameInvites ? props.gameInvites.length : 0) ); useEffect(() => { if (messages > previousMessages) { toast({ message: 'Je hebt nieuwe meldingen!', type: 'confirmation', icon: , }); } setPreviousMessages(messages); }); return props.visible &&

Meldingen

{props.gameInvites?.map(game => )} {props.friendRequests?.map(user => )} {messages == 0 &&

Geen meldingen

}
; } var FriendRequestButtonStyle: CSSProperties = { borderRadius: 6, display: 'inline-block', marginLeft: 0, textAlign: 'center', }; function Acceptable(props: { children?: ReactNode; onAccept?: () => void; onDeny?: () => void; }) { return
{props.children}
} text='Accepteren' /> } text='Verwijderen' />
; } function FriendRequest(props: { user: userInfo; hide: () => void; }) { var [gone, setGone] = useState(false); var hide = () => { setGone(true); props.hide(); }; return !gone && { axios.request({ method: 'post', url: '/api/social/accept', headers: { 'content-type': 'application/json' }, data: { 'id': props.user?.id }, }) .then(hide); }} onDeny={() => { axios.request({ method: 'post', url: '/api/social/remove', headers: { 'content-type': 'application/json' }, data: { 'id': props.user?.id }, }) .then(hide); }} >
Vriendschapsverzoek {props.user.username}
; } function GameInvite(props: { game: gameInfo; hide: () => void; }) { return
Partijuitnodiging

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

; }