Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dummydata.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgresql://neondb_owner:npg_ia4ndyJZDUr6@ep-snowy-firefly-aha21uj0-pooler.c-3.us-east-1.aws.neon.tech/neondb?sslmode=require&channel_binding=require
1 change: 1 addition & 0 deletions mhd
Submodule mhd added at 9ecc06
143 changes: 142 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
"@next/eslint-plugin-next": "^15.5.4",
"dotenv": "^17.2.3",
"drizzle-orm": "^0.44.7",
"framer-motion": "^12.23.24",
"lucide": "^0.544.0",
"lucide-react": "^0.545.0",
"next": "15.5.4",
"pg": "^8.16.3",
"react": "19.1.0",
"react-dom": "19.1.0",
"vercel": "^48.2.0"
"vercel": "^48.2.0",
"zustand": "^5.0.8"
},
"devDependencies": {
"@eslint/js": "^9.37.0",
Expand Down
Binary file added public/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
81 changes: 81 additions & 0 deletions src/app/api/debug-db/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { NextResponse } from "next/server";
import { db } from "@/lib/db";
import { projects, students, schools, teachers } from "@/lib/schema";
import { sql } from "drizzle-orm";

// Temporary debug route to inspect whether the server is connected to the expected DB.
export async function GET() {
try {
// Simple counts to show what's in the connected database
const totalsResult = await db.execute(sql`
SELECT
COUNT(DISTINCT ${projects.schoolId}) AS total_schools,
COUNT(DISTINCT ${projects.teacherId}) AS total_teachers,
COUNT(DISTINCT ${students.id}) AS total_students,
COUNT(${projects.id}) AS total_projects
FROM ${projects}
LEFT JOIN ${students} ON ${students.projectId} = ${projects.id}
`);

const totals = totalsResult.rows[0] || {};

// Check individual table counts with safe try/catch in case tables don't exist
const tableCounts: Record<string, string | number> = {};
try {
const p = await db.execute(
sql`SELECT COUNT(*) AS c FROM ${projects}`,
);
tableCounts.projects = Number(p.rows[0]?.c ?? 0);
} catch (e) {
tableCounts.projects = "missing";
}
try {
const s = await db.execute(
sql`SELECT COUNT(*) AS c FROM ${students}`,
);
tableCounts.students = Number(s.rows[0]?.c ?? 0);
} catch (e) {
tableCounts.students = "missing";
}
try {
const sc = await db.execute(
sql`SELECT COUNT(*) AS c FROM ${schools}`,
);
tableCounts.schools = Number(sc.rows[0]?.c ?? 0);
} catch (e) {
tableCounts.schools = "missing";
}
try {
const t = await db.execute(
sql`SELECT COUNT(*) AS c FROM ${teachers}`,
);
tableCounts.teachers = Number(t.rows[0]?.c ?? 0);
} catch (e) {
tableCounts.teachers = "missing";
}

// Sample up to 5 projects (if the table exists)
let sampleProjects: any[] = [];
try {
const sample = await db.execute(
sql`SELECT * FROM ${projects} LIMIT 5`,
);
sampleProjects = sample.rows || [];
} catch (e) {
sampleProjects = [];
}

// Return a masked DB url presence flag (don't leak full URL)
const hasDbUrl = Boolean(process.env.DATABASE_URL);

return NextResponse.json({
hasDbUrl,
totals,
tableCounts,
sampleProjects,
});
} catch (err) {
console.error("/api/debug-db error:", err);
return NextResponse.json({ error: String(err) }, { status: 500 });
}
}
17 changes: 17 additions & 0 deletions src/app/api/yearly-totals/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NextResponse } from "next/server";
import { getYearlyStats } from "@/lib/yearlyTotals";

export async function GET(req: Request) {
try {
const { searchParams } = new URL(req.url);
const year = parseInt(searchParams.get("year") || "2024");

const data = await getYearlyStats(year);

return NextResponse.json(data);
} catch (err) {
const msg = err instanceof Error ? err.message : String(err);
console.error("/api/yearly-totals error:", err);
return NextResponse.json({ error: msg }, { status: 500 });
}
}
1 change: 1 addition & 0 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
}

:root {
--sidebar-width: 72px;
}

@media (prefers-color-scheme: dark) {
Expand Down
9 changes: 7 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// src/app/layout.tsx
import type { Metadata } from "next";
import React from "react";
import "./globals.css";
import Sidebar from "@/components/Sidebar";

import {
interstate,
millerBanner,
Expand All @@ -23,7 +25,10 @@ export default function RootLayout({
lang="en"
className={`${millerBanner.variable} ${millerDisplay.variable} ${millerText.variable} ${interstate.variable}`}
>
<body className="font-sans">{children}</body>
<body className="font-sans flex flex-row h-screen">
<Sidebar />
<main className="flex-1 flex justify-center">{children}</main>
</body>
</html>
);
}
7 changes: 2 additions & 5 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import NavBar from "@/components/NavBar";
import Dashboard from "@/components/Dashboard";

export default function Home() {
return (
<div className="flex justify-center">
<NavBar />
</div>
);
return <Dashboard />;
}
Loading