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:
parent
b7fb34fdde
commit
3d7ff9adb5
3 changed files with 25 additions and 12 deletions
|
|
@ -27,16 +27,21 @@ 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
|
||||||
|
|
||||||
const [invite] = await sql.unsafe(
|
try {
|
||||||
`INSERT INTO circle_invites (circle_id, token, created_by, expires_at)
|
const [invite] = await sql.unsafe(
|
||||||
VALUES ($1, $2, $3, $4)
|
`INSERT INTO circle_invites (circle_id, token, created_by, expires_at)
|
||||||
RETURNING id, token, expires_at as "expiresAt"`,
|
VALUES ($1, $2, $3, $4)
|
||||||
[circleId, token, familyId, expiresAt]
|
RETURNING id, token, expires_at as "expiresAt"`,
|
||||||
);
|
[circleId, token, familyId, expiresAt]
|
||||||
|
);
|
||||||
|
|
||||||
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "https://tia.manohargupta.com";
|
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "https://tia.manohargupta.com";
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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")}
|
||||||
|
|
|
||||||
|
|
@ -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()}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue