From b509565ec134f5bcdb208a4e8ab8bce7833e707d Mon Sep 17 00:00:00 2001 From: alvintran Date: Thu, 26 Jun 2025 22:43:48 -0700 Subject: [PATCH] bye bye prop --- src/Pages/LedSign/LedSign.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Pages/LedSign/LedSign.js b/src/Pages/LedSign/LedSign.js index 20e4564e6..027c0af4b 100644 --- a/src/Pages/LedSign/LedSign.js +++ b/src/Pages/LedSign/LedSign.js @@ -1,10 +1,11 @@ import React, { useState, useEffect } from 'react'; import { healthCheck, updateSignText } from '../../APIFunctions/LedSign'; +import { useUser } from '../../Components/context/UserContext'; import './ledsign.css'; - -function LedSign(props) { +function LedSign() { + const { user } = useUser(); const [signHealthy, setSignHealthy] = useState(false); const [loading, setLoading] = useState(true); const [text, setText] = useState(''); @@ -69,10 +70,6 @@ function LedSign(props) { async function handleSend() { setAwaitingSignResponse(true); - // on the led sign server, a lower value for scroll speed means that - // the message scrolls faster. In the frontend, the speed input can be - // from 0 to 10. If the speed is 0, the sign doesn't stop, but instead - // just scrolls really fast. let correctedScrollSpeed = 10 - scrollSpeed; const signResponse = await updateSignText( { @@ -82,10 +79,10 @@ function LedSign(props) { backgroundColor, textColor, borderColor, - email: props.user.email, - firstName: props.user.firstName, + email: user.email, + firstName: user.firstName, }, - props.user.token + user.token ); setRequestSuccessful(!signResponse.error); setAwaitingSignResponse(false); @@ -96,10 +93,10 @@ function LedSign(props) { const signResponse = await updateSignText( { ledIsOff: true, - email: props.user.email, - firstName: props.user.firstName, + email: user.email, + firstName: user.firstName, }, - props.user.token + user.token ); setStopRequestSuccesful(!signResponse.error); setAwaitingStopSignResponse(false); @@ -122,7 +119,7 @@ function LedSign(props) { useEffect(() => { async function checkSignHealth() { setLoading(true); - const status = await healthCheck(props.user.firstName); + const status = await healthCheck(user.firstName); if (status && !status.error) { setSignHealthy(true); const { responseData } = status; @@ -139,7 +136,7 @@ function LedSign(props) { } setLoading(false); } - checkSignHealth(props.user.firstName); + checkSignHealth(); // eslint-disable-next-line }, [])