Skip to content

Commit a688e87

Browse files
royalpinto007claude
andcommitted
fix: newsletter build errors (types, FormEvent, digest mapping)
- add newsletter_subscribers to Database types (was typed never) - import FormEvent type instead of React.FormEvent namespace - map posts rows to DigestCase (case_number -> caseNumber) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ea3e6d0 commit a688e87

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

app/api/newsletter/send/route.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ export async function POST(req: NextRequest) {
3333
return NextResponse.json({ ok: true, sent: 0, reason: "no cases" });
3434
}
3535

36+
const digestCases: DigestCase[] = cases.map((c) => ({
37+
caseNumber: c.case_number,
38+
title: c.title,
39+
outcome: c.outcome,
40+
}));
41+
3642
const { data: subs } = await supabase
3743
.from("newsletter_subscribers")
3844
.select("email, unsubscribe_token")
@@ -42,11 +48,7 @@ export async function POST(req: NextRequest) {
4248
let failed = 0;
4349
for (const s of subs ?? []) {
4450
try {
45-
await sendNewsletterDigest(
46-
s.email,
47-
s.unsubscribe_token,
48-
cases as DigestCase[],
49-
);
51+
await sendNewsletterDigest(s.email, s.unsubscribe_token, digestCases);
5052
sent++;
5153
} catch (e) {
5254
failed++;

components/newsletter/NewsletterSignup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
"use client";
22

3-
import { useState } from "react";
3+
import { useState, type FormEvent } from "react";
44

55
export function NewsletterSignup() {
66
const [email, setEmail] = useState("");
77
const [status, setStatus] = useState<"idle" | "loading" | "ok" | "err">(
88
"idle",
99
);
1010

11-
async function submit(e: React.FormEvent) {
11+
async function submit(e: FormEvent) {
1212
e.preventDefault();
1313
if (!email) return;
1414
setStatus("loading");

types/supabase.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@
66
export type Database = {
77
public: {
88
Tables: {
9+
newsletter_subscribers: {
10+
Row: {
11+
id: string;
12+
email: string;
13+
status: string;
14+
unsubscribe_token: string;
15+
created_at: string;
16+
};
17+
Insert: {
18+
id?: string;
19+
email: string;
20+
status?: string;
21+
unsubscribe_token?: string;
22+
created_at?: string;
23+
};
24+
Update: {
25+
id?: string;
26+
email?: string;
27+
status?: string;
28+
unsubscribe_token?: string;
29+
created_at?: string;
30+
};
31+
Relationships: [];
32+
};
933
agents: {
1034
Row: {
1135
id: string;

0 commit comments

Comments
 (0)