Skip to content
Merged
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
3,513 changes: 2,035 additions & 1,478 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-tooltip": "^1.2.8",
"@react-pdf/renderer": "^4.5.1",
"@shadcn/ui": "^0.0.4",
"@tanstack/react-table": "^8.21.3",
"better-auth": "^1.4.1",
Expand All @@ -34,14 +35,16 @@
"csv-parse": "^6.1.0",
"d3": "^7.9.0",
"dotenv": "^17.2.3",
"drizzle-orm": "^0.44.7",
"drizzle-orm": "^0.45.2",
"framer-motion": "^12.23.24",
"html2canvas-pro": "^1.6.6",
"jspdf": "^4.0.0",
"gradient-border-plugin": "^1.1.3",
"input-otp": "^1.4.2",
"lucide": "^0.544.0",
"lucide-react": "^0.545.0",
"maplibre-gl": "^5.16.0",
"next": "^16.0.7",
"nuqs": "^2.8.9",
"pako": "^2.1.0",
"pg": "^8.16.3",
"react": "^19.2.2",
"react-dom": "^19.2.2",
Expand Down
Binary file added public/fonts/dmsans.ttf
Binary file not shown.
55 changes: 52 additions & 3 deletions src/app/api/schools/[name]/[town]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { eq, sql, and, sum } from "drizzle-orm";
import { findRegionOf } from "@/lib/region-finder";
import { schoolPatchBodySchema } from "@/lib/api-schemas";
import { parseOrError, internalError } from "@/lib/api-utils";
import { standardize } from "@/lib/string-standardize";

type YearlySchoolFields = {
division?: string[];
Expand Down Expand Up @@ -86,7 +87,11 @@ export async function PATCH(
} = parsed.data;

const schoolResult = await db
.select({ id: schools.id })
.select({
id: schools.id,
standardizedName: schools.standardizedName,
name: schools.name,
})
.from(schools)
.where(
and(
Expand All @@ -103,7 +108,8 @@ export async function PATCH(
);
}

const schoolId = schoolResult[0].id;
const schoolRow = schoolResult[0];
const schoolId = schoolRow.id;

if (city !== undefined) {
await db
Expand All @@ -114,12 +120,55 @@ export async function PATCH(
}

if (newName !== undefined) {
const trimmed = newName.trim();
const newStd = standardize(trimmed);
if (!newStd) {
return NextResponse.json(
{
error: "That name cannot be used — it normalizes to an empty slug (try adding a location or unique word).",
},
{ status: 400 },
);
}

const oldStd = schoolRow.standardizedName;
if (newStd !== oldStd) {
const collision = await db
.select({ id: schools.id })
.from(schools)
.where(eq(schools.standardizedName, newStd))
.limit(1);
if (collision.length > 0 && collision[0].id !== schoolId) {
return NextResponse.json(
{
error: "A school with this name already exists",
},
{ status: 409 },
);
}
}

await db
.update(schools)
.set({ name: newName })
.set({ name: trimmed, standardizedName: newStd })
.where(eq(schools.id, schoolId));

if (newStd !== oldStd) {
try {
await db.insert(schoolHistoricNames).values({
absorbingSchoolId: schoolId,
mergedName: schoolRow.name,
mergedStandardizedName: oldStd,
mergedExternalSchoolId: null,
});
} catch {
/* duplicate historic slug or race — old URL may not redirect */
}
}

return NextResponse.json({
message: "School name updated successfully",
standardizedName: newStd,
});
}

Expand Down
12 changes: 0 additions & 12 deletions src/app/fonts/DMSans-VariableFont_opsz,wght-normal.js

This file was deleted.

Loading