1- ' use client' ;
1+ " use client" ;
22
3- import { useEffect , useState } from ' react' ;
4- import axios from ' axios' ;
3+ import { useEffect , useState } from " react" ;
4+ import axios from " axios" ;
55
66interface Motd {
7- status : 'up' | ' maintenance' ;
7+ status : "up" | " maintenance" ;
88 message : string ;
99}
1010
11- const DISMISSED_KEY = ' maintenance-banner-dismissed' ;
11+ const DISMISSED_KEY = " maintenance-banner-dismissed" ;
1212
1313export function MaintenanceBanner ( ) {
1414 const [ motd , setMotd ] = useState < Motd | null > ( null ) ;
@@ -17,17 +17,21 @@ export function MaintenanceBanner() {
1717 useEffect ( ( ) => {
1818 const fetchMotd = async ( ) => {
1919 try {
20- const registryUrl = process . env . NEXT_PUBLIC_REGISTRY_URL || 'http://localhost:4321' ;
20+ const registryUrl = process . env . NEXT_PUBLIC_REGISTRY_URL ;
21+ if ( ! registryUrl ) {
22+ // Skip fetching in local dev if env var not set
23+ return ;
24+ }
2125 const response = await axios . get < Motd > ( `${ registryUrl } /motd` ) ;
2226 setMotd ( response . data ) ;
23-
27+
2428 // Check if this message has been dismissed
25- if ( response . data . status === ' maintenance' ) {
29+ if ( response . data . status === " maintenance" ) {
2630 const dismissed = localStorage . getItem ( DISMISSED_KEY ) ;
2731 setIsDismissed ( dismissed === response . data . message ) ;
2832 }
2933 } catch ( error ) {
30- console . error ( ' Failed to fetch motd:' , error ) ;
34+ console . error ( " Failed to fetch motd:" , error ) ;
3135 }
3236 } ;
3337
@@ -41,7 +45,7 @@ export function MaintenanceBanner() {
4145 }
4246 } ;
4347
44- if ( motd ?. status !== ' maintenance' || isDismissed ) {
48+ if ( motd ?. status !== " maintenance" || isDismissed ) {
4549 return null ;
4650 }
4751
@@ -71,4 +75,3 @@ export function MaintenanceBanner() {
7175 </ div >
7276 ) ;
7377}
74-
0 commit comments