diff --git a/src/app/api/circles/[id]/invite/route.ts b/src/app/api/circles/[id]/invite/route.ts index 476137d..37a10dd 100644 --- a/src/app/api/circles/[id]/invite/route.ts +++ b/src/app/api/circles/[id]/invite/route.ts @@ -27,16 +27,21 @@ export async function POST( const token = randomBytes(32).toString("hex"); const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000); // 7 days - const [invite] = await sql.unsafe( - `INSERT INTO circle_invites (circle_id, token, created_by, expires_at) - VALUES ($1, $2, $3, $4) - RETURNING id, token, expires_at as "expiresAt"`, - [circleId, token, familyId, expiresAt] - ); + try { + const [invite] = await sql.unsafe( + `INSERT INTO circle_invites (circle_id, token, created_by, expires_at) + VALUES ($1, $2, $3, $4) + RETURNING id, token, expires_at as "expiresAt"`, + [circleId, token, familyId, expiresAt] + ); - const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "https://tia.manohargupta.com"; - return NextResponse.json({ - success: true, - invite: { ...invite, joinUrl: `${baseUrl}/circle/join/${token}` }, - }); + const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "https://tia.manohargupta.com"; + return NextResponse.json({ + success: true, + invite: { ...invite, joinUrl: `${baseUrl}/circle/join/${token}` }, + }); + } catch (err: unknown) { + const msg = err instanceof Error ? err.message : String(err); + return NextResponse.json({ error: msg }, { status: 500 }); + } } diff --git a/src/app/circle/[id]/page.tsx b/src/app/circle/[id]/page.tsx index c5ba6d0..2e3de4a 100644 --- a/src/app/circle/[id]/page.tsx +++ b/src/app/circle/[id]/page.tsx @@ -174,6 +174,9 @@ function PostCard({ ))}
setCommentText(e.target.value)} onKeyDown={e => e.key === "Enter" && addComment()} @@ -258,6 +261,8 @@ function CreatePostModal({ {step === "compose" ? ( <>