diff --git a/client/components/panels/ban-user.jsx b/client/components/panels/ban-user.jsx index 6371d3b..38dbe1b 100644 --- a/client/components/panels/ban-user.jsx +++ b/client/components/panels/ban-user.jsx @@ -1,9 +1,65 @@ -import React from 'react'; +import React, { useRef, useContext } from 'react'; + +import { TokenContext } from '../utilities/token-provider'; const BanUser = props => { + //context + const authTokens = useContext(TokenContext); + + //ref + const usernameRef = useRef(); + return ( - <> +
+

Permanently Ban User

+
+
+ + +
+ + +
+
); }; -export default BanUser; \ No newline at end of file +const handleButtonPress = async (username, tokenFetch) => { + const result = await tokenFetch(`${process.env.AUTH_URI}/admin/banuser`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*' + }, + body: JSON.stringify({ + username + }) + }); + + if (!result.ok) { + const err = `${result.status}: ${await result.text()}`; + console.log(err); + return [err, false]; + } + + return [null, true]; +}; + +export default BanUser;