11import { h , Fragment , ComponentChildren } from 'preact' ;
22import { useContext } from 'preact/hooks' ;
33
4+ import { Event } from '@shared/DbTypes' ;
45import AppContext from '@/AppContext' ;
56import MenuBar from '../MenuBar' ;
67import AppErrorMessage , { ErrorMessageType } from '../ErrorMessage' ;
@@ -14,29 +15,35 @@ type AutomatedProps = {
1415 }
1516} ;
1617
17- const Automated = ( props : AutomatedProps ) => {
18- const { event, season } = useContext ( AppContext ) ;
19- const { matches : { playoff, qual } } = props ;
20-
21- const ErrorMessage = ( { children, type } : {
22- children : ComponentChildren ,
23- type ?: ErrorMessageType ,
24- } ) => (
18+ function ErrorMessage ( {
19+ children, type, event, season,
20+ } : {
21+ children : ComponentChildren ,
22+ type ?: ErrorMessageType ,
23+ event : Event | undefined ,
24+ season : number | undefined
25+ } ) {
26+ return (
2527 < >
2628 < MenuBar event = { event } season = { season } alwaysShow />
2729 < div >
2830 < AppErrorMessage type = { type } > { children } </ AppErrorMessage >
2931 </ div >
3032 </ >
3133 ) ;
34+ }
35+
36+ ErrorMessage . defaultProps = {
37+ type : 'info' ,
38+ } ;
3239
33- ErrorMessage . defaultProps = {
34- type : 'info' ,
35- } ;
40+ function Automated ( props : AutomatedProps ) {
41+ const { event , season } = useContext ( AppContext ) ;
42+ const { matches : { playoff , qual } } = props ;
3643
3744 if ( ! playoff || ! qual ) {
3845 return (
39- < ErrorMessage >
46+ < ErrorMessage event = { event } season = { season } >
4047 You're missing some configuration info... Try going
4148 { ' ' }
4249 { ' ' }
@@ -54,7 +61,7 @@ const Automated = (props: AutomatedProps) => {
5461 const routeToUse = Routes . find ( ( r ) => r . url === qual && r . usedIn . includes ( 'qual' ) ) ;
5562 if ( ! routeToUse ) {
5663 return (
57- < ErrorMessage >
64+ < ErrorMessage event = { event } season = { season } >
5865 Double check your configuration, something isn't right here...
5966 </ ErrorMessage >
6067 ) ;
@@ -67,7 +74,7 @@ const Automated = (props: AutomatedProps) => {
6774 const routeToUse = Routes . find ( ( r ) => r . url === playoff && r . usedIn . includes ( 'playoff' ) ) ;
6875 if ( ! routeToUse ) {
6976 return (
70- < ErrorMessage >
77+ < ErrorMessage event = { event } season = { season } >
7178 Double check your configuration, something isn't right here...
7279 </ ErrorMessage >
7380 ) ;
@@ -76,17 +83,17 @@ const Automated = (props: AutomatedProps) => {
7683 }
7784 case 'EventOver' :
7885 return (
79- < ErrorMessage type = "arrow" >
86+ < ErrorMessage type = "arrow" event = { event } season = { season } >
8087 The event has ended. See you next time!
8188 </ ErrorMessage >
8289 ) ;
8390 default :
8491 return (
85- < ErrorMessage >
92+ < ErrorMessage event = { event } season = { season } >
8693 Hmm... I'm not sure what the event is up to right now...
8794 </ ErrorMessage >
8895 ) ;
8996 }
90- } ;
97+ }
9198
9299export default Automated ;
0 commit comments