@@ -7,7 +7,7 @@ import { createAlert, testRunAlert } from "@/app/actions/alerts";
77import type { SerpResult } from "@/lib/alerts/valueserp" ;
88
99// People-tracking templates (name / reputation / impersonation / legal) are
10- // withheld from the v1 launch picker pending a trust-and-safety policy.
10+ // withheld from the v1 picker pending a trust-and-safety policy.
1111const PICKABLE = ALERT_CATEGORIES . filter ( ( c ) => ! c . gated ) ;
1212
1313const RECENCIES : { value : Recency ; label : string } [ ] = [
@@ -17,13 +17,7 @@ const RECENCIES: { value: Recency; label: string }[] = [
1717 { value : "any" , label : "Any time" } ,
1818] ;
1919
20- export function CreateAlert ( {
21- remainingSlots,
22- allowHourly,
23- } : {
24- remainingSlots : number ;
25- allowHourly : boolean ;
26- } ) {
20+ export function CreateAlert ( { remainingSlots } : { remainingSlots : number } ) {
2721 const router = useRouter ( ) ;
2822 const [ pending , startTransition ] = useTransition ( ) ;
2923 const [ categoryKey , setCategoryKey ] = useState ( PICKABLE [ 0 ] . key ) ;
@@ -49,41 +43,24 @@ export function CreateAlert({
4943 function runTest ( ) {
5044 setError ( null ) ;
5145 setNotice ( null ) ;
52- if ( ! term . trim ( ) ) {
53- setError ( `${ category . inputLabel } is required.` ) ;
54- return ;
55- }
46+ if ( ! term . trim ( ) ) return setError ( `${ category . inputLabel } is required.` ) ;
5647 startTransition ( async ( ) => {
5748 const res = await testRunAlert ( { category : categoryKey , term, customQuery : term } ) ;
58- if ( ! res . ok ) {
59- setError ( res . error ) ;
60- return ;
61- }
49+ if ( ! res . ok ) return setError ( res . error ) ;
6250 setPreview ( res . results ) ;
63- if ( res . results . length === 0 ) setNotice ( "No current results — you'll be emailed when something new appears." ) ;
51+ if ( res . results . length === 0 )
52+ setNotice ( "No current results — you'll be emailed when something new appears." ) ;
6453 } ) ;
6554 }
6655
6756 function submit ( e : React . FormEvent ) {
6857 e . preventDefault ( ) ;
6958 setError ( null ) ;
7059 setNotice ( null ) ;
71- if ( ! term . trim ( ) ) {
72- setError ( `${ category . inputLabel } is required.` ) ;
73- return ;
74- }
60+ if ( ! term . trim ( ) ) return setError ( `${ category . inputLabel } is required.` ) ;
7561 startTransition ( async ( ) => {
76- const res = await createAlert ( {
77- category : categoryKey ,
78- term,
79- customQuery : term ,
80- recency,
81- frequency,
82- } ) ;
83- if ( ! res . ok ) {
84- setError ( res . error ) ;
85- return ;
86- }
62+ const res = await createAlert ( { category : categoryKey , term, customQuery : term , recency, frequency } ) ;
63+ if ( ! res . ok ) return setError ( res . error ) ;
8764 setTerm ( "" ) ;
8865 setPreview ( null ) ;
8966 setNotice ( "Alert created. First check runs shortly." ) ;
@@ -135,11 +112,9 @@ export function CreateAlert({
135112 value = { frequency }
136113 onChange = { ( e ) => setFrequency ( e . target . value as "daily" | "hourly" ) }
137114 aria-label = "Check frequency"
138- disabled = { ! allowHourly }
139- title = { allowHourly ? "" : "Hourly checks are a paid feature" }
140115 >
141116 < option value = "daily" > Daily</ option >
142- < option value = "hourly" > Hourly{ allowHourly ? "" : " (paid)" } </ option >
117+ < option value = "hourly" > Hourly</ option >
143118 </ select >
144119 </ div >
145120
@@ -166,13 +141,7 @@ export function CreateAlert({
166141 Current results preview (you'll only be emailed NEW ones)
167142 </ p >
168143 { preview . map ( ( r ) => (
169- < a
170- key = { r . url }
171- href = { r . url }
172- target = "_blank"
173- rel = "noreferrer"
174- className = "block text-sm"
175- >
144+ < a key = { r . url } href = { r . url } target = "_blank" rel = "noreferrer" className = "block text-sm" >
176145 < span className = "font-medium text-[var(--color-accent)]" > { r . title || r . url } </ span >
177146 < span className = "block truncate text-xs text-[var(--color-muted)]" > { r . url } </ span >
178147 </ a >
0 commit comments