11import { useEffect , useState } from "react" ;
2- import Layout from "../Layout/layout" ;
3- import Sidebar from "../Sidebar/sidebar" ;
2+ import LoggedInLayout from "../Layout/loggedInLayout" ;
43import activatedAppsList from "./activatedAppsList.module.css" ;
54
65export default function ActivatedAppsList ( ) {
7- const [ activatedApps , setActivatedApps ] = useState ( [ ] ) ;
6+ const [ activatedApps , setActivatedApps ] = useState ( null ) ;
87
9- useEffect ( ( ) => {
10- fetch ( `http://localhost:8400/login` , {
11- headers : {
12- authorization : `Basic ${ localStorage . getItem ( 'apiKey' ) } `
13- }
14- } ) . then ( response => {
15- if ( response . ok && response . status !== 204 ) {
16- return response . json ( ) ;
17- }
18- } ) . then ( response => {
19- setActivatedApps ( response . data . filter ( item => item . activated ) ) ;
20- } ) ;
8+ useEffect ( ( ) => {
9+ fetch ( `http://localhost:8400/login` , {
10+ headers : {
11+ authorization : `Basic ${ localStorage . getItem ( "apiKey" ) } ` ,
12+ } ,
13+ } )
14+ . then ( ( response ) => {
15+ if ( response . ok && response . status !== 204 ) {
16+ return response . json ( ) ;
17+ }
18+ } )
19+ . then ( ( response ) => {
20+ setActivatedApps ( response . data . filter ( ( item ) => item . activated ) ) ;
21+ } ) ;
2122
22- document . title = "Activated Apps - Borum Sphere" ;
23- } , [ ] ) ;
23+ document . title = "Activated Apps - Borum Sphere" ;
24+ } , [ ] ) ;
2425
25- return (
26- < Layout sidebar = { < Sidebar /> } >
27- < main className = { activatedAppsList . container } >
28- < h2 > Activated Borum Apps</ h2 >
29- < p > { activatedApps . length } Activated Borum Apps</ p >
30- < ul >
31- { activatedApps . map ( item => < li key = { item . name . replace ( / \s / g, "" ) } > < img width = { 50 } src = { item . logoSrc } alt = { `${ item . name } Logo` } /> { item . name } </ li > ) }
32- </ ul >
33- </ main >
34- </ Layout >
35-
36- ) ;
37- }
26+ return (
27+ < LoggedInLayout >
28+ < main className = { activatedAppsList . container } >
29+ < h2 > Activated Borum Apps</ h2 >
30+ < p > { activatedApps ?. length || '' } Activated Borum Apps</ p >
31+ < ul >
32+ { activatedApps ?. map ( ( item ) => (
33+ < li key = { item . name . replace ( / \s / g, "" ) } >
34+ < a href = { item . webLink } target = "_blank" rel = "noreferrer" >
35+ < img width = { 50 } src = { item . logoSrc } alt = { `${ item . name } Logo` } />
36+ { item . name }
37+ </ a >
38+ </ li >
39+ ) ) || 'Loading...' }
40+ </ ul >
41+ </ main >
42+ </ LoggedInLayout >
43+ ) ;
44+ }
0 commit comments