File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ++ ;
Original file line number Diff line number Diff line change 11"use client" ;
22
3- import { useState } from "react" ;
3+ import { useState , type FormEvent } from "react" ;
44
55export 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" ) ;
Original file line number Diff line number Diff line change 66export 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 ;
You can’t perform that action at this time.
0 commit comments