From 5ec93679f173c50f072584da3a97a7d627e2dfff Mon Sep 17 00:00:00 2001 From: Eugene Toder Date: Tue, 26 Nov 2024 13:03:32 -0500 Subject: [PATCH] Add a button to reset user's color (#37) Because changing color is a free feature now. --- src/components/ProfileName.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/ProfileName.js b/src/components/ProfileName.js index 5158e2c..12f6d3c 100644 --- a/src/components/ProfileName.js +++ b/src/components/ProfileName.js @@ -11,7 +11,7 @@ import firebase from "../firebase"; import ElapsedTime from "./ElapsedTime"; import User from "./User"; import { UserContext } from "../context"; -import { generateName } from "../util"; +import { generateColor, generateName } from "../util"; const useStyles = makeStyles((theme) => ({ vertIcon: { @@ -45,6 +45,11 @@ function ProfileName({ userId }) { handleClose(); }; + const handleColor = () => { + firebase.database().ref(`users/${userId}/color`).set(generateColor()); + handleClose(); + }; + const handleBan = (minutes) => { const endTime = Date.now() + minutes * 60000; firebase.database().ref(`users/${userId}/banned`).set(endTime); @@ -88,6 +93,7 @@ function ProfileName({ userId }) { onClose={handleClose} > Reset username + Reset color {player.banned && Date.now() < player.banned ? ( handleUnban()}>Unban ) : (