1- import { Accordion , AccordionDetails , AccordionSummary , Alert , Button , Card , CardContent , IconButton , Link , Typography } from "@mui/material" ;
1+ import { Accordion , AccordionDetails , AccordionSummary , Button , Card , CardContent , IconButton , Link , Typography } from "@mui/material" ;
22import { ModuleStatus } from "../../common/TrainingModuleUtils" ;
33import { Box , Stack } from "@mui/system" ;
4- import ModuleStatusRow from "../../common/ModuleStatusRow" ;
54import { isManagerFor } from "../../common/PrivilegeUtils" ;
65import EditIcon from "@mui/icons-material/Edit" ;
76import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp" ;
@@ -15,9 +14,9 @@ import CurrentHours from "../../common/CurrentHours";
1514import { useState } from "react" ;
1615import { useIsMobile } from "../../common/IsMobileProvider" ;
1716
18- function HoursCard ( hours : MakerspaceHours [ ] ) {
17+ function HoursCard ( hours : MakerspaceHours [ ] , isMobile : boolean ) {
1918 return (
20- < Card sx = { { width : "100%" , height : "auto" } } >
19+ < Card sx = { { width : isMobile ? "100%" : "30 %", height : "auto" } } >
2120 < CardContent >
2221 < Typography variant = "h6" textAlign = { "center" } >
2322 Hours
@@ -28,9 +27,9 @@ function HoursCard(hours: MakerspaceHours[]) {
2827 ) ;
2928}
3029
31- function AboutCard ( { location, description, docsLink } : FullMakerspace ) {
30+ function AboutCard ( { location, description, docsLink } : FullMakerspace , isMobile : boolean ) {
3231 return (
33- < Card sx = { { width : "100%" , height : "auto" } } >
32+ < Card sx = { { width : isMobile ? "100%" : "70 %", height : "auto" } } >
3433 < CardContent >
3534 < Typography variant = "h6" textAlign = { "center" } >
3635 About
@@ -45,35 +44,6 @@ function AboutCard({ location, description, docsLink }: FullMakerspace) {
4544 ) ;
4645}
4746
48- function MakerspaceTrainingCard ( makerspaceTrainings : ModuleStatus [ ] , user : any ) {
49- return (
50- < Card sx = { { width : "100%" , height : "auto" } } >
51- < CardContent >
52- < Typography variant = "h6" textAlign = { "center" } >
53- Makerspace Trainings
54- </ Typography >
55-
56- < Stack direction = { "column" } spacing = { 2 } alignItems = { "center" } >
57- < Stack direction = { "column" } spacing = { 2 } alignItems = { "center" } >
58- { user . visitor ? (
59- < Alert severity = "info" > Log in to view training progress.</ Alert >
60- ) : makerspaceTrainings . some ( ( ms ) => ms . status !== "Passed" && ms . status !== "Expiring Soon" ) ? (
61- < Alert severity = "error" >
62- You must pass the makerspace trainings before you can use equipment in the makerspace!
63- </ Alert >
64- ) : null }
65- </ Stack >
66- < Stack direction = { "column" } spacing = { 1 } >
67- { makerspaceTrainings . map ( ( ms : ModuleStatus ) => (
68- < ModuleStatusRow ms = { ms } />
69- ) ) }
70- </ Stack >
71- </ Stack >
72- </ CardContent >
73- </ Card >
74- ) ;
75- }
76-
7747export interface ExpandableHeaderProps {
7848 makerspace : FullMakerspace ;
7949 makerspaceTrainings : ModuleStatus [ ] ;
@@ -87,9 +57,6 @@ function TitleRow(
8757 id : number ,
8858 canEdit : boolean ,
8959 hours : MakerspaceHours [ ] ,
90- hasIncomplete : boolean ,
91- hasExpiring : boolean ,
92- user : any
9360) {
9461 const title = < Typography variant = { isMobile ? "h4" : "h3" } > { name } </ Typography > ;
9562
@@ -109,17 +76,6 @@ function TitleRow(
10976 </ IconButton >
11077 ) : null ;
11178
112- const alert = user . visitor ? (
113- // user is not logged in
114- < Alert severity = "info" > Log in to view training progress.</ Alert >
115- ) : hasIncomplete ? (
116- // user is logged in with incomplete trainings
117- < Alert severity = "error" > You have incomplete makerspace trainings.</ Alert >
118- ) : hasExpiring ? (
119- // user is logged in with expiring trainings
120- < Alert severity = "warning" > You have makerspace trainings that expire soon.</ Alert >
121- ) : undefined ;
122-
12379 const hoursElement = < CurrentHours times = { hours } fillLine = { isMobile } showDay = { false } /> ;
12480
12581 const expandButton = (
@@ -151,7 +107,6 @@ function TitleRow(
151107 < Stack direction = { "column" } width = { "100%" } spacing = { "5px" } >
152108 { titleAndEdit }
153109 { hoursElement }
154- { alert }
155110 { expandButton }
156111 </ Stack >
157112 ) ;
@@ -160,7 +115,6 @@ function TitleRow(
160115 return (
161116 < Stack direction = { "row" } alignItems = { "center" } justifyContent = { "space-between" } spacing = { "15px" } width = { "100%" } >
162117 { titleAndEdit }
163- { alert }
164118 < Box flexGrow = { 1 } > </ Box >
165119 { hoursElement }
166120 { expandButton }
@@ -173,11 +127,7 @@ export default function ExpandableHeader({ makerspace, makerspaceTrainings }: Ex
173127 const navigate = useNavigate ( ) ;
174128 const isMobile = useIsMobile ( ) ;
175129
176- const hasIncompleteSpaceTrainings = makerspaceTrainings . some (
177- ( ms ) => ms . status !== "Passed" && ms . status !== "Expiring Soon"
178- ) ;
179- const hasExpiringSoonSpaceTrainings = makerspaceTrainings . some ( ( ms ) => ms . status === "Expiring Soon" ) ;
180- const [ expanded , setExpanded ] = useState < boolean > ( hasIncompleteSpaceTrainings || hasExpiringSoonSpaceTrainings ) ;
130+ const [ expanded , setExpanded ] = useState < boolean > ( user . visitor ) ;
181131
182132 return (
183133 < Accordion expanded = { expanded } sx = { { border : "none" } } elevation = { 0 } onChange = { ( ) => setExpanded ( ! expanded ) } >
@@ -190,18 +140,14 @@ export default function ExpandableHeader({ makerspace, makerspaceTrainings }: Ex
190140 makerspace . id ,
191141 isManagerFor ( user , Number ( makerspace . id ) ) ,
192142 makerspace . hours ,
193- hasIncompleteSpaceTrainings ,
194- hasExpiringSoonSpaceTrainings ,
195- user
196143 ) }
197144 </ AccordionSummary >
198145
199146 < AccordionDetails >
200147 { makerspaceTrainings . length > 0 && (
201148 < Stack direction = { isMobile ? "column" : "row" } spacing = { isMobile ? 2 : 5 } justifyContent = "space-around" flexGrow = { 0 } >
202- { AboutCard ( makerspace ) }
203- { HoursCard ( makerspace . hours ) }
204- { MakerspaceTrainingCard ( makerspaceTrainings , user ) }
149+ { AboutCard ( makerspace , isMobile ) }
150+ { HoursCard ( makerspace . hours , isMobile ) }
205151 </ Stack >
206152 ) }
207153 </ AccordionDetails >
0 commit comments