GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #1 from aidrivencoder/dev · aidrivencoder/master-git-github@35cdfac

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • firebase.json
  • firebase.rules
  • firestore.indexes.json
  • package-lock.json
  • package.json
  • src
    • app
      • admin
        • layout.tsx
        • page.tsx
        • subscriptions
          • page.tsx
        • tutorials
          • page.tsx
        • users
          • page.tsx
      • api
        • cancel-subscription
          • route.ts
        • create-checkout-session
          • route.ts
        • create-portal-session
          • route.ts
        • webhooks/stripe
          • route.ts
      • dashboard
        • page.tsx
      • globals.css
      • page.tsx
      • pricing
        • page.tsx
      • profile
        • page.tsx
      • tutorials
        • [id]
          • page.tsx
        • page.tsx
    • components
      • auth
        • LoginForm.tsx
        • SignUpForm.tsx
      • premium
        • PremiumContent.tsx
      • profile
        • SubscriptionManager.tsx
      • providers
        • AuthProvider.tsx
      • theme
        • ThemeProvider.tsx
        • ThemeToggle.tsx
      • tutorials
        • CodeBlock.tsx
        • GitCommandButtons.tsx
        • GitCommandSimulator.tsx
        • GitVisualizer.tsx
        • GitVisualizerV2.tsx
        • InteractiveTutorial.tsx
        • MarkdownContent.tsx
        • Quiz.tsx
        • StepNavigation.tsx
        • TutorialCard.tsx
        • TutorialPage.tsx
        • TutorialViewer.tsx
      • ui
        • LoadingSpinner.tsx
    • lib
      • firebase
        • auth.ts
        • config.ts
        • config
          • firebase-admin.ts
        • init
          • adminData.ts
          • initialize-collections.ts
        • schema
          • checkout.ts
        • services
          • initializeTutorials.ts
          • tutorials.ts
        • user.ts
      • hooks
        • useTutorialProgress.ts
      • stripe
        • checkout.ts
      • tutorials
        • git-basics.ts
        • index.ts
    • styles
      • prism-theme.css
    • tutorials/data
      • git-advanced.ts
      • git-basics.ts
      • git-branching.ts
      • git-remote.ts
      • git-visual.ts
      • index.ts
    • types
      • subscription.ts
      • user.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎firebase.json‎

Copy file name to clipboard
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"firestore": {
3+
"rules": "firebase.rules",
4+
"indexes": "firestore.indexes.json"
5+
}
6+
}
Collapse file

‎firebase.rules‎

Copy file name to clipboardExpand all lines: firebase.rules
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,13 @@ service cloud.firestore {
5454
);
5555
allow write: if isAdmin();
5656
}
57+
58+
// Checkout Sessions collection
59+
match /checkoutSessions/{sessionId} {
60+
allow read: if isAuthenticated() && (
61+
resource.data.userId == request.auth.uid || isAdmin()
62+
);
63+
allow write: if isAdmin();
64+
}
5765
}
58-
}
66+
}
Collapse file

‎firestore.indexes.json‎

Copy file name to clipboard
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"indexes": [],
3+
"fieldOverrides": []
4+
}
Collapse file

‎package-lock.json‎

Copy file name to clipboardExpand all lines: package-lock.json
+4Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,44 @@
1212
"@headlessui/react": "^1.7.17",
1313
"@heroicons/react": "^2.0.18",
1414
"@mdx-js/react": "^3.0.0",
15-
"@uiw/react-markdown-preview": "^5.0.3",
16-
"@uiw/react-md-editor": "^4.0.1",
17-
"prismjs": "^1.29.0",
1815
"@stripe/stripe-js": "^2.1.7",
1916
"@tanstack/react-query": "^4.36.1",
17+
"@uiw/react-markdown-preview": "^5.0.3",
18+
"@uiw/react-md-editor": "^4.0.1",
2019
"firebase": "^9.23.0",
2120
"firebase-admin": "^11.11.0",
2221
"firebase-tools": "^12.7.0",
2322
"next": "13.4.19",
23+
"prismjs": "^1.29.0",
2424
"react": "18.2.0",
2525
"react-dom": "18.2.0",
26-
"react-syntax-highlighter": "^15.5.0",
2726
"react-error-boundary": "^4.0.11",
27+
"react-markdown": "^9.0.1",
28+
"react-syntax-highlighter": "^15.5.0",
29+
"rehype-prism-plus": "^2.0.0",
30+
"rehype-raw": "^7.0.0",
31+
"remark-gfm": "^4.0.0",
2832
"stripe": "^13.9.0",
2933
"zustand": "^4.4.3"
3034
},
3135
"devDependencies": {
3236
"@babel/core": "^7.23.0",
3337
"@babel/plugin-proposal-class-properties": "^7.18.6",
34-
"@next/bundle-analyzer": "^13.5.4",
3538
"@babel/plugin-proposal-private-methods": "^7.18.6",
3639
"@babel/preset-env": "^7.22.20",
40+
"@next/bundle-analyzer": "^13.5.4",
3741
"@types/node": "^20.8.4",
3842
"@types/prismjs": "^1.26.3",
39-
"@types/react-syntax-highlighter": "^15.5.11",
4043
"@types/react": "18.2.0",
4144
"@types/react-dom": "18.2.0",
45+
"@types/react-syntax-highlighter": "^15.5.11",
4246
"autoprefixer": "^10.4.16",
4347
"babel-loader": "^9.1.3",
4448
"eslint": "^8.51.0",
4549
"eslint-config-next": "13.4.19",
4650
"postcss": "^8.4.31",
47-
"tailwindcss": "^3.3.3",
4851
"raw-loader": "^4.0.2",
52+
"tailwindcss": "^3.3.3",
4953
"typescript": "^5.2.2"
5054
}
5155
}
Collapse file

‎src/app/admin/layout.tsx‎

Copy file name to clipboard
+143Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
'use client';
2+
3+
import { useEffect, useState } from 'react';
4+
import { useRouter } from 'next/navigation';
5+
import Link from 'next/link';
6+
import { auth } from '@/lib/firebase/config';
7+
import { onAuthStateChanged } from 'firebase/auth';
8+
import { db } from '@/lib/firebase/config';
9+
import { doc, getDoc } from 'firebase/firestore';
10+
11+
interface NavItem {
12+
label: string;
13+
href: string;
14+
icon: string;
15+
}
16+
17+
const navItems: NavItem[] = [
18+
{
19+
label: 'Overview',
20+
href: '/admin',
21+
icon: '📊'
22+
},
23+
{
24+
label: 'Users',
25+
href: '/admin/users',
26+
icon: '👥'
27+
},
28+
{
29+
label: 'Tutorials',
30+
href: '/admin/tutorials',
31+
icon: '📚'
32+
},
33+
{
34+
label: 'Subscriptions',
35+
href: '/admin/subscriptions',
36+
icon: '💳'
37+
}
38+
];
39+
40+
export default function AdminLayout({
41+
children,
42+
}: {
43+
children: React.ReactNode;
44+
}) {
45+
const [loading, setLoading] = useState(true);
46+
const [isAdmin, setIsAdmin] = useState(false);
47+
const router = useRouter();
48+
49+
useEffect(() => {
50+
const unsubscribe = onAuthStateChanged(auth, async (user) => {
51+
if (!user) {
52+
router.push('/login');
53+
setLoading(false);
54+
return;
55+
}
56+
57+
try {
58+
// Check if user has admin role in Firestore
59+
const userDoc = await getDoc(doc(db, 'users', user.uid));
60+
const userData = userDoc.data();
61+
62+
if (!userData || userData.role !== 'admin') {
63+
router.push('/login');
64+
setLoading(false);
65+
return;
66+
}
67+
68+
setIsAdmin(true);
69+
} catch (error) {
70+
console.error('Error checking admin status:', error);
71+
router.push('/login');
72+
} finally {
73+
setLoading(false);
74+
}
75+
});
76+
77+
return () => unsubscribe();
78+
}, [router]);
79+
80+
if (loading) {
81+
return (
82+
<div className="flex items-center justify-center min-h-screen">
83+
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900"></div>
84+
</div>
85+
);
86+
}
87+
88+
if (!isAdmin) {
89+
return null;
90+
}
91+
92+
return (
93+
<div className="min-h-screen bg-gray-100">
94+
<div className="flex">
95+
{/* Admin Sidebar */}
96+
<div className="w-64 min-h-screen bg-white shadow-lg">
97+
<div className="p-6 border-b">
98+
<h2 className="text-xl font-bold text-gray-800">Admin Dashboard</h2>
99+
</div>
100+
<nav className="mt-6">
101+
{navItems.map((item) => (
102+
<Link
103+
key={item.href}
104+
href={item.href}
105+
className={`flex items-center px-6 py-3 text-gray-700 hover:bg-gray-100 hover:text-gray-900 transition-colors duration-200 ${
106+
typeof window !== 'undefined' && window.location.pathname === item.href
107+
? 'bg-gray-100 text-gray-900'
108+
: ''
109+
}`}
110+
>
111+
<span className="mr-3">{item.icon}</span>
112+
{item.label}
113+
</Link>
114+
))}
115+
</nav>
116+
117+
<div className="absolute bottom-0 w-64 p-6 border-t">
118+
<div className="flex items-center">
119+
<div className="ml-3">
120+
<p className="text-sm font-medium text-gray-700">
121+
{auth.currentUser?.email}
122+
</p>
123+
<button
124+
onClick={() => auth.signOut()}
125+
className="text-sm text-red-600 hover:text-red-800"
126+
>
127+
Sign Out
128+
</button>
129+
</div>
130+
</div>
131+
</div>
132+
</div>
133+
134+
{/* Main Content */}
135+
<div className="flex-1 overflow-auto">
136+
<div className="p-6">
137+
{children}
138+
</div>
139+
</div>
140+
</div>
141+
</div>
142+
);
143+
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.