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
6 changes: 4 additions & 2 deletions app/api/notifications/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ 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();
if (!user?.id) {
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);
}

Expand Down
5 changes: 3 additions & 2 deletions app/api/organizations/[orgId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 9 additions & 6 deletions app/api/users/[userId]/role/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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();
Expand All @@ -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)) {
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions app/api/widget-config/[orgId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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) {
Expand All @@ -81,7 +82,7 @@ export async function GET(
config,
organization_id
`)
.eq("organization_id", params.orgId)
.eq("organization_id", resolvedParams.orgId)
.limit(1)
.single();

Expand Down Expand Up @@ -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: {
Expand Down
14 changes: 8 additions & 6 deletions app/api/widgets/[widgetId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -75,7 +77,7 @@ export async function PUT(
...body,
updated_at: new Date().toISOString(),
})
.eq("id", params.widgetId)
.eq("id", resolvedParams.widgetId)
.select()
.single();

Expand Down Expand Up @@ -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) {
Expand All @@ -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;

Expand Down
16 changes: 2 additions & 14 deletions components/ui/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -31,18 +31,6 @@ const Alert = React.forwardRef<
))
Alert.displayName = "Alert"

const AlertTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h5
ref={ref}
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
{...props}
/>
))
AlertTitle.displayName = "AlertTitle"

const AlertDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
Expand All @@ -55,4 +43,4 @@ const AlertDescription = React.forwardRef<
))
AlertDescription.displayName = "AlertDescription"

export { Alert, AlertTitle, AlertDescription }
export { Alert, AlertDescription }