Initial commit: Converge portfolio rationalization app
Next.js app for mapping a customer's competitive tool landscape onto our portfolio and building the consolidation business case: assessment workbench, customer report and Word export, product catalog, competitive knowledge base, dossier import, shareable landscape questionnaires with a review inbox, tool-footprint and business-unit value analysis, and an implementation timeline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
25
src/app/api/assessments/[id]/surveys/route.ts
Normal file
25
src/app/api/assessments/[id]/surveys/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { createSurvey, getAssessment, getCatalog, listSurveys } from "@/lib/store";
|
||||
import { surveyableDomains } from "@/lib/survey";
|
||||
|
||||
type Ctx = { params: Promise<{ id: string }> };
|
||||
|
||||
export async function GET(_req: Request, { params }: Ctx) {
|
||||
const { id } = await params;
|
||||
if (!(await getAssessment(id))) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
return NextResponse.json(await listSurveys(id));
|
||||
}
|
||||
|
||||
export async function POST(req: Request, { params }: Ctx) {
|
||||
const { id } = await params;
|
||||
if (!(await getAssessment(id))) return NextResponse.json({ error: "Not found" }, { status: 404 });
|
||||
|
||||
const body = (await req.json()) as { respondentName?: string; domains?: string[] };
|
||||
// Keep catalog order and drop anything that is not a live category.
|
||||
const wanted = new Set(Array.isArray(body.domains) ? body.domains : []);
|
||||
const domains = surveyableDomains(await getCatalog()).map((d) => d.id).filter((d) => wanted.has(d));
|
||||
if (!domains.length) return NextResponse.json({ error: "Pick at least one category." }, { status: 400 });
|
||||
|
||||
const name = typeof body.respondentName === "string" ? body.respondentName.trim().slice(0, 120) : "";
|
||||
return NextResponse.json(await createSurvey(id, name, domains));
|
||||
}
|
||||
Reference in New Issue
Block a user