@@ -3,6 +3,7 @@ import { healthCheck, updateSignText } from '../../APIFunctions/LedSign';
33import {
44 getPermissionRequests ,
55 createPermissionRequest ,
6+ deletePermissionRequest ,
67} from '../../APIFunctions/PermissionRequest' ;
78import { useSCE } from '../../Components/context/SceContext' ;
89import { membershipState } from '../../Enums' ;
@@ -259,56 +260,83 @@ function LedSign() {
259260 const result = await createPermissionRequest ( 'LED_SIGN' , user . token ) ;
260261 if ( ! result . error ) {
261262 setPermissionRequest ( {
263+ _id : result . responseData . _id ,
262264 status : 'PENDING' ,
263265 } ) ;
264266 }
265267 setRequestingPermission ( false ) ;
266268 }
267269
268- function renderPermissionRequestUI ( ) {
269- if ( user . accessLevel >= membershipState . OFFICER ) {
270- return null ;
270+ async function handleCancelRequest ( ) {
271+ setRequestingPermission ( true ) ;
272+ const result = await deletePermissionRequest ( permissionRequest . _id , user . token ) ;
273+ if ( ! result . error ) {
274+ setPermissionRequest ( null ) ;
271275 }
276+ setRequestingPermission ( false ) ;
277+ }
278+
279+ function renderPermissionRequestUI ( ) {
280+ if ( user . accessLevel >= membershipState . OFFICER ) return null ;
281+
282+ // Mobile-friendly container: using max-w-md for better card feel on mobile
283+ const containerClasses = 'w-11/12 sm:w-2/3 lg:w-1/2 text-center p-6 bg-white dark:bg-gray-800 rounded-xl shadow-md space-y-4 fade-in border border-gray-200 dark:border-gray-700' ;
272284
273285 if ( checkingPermission || requestingPermission ) {
274286 return (
275- < div className = "w-2/3 lg:w-1/2 text-center py-4" >
276- < p > Loading...</ p >
287+ < div className = { containerClasses } >
288+ < div className = "flex justify-center items-center space-x-2" >
289+ < div className = "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" > </ div >
290+ < p className = "text-gray-500" > Processing...</ p >
291+ </ div >
277292 </ div >
278293 ) ;
279294 }
280295
281296 if ( ! permissionRequest ) {
282297 return (
283- < div className = "w-2/3 lg:w-1/2 text-center py-4 space-y-2 fade-in" >
284- < p className = "text-gray-700 dark:text-gray-300" >
285- You need permission to access the LED sign.
298+ < div className = { containerClasses } >
299+ < h2 className = "text-xl font-semibold" > Access Required</ h2 >
300+ < p className = "text-gray-600 dark:text-gray-400" >
301+ You currently do not have permission to update the LED sign. Would you like to request access?
286302 </ p >
287303 < button
288- className = "btn bg-blue-500 hover:bg-blue-400 text-white"
304+ className = "btn w-full bg-blue-500 hover:bg-blue-400 text-white font-bold py-3 rounded-lg transition-colors "
289305 onClick = { handleRequestAccess }
290- disabled = { requestingPermission }
291306 >
292- { requestingPermission ? 'Requesting...' : ' Request Access' }
307+ Request Access
293308 </ button >
294309 </ div >
295310 ) ;
296311 }
297312
298313 if ( permissionRequest . status === 'PENDING' ) {
299314 return (
300- < div className = "w-2/3 lg:w-1/2 text-center py-4 space-y-2 fade-in" >
315+ < div className = { containerClasses } >
316+ < div className = "inline-flex items-center justify-center p-2 bg-yellow-100 dark:bg-yellow-900 rounded-full mb-2" >
317+ < span className = "text-yellow-800 dark:text-yellow-200 text-sm font-bold px-2" > Pending Approval</ span >
318+ </ div >
301319 < p className = "text-gray-700 dark:text-gray-300" >
302- You requested access to the sign on { getFormattedTime ( permissionRequest . createdAt ) } .
320+ Requested on { getFormattedTime ( permissionRequest . createdAt ) }
303321 </ p >
304- < p className = "text-sm text-gray-600 dark:text-gray-400 italic" >
305- Drop a message in Discord to speed up the process!
322+ < p className = "text-sm text-gray-500 dark:text-gray-400 italic" >
323+ Check back soon! You can also message us on Discord to speed this up.
306324 </ p >
325+
326+ { /* Mobile-friendly Button Stack */ }
327+ < div className = "flex flex-col gap-2 pt-4" >
328+ < button
329+ className = "btn w-full bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200"
330+ onClick = { handleCancelRequest }
331+ >
332+ Nevermind, Cancel Request
333+ </ button >
334+ </ div >
307335 </ div >
308336 ) ;
309337 }
310338
311- return < h1 > { JSON . stringify ( permissionRequest ) } </ h1 > ;
339+ return null ;
312340 }
313341
314342 function renderSignControls ( ) {
0 commit comments