diff --git a/src/Pages/LedSign/LedSign.js b/src/Pages/LedSign/LedSign.js index 176aa7fa3..1bdc6a751 100644 --- a/src/Pages/LedSign/LedSign.js +++ b/src/Pages/LedSign/LedSign.js @@ -25,6 +25,7 @@ function LedSign() { const [permissionRequest, setPermissionRequest] = useState(null); const [checkingPermission, setCheckingPermission] = useState(false); const [requestingPermission, setRequestingPermission] = useState(false); + const [cancelingRequest, setCancelingRequest] = useState(false); const isOfficer = user.accessLevel >= membershipState.OFFICER; const [tab, setTab] = useState('sign'); const [allPermissionRequests, setAllPermissionRequests] = useState([]); @@ -237,6 +238,16 @@ function LedSign() { // eslint-disable-next-line }, []); + async function fetchAllPermissionRequests() { + if (!isOfficer) return; + setLoadingRequests(true); + const result = await getAllPermissionRequests('LED_SIGN', user.token); + if (!result.error && result.responseData) { + setAllPermissionRequests(result.responseData); + } + setLoadingRequests(false); + } + useEffect(() => { if (isOfficer && tab === 'requests') { fetchAllPermissionRequests(); @@ -272,6 +283,17 @@ function LedSign() { setRequestingPermission(false); } + async function handleCancelRequest() { + if (!permissionRequest || !permissionRequest._id) return; + + setCancelingRequest(true); + const result = await deletePermissionRequest('LED_SIGN', permissionRequest._id, user.token); + if (!result.error) { + setPermissionRequest(null); + } + setCancelingRequest(false); + } + function renderPermissionRequestUI() { if (user.accessLevel >= membershipState.OFFICER) { return null; @@ -294,6 +316,13 @@ function LedSign() {

Drop a message in Discord to speed up the process!

+ ); } @@ -331,16 +360,6 @@ function LedSign() { : 'p-2 hover:bg-gray-400 rounded-md dark:text-white text-gray-700'; } - async function fetchAllPermissionRequests() { - if (!isOfficer) return; - setLoadingRequests(true); - const result = await getAllPermissionRequests('LED_SIGN', user.token); - if (!result.error && result.responseData) { - setAllPermissionRequests(result.responseData); - } - setLoadingRequests(false); - } - async function handleApprove(requestId) { const result = await approvePermissionRequest('LED_SIGN', requestId, user.token); if (!result.error) await fetchAllPermissionRequests(); @@ -414,7 +433,7 @@ function LedSign() { ); } - const hasAccess = user.accessLevel >= membershipState.OFFICER; + const hasAccess = user.accessLevel >= membershipState.OFFICER || (permissionRequest && permissionRequest.approved); return (
@@ -442,75 +461,75 @@ function LedSign() {
{tab === 'sign' && (
-
-
-
- -
-
-
-
-
-

- {/* +
+
+
+ +
+
+
+
+
+

+ {/* we add a padding of 28 characters of whitespace so the entire message scrolls to the end of the preview before repeating. the preview has a width of about 28 characters. */} - {text.padEnd(28, ' ')} -

+ {text.padEnd(28, ' ')} +

+
+
+
-
-
-
- {maybeShowExpirationDate()} - {getExpirationButtonOrInput()} - { - inputArray.map(({ - id, - title, - type, - value, - onChange, - ...rest - }) => ( -
-
- - -
-
- )) - } + {maybeShowExpirationDate()} + {getExpirationButtonOrInput()} + { + inputArray.map(({ + id, + title, + type, + value, + onChange, + ...rest + }) => ( +
+
+ + +
+
+ )) + } - - + - {renderRequestStatus()} + + {renderRequestStatus()} +
+ - - )} {tab === 'requests' && }