File tree Expand file tree Collapse file tree 13 files changed +189
-9
lines changed
group-charter-manager/src
lib/fragments/MaintenanceBanner Expand file tree Collapse file tree 13 files changed +189
-9
lines changed Original file line number Diff line number Diff line change @@ -4,10 +4,13 @@ PUBLIC_PICTIQUE_BASE_URL=your_public_pictique_base_url_here
44# Blabsy Configuration
55PUBLIC_BLABSY_BASE_URL = your_public_blabsy_base_url_here
66
7- # Eid Wallet Configuration
7+ # Eid Wallet & Pictique Configuration (Svelte)
88PUBLIC_REGISTRY_URL = your_public_registry_url_here
99PUBLIC_PROVISIONER_URL = your_public_provisioner_url_here
1010
11+ # Next.js Applications Configuration (eVoting, Blabsy, Group Charter Manager)
12+ NEXT_PUBLIC_REGISTRY_URL = your_public_registry_url_here
13+
1114# Neo4j Configuration
1215NEO4J_URI = bolt://neo4j:7687
1316NEO4J_USER = neo4j
Original file line number Diff line number Diff line change 1+ # Registry URL for fetching motd and other registry services
2+ # Note: In Next.js, environment variables exposed to the browser must be prefixed with NEXT_PUBLIC_
3+ NEXT_PUBLIC_REGISTRY_URL = http://localhost:4321
4+
Original file line number Diff line number Diff line change 1+ import { useEffect , useState } from 'react' ;
2+ import axios from 'axios' ;
3+
4+ interface Motd {
5+ status : 'up' | 'maintenance' ;
6+ message : string ;
7+ }
8+
9+ export function MaintenanceBanner ( ) : JSX . Element | null {
10+ const [ motd , setMotd ] = useState < Motd | null > ( null ) ;
11+
12+ useEffect ( ( ) => {
13+ const fetchMotd = async ( ) => {
14+ try {
15+ const registryUrl = process . env . NEXT_PUBLIC_REGISTRY_URL || 'http://localhost:4321' ;
16+ const response = await axios . get < Motd > ( `${ registryUrl } /motd` ) ;
17+ setMotd ( response . data ) ;
18+ } catch ( error ) {
19+ console . error ( 'Failed to fetch motd:' , error ) ;
20+ }
21+ } ;
22+
23+ void fetchMotd ( ) ;
24+ } , [ ] ) ;
25+
26+ if ( motd ?. status !== 'maintenance' ) {
27+ return null ;
28+ }
29+
30+ return (
31+ < div className = 'bg-yellow-500 px-4 py-3 text-center text-sm font-medium text-black' >
32+ ⚠️ { motd . message }
33+ </ div >
34+ ) ;
35+ }
36+
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import '@styles/globals.scss';
33import { AuthContextProvider } from '@lib/context/auth-context' ;
44import { ThemeContextProvider } from '@lib/context/theme-context' ;
55import { AppHead } from '@components/common/app-head' ;
6+ import { MaintenanceBanner } from '@components/common/maintenance-banner' ;
67import type { ReactElement , ReactNode } from 'react' ;
78import type { NextPage } from 'next' ;
89import type { AppProps } from 'next/app' ;
@@ -24,6 +25,7 @@ export default function App({
2425 return (
2526 < >
2627 < AppHead />
28+ < MaintenanceBanner />
2729 < AuthContextProvider >
2830 < ThemeContextProvider >
2931 { getLayout ( < Component { ...pageProps } /> ) }
Original file line number Diff line number Diff line change 11import type { Metadata } from "next" ;
22import "./globals.css" ;
33import { AuthProvider } from "@/lib/auth-context" ;
4+ import { MaintenanceBanner } from "@/components/MaintenanceBanner" ;
45
56export const metadata : Metadata = {
67 title : "eVoting Platform" ,
@@ -18,6 +19,7 @@ export default function RootLayout({
1819 return (
1920 < html lang = "en" >
2021 < body >
22+ < MaintenanceBanner />
2123 < AuthProvider >
2224 { children }
2325 </ AuthProvider >
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { useEffect , useState } from 'react' ;
4+ import axios from 'axios' ;
5+
6+ interface Motd {
7+ status : 'up' | 'maintenance' ;
8+ message : string ;
9+ }
10+
11+ export function MaintenanceBanner ( ) {
12+ const [ motd , setMotd ] = useState < Motd | null > ( null ) ;
13+
14+ useEffect ( ( ) => {
15+ const fetchMotd = async ( ) => {
16+ try {
17+ const registryUrl = process . env . NEXT_PUBLIC_REGISTRY_URL || 'http://localhost:4321' ;
18+ const response = await axios . get < Motd > ( `${ registryUrl } /motd` ) ;
19+ setMotd ( response . data ) ;
20+ } catch ( error ) {
21+ console . error ( 'Failed to fetch motd:' , error ) ;
22+ }
23+ } ;
24+
25+ fetchMotd ( ) ;
26+ } , [ ] ) ;
27+
28+ if ( motd ?. status !== 'maintenance' ) {
29+ return null ;
30+ }
31+
32+ return (
33+ < div className = "bg-yellow-500 px-4 py-3 text-center text-sm font-medium text-black" >
34+ ⚠️ { motd . message }
35+ </ div >
36+ ) ;
37+ }
38+
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import "./globals.css";
44import { Toaster } from "@/components/ui/toaster" ;
55import { AuthProvider } from "@/components/auth/auth-provider" ;
66import DisclaimerModal from "@/components/disclaimer-modal" ;
7+ import { MaintenanceBanner } from "@/components/MaintenanceBanner" ;
78
89const inter = Inter ( { subsets : [ "latin" ] } ) ;
910
@@ -23,6 +24,7 @@ export default function RootLayout({
2324 return (
2425 < html lang = "en" >
2526 < body className = { inter . className } >
27+ < MaintenanceBanner />
2628 < AuthProvider >
2729 { children }
2830 < Toaster />
Original file line number Diff line number Diff line change 1+ 'use client' ;
2+
3+ import { useEffect , useState } from 'react' ;
4+ import axios from 'axios' ;
5+
6+ interface Motd {
7+ status : 'up' | 'maintenance' ;
8+ message : string ;
9+ }
10+
11+ export function MaintenanceBanner ( ) {
12+ const [ motd , setMotd ] = useState < Motd | null > ( null ) ;
13+
14+ useEffect ( ( ) => {
15+ const fetchMotd = async ( ) => {
16+ try {
17+ const registryUrl = process . env . NEXT_PUBLIC_REGISTRY_URL || 'http://localhost:4321' ;
18+ const response = await axios . get < Motd > ( `${ registryUrl } /motd` ) ;
19+ setMotd ( response . data ) ;
20+ } catch ( error ) {
21+ console . error ( 'Failed to fetch motd:' , error ) ;
22+ }
23+ } ;
24+
25+ fetchMotd ( ) ;
26+ } , [ ] ) ;
27+
28+ if ( motd ?. status !== 'maintenance' ) {
29+ return null ;
30+ }
31+
32+ return (
33+ < div className = "bg-yellow-500 px-4 py-3 text-center text-sm font-medium text-black" >
34+ ⚠️ { motd . message }
35+ </ div >
36+ ) ;
37+ }
38+
Original file line number Diff line number Diff line change 1+ # Registry URL for fetching motd and other registry services
2+ # Note: In SvelteKit, public environment variables must be prefixed with PUBLIC_
3+ PUBLIC_REGISTRY_URL = http://localhost:4321
4+
Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import { onMount } from ' svelte' ;
3+ import axios from ' axios' ;
4+ import { PUBLIC_REGISTRY_URL } from ' $env/static/public' ;
5+
6+ let motd = $state <{ status: ' up' | ' maintenance' ; message: string } | null >(null );
7+
8+ onMount (async () => {
9+ try {
10+ const registryUrl = PUBLIC_REGISTRY_URL || ' http://localhost:4321' ;
11+ const response = await axios .get (` ${registryUrl }/motd ` );
12+ motd = response .data ;
13+ } catch (error ) {
14+ console .error (' Failed to fetch motd:' , error );
15+ }
16+ });
17+ </script >
18+
19+ {#if motd ?.status === ' maintenance' }
20+ <div class =" bg-yellow-500 px-4 py-3 text-center text-sm font-medium text-black" >
21+ ⚠️ {motd .message }
22+ </div >
23+ {/if }
You can’t perform that action at this time.
0 commit comments