From 32c2a665df4d22feca75ed446a431c15e49e330f Mon Sep 17 00:00:00 2001 From: TFPrsvr Date: Thu, 21 Aug 2025 11:00:12 -0500 Subject: [PATCH 1/3] Fix Next.js 15 async params compatibility in remaining API routes --- app/api/notifications/[id]/route.ts | 6 ++++-- app/api/organizations/[orgId]/route.ts | 5 +++-- app/api/users/[userId]/role/route.ts | 15 +++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/api/notifications/[id]/route.ts b/app/api/notifications/[id]/route.ts index 35b946a..9f06d16 100644 --- a/app/api/notifications/[id]/route.ts +++ b/app/api/notifications/[id]/route.ts @@ -5,7 +5,7 @@ import { NotificationService } from "@/lib/notifications/service"; // PATCH /api/notifications/[id] - Mark notification as read export async function PATCH( request: NextRequest, - { params }: { params: { id: string } } + { params }: { params: Promise<{ id: string }> } ) { try { const user = await currentUser(); @@ -13,11 +13,13 @@ export async function PATCH( return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } + const resolvedParams = await params; + const body = await request.json(); const { action } = body; if (action === "mark_read") { - const result = await NotificationService.markAsRead(params.id, user.id); + const result = await NotificationService.markAsRead(resolvedParams.id, user.id); return NextResponse.json(result); } diff --git a/app/api/organizations/[orgId]/route.ts b/app/api/organizations/[orgId]/route.ts index 456e1d4..946f87c 100644 --- a/app/api/organizations/[orgId]/route.ts +++ b/app/api/organizations/[orgId]/route.ts @@ -5,12 +5,13 @@ import { supabaseAdmin } from "@/lib/supabase/supabase-server"; // GET /api/org/:orgId export async function GET( _req: Request, - { params }: { params: { orgId: string } } + { params }: { params: Promise<{ orgId: string }> } ) { + const resolvedParams = await params; const { data: org, error } = await supabaseAdmin .from("organizations") .select("*") - .eq("id", params.orgId) + .eq("id", resolvedParams.orgId) .single(); if (error) diff --git a/app/api/users/[userId]/role/route.ts b/app/api/users/[userId]/role/route.ts index e096cd1..12fe56d 100644 --- a/app/api/users/[userId]/role/route.ts +++ b/app/api/users/[userId]/role/route.ts @@ -6,7 +6,7 @@ import { UserRole, RolePermissions } from '@/types/roles.types'; // GET /api/users/[userId]/role - Get user's current role export async function GET( request: NextRequest, - { params }: { params: { userId: string } } + { params }: { params: Promise<{ userId: string }> } ) { try { const { userId: currentUserId } = await auth(); @@ -15,7 +15,8 @@ export async function GET( return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } - const targetUserId = params.userId; + const resolvedParams = await params; + const targetUserId = resolvedParams.userId; // Get current user's permissions const { data: currentUser } = await supabaseAdmin @@ -61,7 +62,7 @@ export async function GET( // PUT /api/users/[userId]/role - Update user's role export async function PUT( request: NextRequest, - { params }: { params: { userId: string } } + { params }: { params: Promise<{ userId: string }> } ) { try { const { userId: currentUserId } = await auth(); @@ -70,8 +71,9 @@ export async function PUT( return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } + const resolvedParams = await params; const { role: newRole, reason } = await request.json(); - const targetUserId = params.userId; + const targetUserId = resolvedParams.userId; // Validate new role if (!['super_admin', 'admin', 'user'].includes(newRole)) { @@ -180,7 +182,7 @@ export async function PUT( // GET /api/users/[userId]/role/history - Get role assignment history export async function DELETE( request: NextRequest, - { params }: { params: { userId: string } } + { params }: { params: Promise<{ userId: string }> } ) { try { const { userId: currentUserId } = await auth(); @@ -189,7 +191,8 @@ export async function DELETE( return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); } - const targetUserId = params.userId; + const resolvedParams = await params; + const targetUserId = resolvedParams.userId; // Get current user's permissions const { data: currentUser } = await supabaseAdmin From 295a6be98ff2470b2a549e82fe6f1b50ab955b9f Mon Sep 17 00:00:00 2001 From: TFPrsvr Date: Thu, 21 Aug 2025 11:50:29 -0500 Subject: [PATCH 2/3] Fix remaining async params issues in widget API routes --- app/api/widget-config/[orgId]/route.ts | 11 ++++++----- app/api/widgets/[widgetId]/route.ts | 14 ++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/api/widget-config/[orgId]/route.ts b/app/api/widget-config/[orgId]/route.ts index 52542fb..9a4d330 100644 --- a/app/api/widget-config/[orgId]/route.ts +++ b/app/api/widget-config/[orgId]/route.ts @@ -43,9 +43,10 @@ export async function OPTIONS() { export async function GET( req: Request, - { params }: { params: { orgId: string } } + { params }: { params: Promise<{ orgId: string }> } ) { - console.log("Widget config API called for orgId:", params.orgId); + const resolvedParams = await params; + console.log("Widget config API called for orgId:", resolvedParams.orgId); // Add CORS headers for widget embed requests const headers = { @@ -61,7 +62,7 @@ export async function GET( const { data: organization, error: orgError } = await supabase .from("organizations") .select("id, name, stripe_customer_id") - .eq("id", params.orgId) + .eq("id", resolvedParams.orgId) .single(); if (orgError || !organization) { @@ -81,7 +82,7 @@ export async function GET( config, organization_id `) - .eq("organization_id", params.orgId) + .eq("organization_id", resolvedParams.orgId) .limit(1) .single(); @@ -115,7 +116,7 @@ export async function GET( id: widgets?.id || 'default', name: widgets?.name || 'Default Widget', slug: widgets?.slug || 'default', - organizationId: params.orgId, + organizationId: resolvedParams.orgId, organizationName: organization.name, stripeCustomerId: organization.stripe_customer_id, config: { diff --git a/app/api/widgets/[widgetId]/route.ts b/app/api/widgets/[widgetId]/route.ts index a91b880..9e651a8 100644 --- a/app/api/widgets/[widgetId]/route.ts +++ b/app/api/widgets/[widgetId]/route.ts @@ -4,20 +4,22 @@ import { createClient } from "@/lib/supabase/supabase-server"; export async function GET( req: Request, - { params }: { params: { widgetId: string } } + { params }: { params: Promise<{ widgetId: string }> } ) { const { userId } = await auth(); if (!userId) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } + const resolvedParams = await params; + const supabase = await createClient(); try { const { data: widget, error } = await supabase .from("widgets") .select("*, widget_themes(*), causes(*)") - .eq("id", params.widgetId) + .eq("id", resolvedParams.widgetId) .single(); if (error) throw error; @@ -54,7 +56,7 @@ export async function PUT( const { data: widget } = await supabase .from("widgets") .select("organization_id") - .eq("id", params.widgetId) + .eq("id", resolvedParams.widgetId) .single(); if (!widget) { @@ -75,7 +77,7 @@ export async function PUT( ...body, updated_at: new Date().toISOString(), }) - .eq("id", params.widgetId) + .eq("id", resolvedParams.widgetId) .select() .single(); @@ -112,7 +114,7 @@ export async function DELETE( const { data: widget } = await supabase .from("widgets") .select("organization_id") - .eq("id", params.widgetId) + .eq("id", resolvedParams.widgetId) .single(); if (!widget) { @@ -130,7 +132,7 @@ export async function DELETE( const { error } = await supabase .from("widgets") .delete() - .eq("id", params.widgetId); + .eq("id", resolvedParams.widgetId); if (error) throw error; From e534981d5a5bb0ae15d3a036b942920decee4944 Mon Sep 17 00:00:00 2001 From: TFPrsvr Date: Thu, 21 Aug 2025 12:32:34 -0500 Subject: [PATCH 3/3] Fix Alert component implementation and styling - Simplified Alert component to match shadcn/ui standards - Removed unnecessary AlertTitle component - Updated CSS classes for better spacing and typography - Fixed import path case sensitivity issue --- components/ui/alert.tsx | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/components/ui/alert.tsx b/components/ui/alert.tsx index fc218ce..1202aa1 100644 --- a/components/ui/alert.tsx +++ b/components/ui/alert.tsx @@ -3,7 +3,7 @@ import { cva, type VariantProps } from "class-variance-authority" import { cn } from "@/lib/utils" const alertVariants = cva( - "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground", + "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", { variants: { variant: { @@ -31,18 +31,6 @@ const Alert = React.forwardRef< )) Alert.displayName = "Alert" -const AlertTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)) -AlertTitle.displayName = "AlertTitle" - const AlertDescription = React.forwardRef< HTMLParagraphElement, React.HTMLAttributes @@ -55,4 +43,4 @@ const AlertDescription = React.forwardRef< )) AlertDescription.displayName = "AlertDescription" -export { Alert, AlertTitle, AlertDescription } \ No newline at end of file +export { Alert, AlertDescription } \ No newline at end of file