@@ -19,6 +19,7 @@ interface ApiKey {
1919 id : string ;
2020 name : string ;
2121 key_prefix : string ;
22+ key_type : 'test' | 'live' ;
2223 scope : 'global' | 'domain' | 'multi' ;
2324 active : number ;
2425 last_used_at : string | null ;
@@ -44,7 +45,7 @@ export default function KeysPage() {
4445 const [ creating , setCreating ] = useState ( false ) ;
4546 const [ newKey , setNewKey ] = useState < NewKey | null > ( null ) ;
4647 const [ copied , setCopied ] = useState ( false ) ;
47- const [ form , setForm ] = useState ( { name : '' , scope : 'global' as const } ) ;
48+ const [ form , setForm ] = useState ( { name : '' , type : 'live' as 'test' | 'live' , scope : 'global' as const } ) ;
4849 const [ revokeId , setRevokeId ] = useState < string | null > ( null ) ;
4950
5051 async function load ( ) {
@@ -61,7 +62,7 @@ export default function KeysPage() {
6162 const { data } = await api . post < NewKey > ( '/api/keys' , form ) ;
6263 setNewKey ( data ) ;
6364 setCreating ( false ) ;
64- setForm ( { name : '' , scope : 'global' } ) ;
65+ setForm ( { name : '' , type : 'live' , scope : 'global' } ) ;
6566 load ( ) ;
6667 }
6768
@@ -117,7 +118,9 @@ export default function KeysPage() {
117118 < Alert className = "mb-6 border-emerald-200 bg-emerald-50" >
118119 < AlertDescription className = "flex items-start justify-between gap-4" >
119120 < div >
120- < p className = "text-sm font-semibold text-emerald-700 mb-1" > Copy your new API key — it won't be shown again</ p >
121+ < p className = "text-sm font-semibold text-emerald-700 mb-1" >
122+ { newKey . key_type === 'test' ? 'Test key created — ' : '' } Copy your new API key — it won't be shown again
123+ </ p >
121124 < code className = "text-xs font-mono text-emerald-800 break-all" > { newKey . key } </ code >
122125 < div >
123126 < Button variant = "ghost" size = "sm" onClick = { ( ) => setNewKey ( null ) } className = "mt-2 h-auto p-0 text-xs text-muted-foreground" >
@@ -155,22 +158,37 @@ export default function KeysPage() {
155158 />
156159 </ div >
157160 < div className = "flex flex-col gap-1.5" >
158- < Label > Scope </ Label >
161+ < Label > Type </ Label >
159162 < Select
160- value = { form . scope }
161- onValueChange = { v => setForm ( f => ( { ...f , scope : v as typeof form . scope } ) ) }
163+ value = { form . type }
164+ onValueChange = { v => setForm ( f => ( { ...f , type : v as typeof form . type } ) ) }
162165 >
163166 < SelectTrigger >
164167 < SelectValue />
165168 </ SelectTrigger >
166169 < SelectContent >
167- < SelectItem value = "global" > Global</ SelectItem >
168- < SelectItem value = "domain" > Domain</ SelectItem >
169- < SelectItem value = "multi" > Multi-domain</ SelectItem >
170+ < SelectItem value = "live" > Live</ SelectItem >
171+ < SelectItem value = "test" > Test</ SelectItem >
170172 </ SelectContent >
171173 </ Select >
172174 </ div >
173175 </ div >
176+ < div className = "flex flex-col gap-1.5" >
177+ < Label > Scope</ Label >
178+ < Select
179+ value = { form . scope }
180+ onValueChange = { v => setForm ( f => ( { ...f , scope : v as typeof form . scope } ) ) }
181+ >
182+ < SelectTrigger >
183+ < SelectValue />
184+ </ SelectTrigger >
185+ < SelectContent >
186+ < SelectItem value = "global" > Global</ SelectItem >
187+ < SelectItem value = "domain" > Domain</ SelectItem >
188+ < SelectItem value = "multi" > Multi-domain</ SelectItem >
189+ </ SelectContent >
190+ </ Select >
191+ </ div >
174192 < div className = "flex gap-2" >
175193 < Button type = "submit" > Create</ Button >
176194 < Button type = "button" variant = "ghost" onClick = { ( ) => setCreating ( false ) } > Cancel</ Button >
@@ -194,8 +212,10 @@ export default function KeysPage() {
194212 < div className = "flex-1 min-w-0" >
195213 < div className = "flex items-center gap-2" >
196214 < span className = "font-medium text-sm" > { k . name } </ span >
197- < Badge variant = "secondary" className = "font-mono text-xs" > { k . scope } </ Badge >
198- </ div >
215+ < Badge variant = "secondary" className = "font-mono text-xs" > { k . scope } </ Badge > { k . key_type === 'test'
216+ ? < Badge className = "text-[10px] bg-amber-500/10 text-amber-600 border-amber-200" > test</ Badge >
217+ : < Badge className = "text-[10px] bg-emerald-500/10 text-emerald-600 border-emerald-200" > live</ Badge >
218+ } </ div >
199219 < div className = "flex items-center gap-3 mt-0.5" >
200220 < code className = "text-xs text-muted-foreground font-mono" > { k . key_prefix } …</ code >
201221 < span className = "text-xs text-muted-foreground" > { k . send_count . toLocaleString ( ) } sends</ span >
0 commit comments