fix: surface invite creation error + fix form field id/name attributes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Manohar Gupta 2026-05-24 01:51:51 +05:30
parent b7fb34fdde
commit 3d7ff9adb5
3 changed files with 25 additions and 12 deletions

View file

@ -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 });
}
}

View file

@ -174,6 +174,9 @@ function PostCard({
))}
<div className="flex gap-2 pt-1">
<input
id="comment-input"
name="comment-input"
autoComplete="off"
value={commentText}
onChange={e => setCommentText(e.target.value)}
onKeyDown={e => e.key === "Enter" && addComment()}
@ -258,6 +261,8 @@ function CreatePostModal({
{step === "compose" ? (
<>
<textarea
id="post-body"
name="post-body"
autoFocus
value={body}
onChange={e => setBody(e.target.value)}
@ -276,7 +281,7 @@ function CreatePostModal({
)}
<label className="flex items-center gap-2 text-sm text-gray-500 cursor-pointer mb-4">
<span className="text-xl">📷</span> Add photo
<input type="file" accept="image/*" className="hidden" onChange={pickImage} />
<input id="post-image" name="post-image" type="file" accept="image/*" className="hidden" onChange={pickImage} />
</label>
<button
onClick={() => setStep("confirm")}

View file

@ -67,7 +67,10 @@ export default function CirclePage() {
<div className="mx-4 mb-4 p-4 bg-white dark:bg-gray-800 rounded-2xl shadow-sm space-y-3">
<p className="text-sm font-medium text-gray-700 dark:text-gray-200">Create a new Circle</p>
<input
id="circle-name"
name="circle-name"
autoFocus
autoComplete="off"
value={newName}
onChange={e => setNewName(e.target.value)}
onKeyDown={e => e.key === "Enter" && createCircle()}