Skip to content

Commit a60450b

Browse files
committed
refactor: replace AppHeader with TopBar in various components and introduce FestivalIndicator for better context handling
1 parent 1f283a6 commit a60450b

File tree

11 files changed

+40
-49
lines changed

11 files changed

+40
-49
lines changed

src/components/layout/AppHeader.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { TooltipProvider } from "@/components/ui/tooltip";
33
import { useScrollVisibility } from "@/hooks/useScrollVisibility";
44
import { TopBar } from "./TopBar";
55
import { TitleSection } from "./AppHeader/TitleSection";
6+
import { FestivalIndicator } from "./AppHeader/FestivalIndicator";
67

78
interface AppHeaderProps {
89
// Navigation
@@ -50,10 +51,13 @@ export function AppHeader({
5051
showBackButton={showBackButton}
5152
backLabel={backLabel}
5253
showGroupsButton={showGroupsButton}
53-
isTitleVisible={!shouldShowFestivalIcon}
54-
logoUrl={logoUrl}
55-
title={title}
56-
/>
54+
>
55+
<FestivalIndicator
56+
isTitleVisible={!shouldShowFestivalIcon}
57+
logoUrl={logoUrl}
58+
title={title}
59+
/>
60+
</TopBar>
5761

5862
<div ref={titleRef}>
5963
<TitleSection

src/components/layout/AppHeader/FestivalIndicator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useFestivalEdition } from "@/contexts/FestivalEditionContext";
22

33
interface FestivalIndicatorProps {
4-
isTitleVisible: boolean;
4+
isTitleVisible?: boolean;
55
logoUrl?: string | null;
66
title?: string;
77
}

src/components/layout/TopBar.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
11
import { useIsMobile } from "@/hooks/use-mobile";
22
import { AppBranding } from "./AppHeader/AppBranding";
3-
import { FestivalIndicator } from "./AppHeader/FestivalIndicator";
43
import { UserActions } from "./AppHeader/UserActions";
4+
import { PropsWithChildren } from "react";
55

66
interface TopBarProps {
77
showBackButton?: boolean;
88
backLabel?: string;
99
showGroupsButton?: boolean;
10-
11-
// Festival context
12-
isTitleVisible?: boolean;
13-
logoUrl?: string | null;
14-
title?: string;
1510
}
1611

1712
export function TopBar({
1813
showBackButton = false,
1914
backLabel = "Back",
2015
showGroupsButton = false,
2116

22-
isTitleVisible = false,
23-
logoUrl,
24-
title,
25-
}: TopBarProps) {
17+
children,
18+
}: PropsWithChildren<TopBarProps>) {
2619
const isMobile = useIsMobile();
2720

2821
return (
2922
<>
3023
<div className="fixed top-0 left-0 right-0 z-50 backdrop-blur-md border-b border-purple-400/20 flex items-center px-4 py-3 md:py-4">
3124
<AppBranding isMobile={isMobile} />
3225

33-
<FestivalIndicator
34-
isTitleVisible={isTitleVisible}
35-
logoUrl={logoUrl}
36-
title={title}
37-
/>
26+
{children}
3827

3928
<UserActions
4029
showBackButton={showBackButton}

src/components/router/EditionRoutes.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Navigate, Route } from "react-router-dom";
2-
import EditionView from "@/pages/EditionView/EditionView";
2+
import EditionLayout from "@/pages/EditionView/EditionLayout";
33
import { SetDetails } from "@/pages/SetDetails";
44
import { ExploreSetPage } from "@/pages/ExploreSetPage/ExploreSetPage";
55

@@ -22,8 +22,8 @@ export function createEditionRoutes({
2222
WrapperComponent,
2323
}: EditionRoutesProps) {
2424
const EditionComponent = WrapperComponent
25-
? () => <WrapperComponent component={EditionView} />
26-
: EditionView;
25+
? () => <WrapperComponent component={EditionLayout} />
26+
: EditionLayout;
2727

2828
const SetDetailsComponent = WrapperComponent
2929
? () => <WrapperComponent component={SetDetails} />

src/contexts/FestivalEditionContext.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Festival } from "@/hooks/queries/festivals/types";
1111
import { useFestivalEditionBySlugQuery } from "@/hooks/queries/festivals/editions/useFestivalEditionBySlug";
1212
import { FestivalEdition } from "@/hooks/queries/festivals/editions/types";
1313
import { getSubdomainInfo } from "@/lib/subdomain";
14-
import { AppHeader } from "@/components/layout/AppHeader";
14+
import { TopBar } from "@/components/layout/TopBar";
1515
import { useToast } from "@/hooks/use-toast";
1616

1717
interface FestivalEditionContextType {
@@ -170,10 +170,10 @@ export function FestivalEditionProvider({
170170
<FestivalEditionContext.Provider value={contextValue}>
171171
<div className="min-h-screen bg-app-gradient">
172172
<div className="container mx-auto px-4 py-8">
173-
<AppHeader
174-
backLabel="Back to Festivals"
175-
title="Festival not found"
176-
/>
173+
<TopBar backLabel="Back to Festivals" />
174+
<h1 className="text-4xl font-bold text-white text-center mb-8">
175+
No valid festival or edition found
176+
</h1>
177177
<Navigate to="/" />
178178
</div>
179179
</div>

src/pages/EditionSelection.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useFestivalEditionsForFestivalQuery } from "@/hooks/queries/festivals/e
1515
import { FestivalEdition } from "@/hooks/queries/festivals/editions/types";
1616
import { useEffect } from "react";
1717
import { getSubdomainInfo } from "@/lib/subdomain";
18+
import { TopBar } from "@/components/layout/TopBar";
1819

1920
export default function EditionSelection() {
2021
const { festival } = useFestivalEdition();
@@ -80,11 +81,10 @@ export default function EditionSelection() {
8081
return (
8182
<div className="min-h-screen bg-app-gradient">
8283
<div className="container mx-auto px-4 py-8">
83-
<AppHeader
84-
showBackButton
85-
backLabel="Back to Festivals"
86-
title={festival.name}
87-
/>
84+
<TopBar showBackButton backLabel="Back to Festivals" />
85+
<h1 className="text-4xl font-bold text-white text-center mb-8">
86+
{festival.name}
87+
</h1>
8888

8989
<div className="flex items-center justify-center mt-16">
9090
<Card className="w-full max-w-md bg-white/10 border-purple-400/30">
@@ -144,6 +144,8 @@ export default function EditionSelection() {
144144
showBackButton
145145
backLabel="Back to Festivals"
146146
title={festival.name}
147+
logoUrl={festival.logo_url}
148+
showGroupsButton
147149
/>
148150

149151
<div className="mt-12 grid gap-6 md:grid-cols-2 lg:grid-cols-3">
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import { useFestivalEdition } from "@/contexts/FestivalEditionContext";
55
import { Outlet } from "react-router-dom";
66

77
export default function EditionView() {
8-
// Get festival/edition context
98
const { festival, edition, isContextReady } = useFestivalEdition();
109

11-
// Show loading while context is not ready
1210
if (!isContextReady) {
1311
return (
1412
<div className="min-h-screen bg-app-gradient flex items-center justify-center">
@@ -34,7 +32,6 @@ export default function EditionView() {
3432
showGroupsButton
3533
/>
3634

37-
{/* Main Tab Navigation */}
3835
<MainTabNavigation />
3936

4037
<div className="mt-4 md:mt-8">

src/pages/FestivalSelection.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from "@/components/ui/card";
99
import { useFestivalsQuery } from "@/hooks/queries/festivals/useFestivals";
1010
import { Festival } from "@/hooks/queries/festivals/types";
11-
import { AppHeader } from "@/components/layout/AppHeader";
1211
import { useEffect } from "react";
1312
import {
1413
createFestivalSubdomainUrl,
@@ -17,6 +16,8 @@ import {
1716
import { Link } from "react-router-dom";
1817
import { useCustomLinksQuery } from "@/hooks/queries/custom-links/useCustomLinks";
1918
import { PageTitle } from "@/components/PageTitle/PageTitle";
19+
import { TopBar } from "@/components/layout/TopBar";
20+
import { AppHeader } from "@/components/layout/AppHeader";
2021

2122
export default function FestivalSelection() {
2223
const { data: availableFestivals = [], isLoading: festivalsLoading } =
@@ -52,7 +53,7 @@ export default function FestivalSelection() {
5253
<div className="min-h-screen bg-app-gradient">
5354
<div className="container mx-auto px-4 py-8">
5455
<PageTitle title="Select Festival" />
55-
<AppHeader title="UpLine" />
56+
<TopBar />
5657

5758
<div className="flex items-center justify-center mt-16">
5859
<Card className="w-full max-w-md bg-white/10 border-purple-400/30">

src/pages/SetDetails.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useAuth } from "@/contexts/AuthContext";
1414
import { useVoteCount } from "@/hooks/useVoteCount";
1515
import { PageTitle } from "@/components/PageTitle/PageTitle";
1616
import { TopBar } from "@/components/layout/TopBar";
17+
import { FestivalIndicator } from "@/components/layout/AppHeader/FestivalIndicator";
1718

1819
export function SetDetails() {
1920
const { user } = useAuth();
@@ -47,11 +48,12 @@ export function SetDetails() {
4748
<PageTitle title={setTitle} prefix={festival?.name} />
4849
<div className="min-h-screen bg-app-gradient">
4950
<div className="container mx-auto px-4 py-8">
50-
<TopBar
51-
showBackButton
52-
backLabel="Back to Artists"
53-
logoUrl={festival?.logo_url}
54-
/>
51+
<TopBar showBackButton backLabel="Back to Artists" showGroupsButton>
52+
<FestivalIndicator
53+
title={festival?.name}
54+
logoUrl={festival?.logo_url}
55+
/>
56+
</TopBar>
5557

5658
{/* Set Header */}
5759
{isMultiArtistSet ? (

src/pages/admin/AdminLayout.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ export default function AdminLayout() {
7070
return (
7171
<div className="min-h-screen bg-app-gradient">
7272
<div className="container mx-auto px-4 py-8">
73-
<TopBar
74-
showBackButton
75-
backLabel="Back to app"
76-
title="Admin Dashboard"
77-
/>
73+
<TopBar showBackButton backLabel="Back to app" />
7874

7975
<div>
8076
<Tabs

0 commit comments

Comments
 (0)