fix: resolve Prettier markdown code block parsing errors

- Fix syntax errors in skills markdown files (.github/skills, .opencode/skills)
- Change typescript to tsx for code blocks with JSX
- Replace ellipsis (...) in array examples with valid syntax
- Separate CSS from TypeScript into distinct code blocks
- Convert JavaScript object examples to valid JSON in docs
- Fix enum definitions with proper comma separation
This commit is contained in:
2026-01-20 21:09:29 +01:00
parent 7932fe7386
commit cd05fc8648
177 changed files with 5042 additions and 5541 deletions

View File

@@ -1,10 +1,10 @@
import { CompanyStatus } from "@prisma/client";
import { type NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { platformAuthOptions } from "../../../../../lib/platform-auth";
import { prisma } from "../../../../../lib/prisma";
export const dynamic = "force-dynamic";
import {
getAuthenticatedPlatformUser,
hasPlatformAccess,
} from "@/lib/auth/server";
import { prisma } from "@/lib/prisma";
// GET /api/platform/companies/[id] - Get company details
export async function GET(
@@ -12,9 +12,9 @@ export async function GET(
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(platformAuthOptions);
const { user } = await getAuthenticatedPlatformUser();
if (!session?.user?.isPlatformUser) {
if (!user) {
return NextResponse.json(
{ error: "Platform access required" },
{ status: 401 }
@@ -67,12 +67,9 @@ export async function PATCH(
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(platformAuthOptions);
const { user } = await getAuthenticatedPlatformUser();
if (
!session?.user?.isPlatformUser ||
session.user.platformRole === "SUPPORT"
) {
if (!user || !hasPlatformAccess(user.role, "PLATFORM_ADMIN")) {
return NextResponse.json(
{ error: "Admin access required" },
{ status: 403 }
@@ -81,12 +78,10 @@ export async function PATCH(
const { id } = await params;
const body = await request.json();
const { name, email, maxUsers, csvUrl, csvUsername, csvPassword, status } =
body;
const { name, maxUsers, csvUrl, csvUsername, csvPassword, status } = body;
const updateData: {
name?: string;
email?: string;
maxUsers?: number;
csvUrl?: string;
csvUsername?: string;
@@ -94,7 +89,6 @@ export async function PATCH(
status?: CompanyStatus;
} = {};
if (name !== undefined) updateData.name = name;
if (email !== undefined) updateData.email = email;
if (maxUsers !== undefined) updateData.maxUsers = maxUsers;
if (csvUrl !== undefined) updateData.csvUrl = csvUrl;
if (csvUsername !== undefined) updateData.csvUsername = csvUsername;
@@ -122,12 +116,9 @@ export async function DELETE(
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(platformAuthOptions);
const { user } = await getAuthenticatedPlatformUser();
if (
!session?.user?.isPlatformUser ||
session.user.platformRole !== "SUPER_ADMIN"
) {
if (!user || !hasPlatformAccess(user.role, "PLATFORM_SUPER_ADMIN")) {
return NextResponse.json(
{ error: "Super admin access required" },
{ status: 403 }

View File

@@ -1,10 +1,9 @@
import { hash } from "bcryptjs";
import { type NextRequest, NextResponse } from "next/server";
import { getServerSession } from "next-auth";
import { platformAuthOptions } from "../../../../../../lib/platform-auth";
import { prisma } from "../../../../../../lib/prisma";
export const dynamic = "force-dynamic";
import {
getAuthenticatedPlatformUser,
hasPlatformAccess,
} from "@/lib/auth/server";
import { prisma } from "@/lib/prisma";
// POST /api/platform/companies/[id]/users - Invite user to company
export async function POST(
@@ -12,11 +11,11 @@ export async function POST(
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(platformAuthOptions);
const { user: platformUser } = await getAuthenticatedPlatformUser();
if (
!session?.user?.isPlatformUser ||
session.user.platformRole === "SUPPORT"
!platformUser ||
!hasPlatformAccess(platformUser.role, "PLATFORM_ADMIN")
) {
return NextResponse.json(
{ error: "Admin access required" },
@@ -53,34 +52,26 @@ export async function POST(
);
}
// Check if user already exists in this company
const existingUser = await prisma.user.findFirst({
where: {
email,
companyId,
},
// Check if user already exists
const existingUser = await prisma.user.findUnique({
where: { email },
});
if (existingUser) {
return NextResponse.json(
{ error: "User already exists in this company" },
{ error: "User with this email already exists" },
{ status: 400 }
);
}
// Generate a temporary password (in a real app, you'd send an invitation email)
const tempPassword = `temp${Math.random().toString(36).slice(-8)}`;
const hashedPassword = await hash(tempPassword, 10);
// Create the user
// Create the user placeholder (they'll complete signup via Neon Auth)
const user = await prisma.user.create({
data: {
name,
email,
password: hashedPassword,
role,
companyId,
invitedBy: session.user.email,
invitedBy: platformUser.email,
invitedAt: new Date(),
},
select: {
@@ -94,13 +85,12 @@ export async function POST(
},
});
// In a real application, you would send an email with login credentials
// For now, we'll return the temporary password
// TODO: Send invitation email with sign-up link
return NextResponse.json({
user,
tempPassword, // Remove this in production and send via email
signupUrl: "/auth/sign-up",
message:
"User invited successfully. In production, credentials would be sent via email.",
"User invited. They should sign up at /auth/sign-up with this email.",
});
} catch (error) {
console.error("Platform user invitation error:", error);
@@ -117,9 +107,9 @@ export async function GET(
{ params }: { params: Promise<{ id: string }> }
) {
try {
const session = await getServerSession(platformAuthOptions);
const { user } = await getAuthenticatedPlatformUser();
if (!session?.user?.isPlatformUser) {
if (!user) {
return NextResponse.json(
{ error: "Platform access required" },
{ status: 401 }