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,6 +27,7 @@ export async function POST(
const token = randomBytes(32).toString("hex"); const token = randomBytes(32).toString("hex");
const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000); // 7 days const expiresAt = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000); // 7 days
try {
const [invite] = await sql.unsafe( const [invite] = await sql.unsafe(
`INSERT INTO circle_invites (circle_id, token, created_by, expires_at) `INSERT INTO circle_invites (circle_id, token, created_by, expires_at)
VALUES ($1, $2, $3, $4) VALUES ($1, $2, $3, $4)
@ -39,4 +40,8 @@ export async function POST(
success: true, success: true,
invite: { ...invite, joinUrl: `${baseUrl}/circle/join/${token}` }, 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"> <div className="flex gap-2 pt-1">
<input <input
id="comment-input"
name="comment-input"
autoComplete="off"
value={commentText} value={commentText}
onChange={e => setCommentText(e.target.value)} onChange={e => setCommentText(e.target.value)}
onKeyDown={e => e.key === "Enter" && addComment()} onKeyDown={e => e.key === "Enter" && addComment()}
@ -258,6 +261,8 @@ function CreatePostModal({
{step === "compose" ? ( {step === "compose" ? (
<> <>
<textarea <textarea
id="post-body"
name="post-body"
autoFocus autoFocus
value={body} value={body}
onChange={e => setBody(e.target.value)} 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"> <label className="flex items-center gap-2 text-sm text-gray-500 cursor-pointer mb-4">
<span className="text-xl">📷</span> Add photo <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> </label>
<button <button
onClick={() => setStep("confirm")} 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"> <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> <p className="text-sm font-medium text-gray-700 dark:text-gray-200">Create a new Circle</p>
<input <input
id="circle-name"
name="circle-name"
autoFocus autoFocus
autoComplete="off"
value={newName} value={newName}
onChange={e => setNewName(e.target.value)} onChange={e => setNewName(e.target.value)}
onKeyDown={e => e.key === "Enter" && createCircle()} onKeyDown={e => e.key === "Enter" && createCircle()}