-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathApp.tsx
More file actions
133 lines (122 loc) · 4.13 KB
/
App.tsx
File metadata and controls
133 lines (122 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { useState } from "react";
import { Routes, Route, Link, useLocation } from "react-router-dom";
import { IdTokenExample } from "./components/IdTokenExample";
import { CollectionQueryExample } from "./components/CollectionQueryExample";
import "./firebase";
function App() {
const [queryClient] = useState(
() =>
new QueryClient({
defaultOptions: {
queries: {
staleTime: 60 * 1000,
},
},
})
);
return (
<QueryClientProvider client={queryClient}>
<div className="min-h-screen bg-gray-50">
<Navigation />
<div className="py-12">
<div className="max-w-6xl mx-auto px-4">
<Routes>
<Route path="/" element={<Home />} />
<Route path="/auth/id-token" element={<IdTokenExample />} />
<Route
path="/firestore/collection-query"
element={<CollectionQueryExample />}
/>
</Routes>
</div>
</div>
</div>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
}
function Navigation() {
const location = useLocation();
const navItems = [
{ path: "/", label: "Home" },
{ path: "/auth/id-token", label: "ID Token Query" },
{ path: "/firestore/collection-query", label: "Collection Query" },
];
return (
<nav className="bg-white shadow-sm border-b">
<div className="max-w-6xl mx-auto px-4">
<div className="flex items-center justify-between h-16">
<div className="flex items-center space-x-8">
<h1 className="text-xl font-bold text-gray-900">
TanStack Query Firebase
</h1>
<div className="flex space-x-4">
{navItems.map((item) => (
<Link
key={item.path}
to={item.path}
className={`px-3 py-2 rounded-md text-sm font-medium transition-colors ${
location.pathname === item.path
? "bg-blue-100 text-blue-700"
: "text-gray-600 hover:text-gray-900 hover:bg-gray-100"
}`}
>
{item.label}
</Link>
))}
</div>
</div>
</div>
</div>
</nav>
);
}
function Home() {
return (
<div className="text-center">
<h1 className="text-4xl font-bold text-gray-900 mb-4">
TanStack Query Firebase Examples
</h1>
<p className="text-xl text-gray-600 mb-8">
Explore different Firebase hooks and patterns with TanStack Query
</p>
<div className="grid md:grid-cols-2 gap-6 max-w-4xl mx-auto">
<div className="bg-white rounded-lg shadow-md p-6">
<h2 className="text-2xl font-bold text-gray-900 mb-4">
Authentication
</h2>
<p className="text-gray-600 mb-4">
Examples of Firebase Authentication hooks including ID token
management.
</p>
<Link
to="/auth/id-token"
className="inline-block bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 transition-colors"
>
View ID Token Example
</Link>
</div>
<div className="bg-white rounded-lg shadow-md p-6">
<h2 className="text-2xl font-bold text-gray-900 mb-4">Firestore</h2>
<p className="text-gray-600 mb-4">
Examples of Firestore hooks for querying collections and documents.
</p>
<Link
to="/firestore/collection-query"
className="inline-block bg-green-600 text-white px-4 py-2 rounded-md hover:bg-green-700 transition-colors"
>
View Collection Query Example
</Link>
</div>
</div>
<div className="mt-12 text-center">
<p className="text-gray-500">
Built with Vite, TanStack Query, React Router, and Firebase
</p>
</div>
</div>
);
}
export default App;