@@ -17,13 +17,12 @@ import {
1717 Loader ,
1818 Mail ,
1919 MessageSquare ,
20- MoveUpRight ,
2120 Send ,
2221 UserPlus ,
2322 Zap ,
2423} from "lucide-react" ;
2524import Link from "next/link" ;
26- import { useEffect , useState } from "react" ;
25+ import { useCallback , useEffect , useState } from "react" ;
2726import { useOrgOnboarding } from "../../../services/hooks/useOrgOnboarding" ;
2827import { useOrg } from "../../layout/org/organizationContext" ;
2928import { QuickstartStepCard } from "../../onboarding/QuickstartStep" ;
@@ -59,10 +58,9 @@ const QuickstartPage = () => {
5958 const { setNotification } = useNotification ( ) ;
6059 const { addKey } = useKeys ( ) ;
6160 const [ quickstartKey , setQuickstartKey ] = useLocalStorage < string | undefined > (
62- ` ${ org ?. currentOrg ?. id } _quickstartKey` ,
61+ "quickstartKey" ,
6362 undefined ,
6463 ) ;
65- const [ isCreatingKey , setIsCreatingKey ] = useState ( false ) ;
6664 const [ isProviderSheetOpen , setIsProviderSheetOpen ] = useState ( false ) ;
6765 const [ isPaymentModalOpen , setIsPaymentModalOpen ] = useState ( false ) ;
6866 const [ isHelixDialogOpen , setIsHelixDialogOpen ] = useState ( false ) ;
@@ -103,27 +101,29 @@ const QuickstartPage = () => {
103101 } ) ;
104102 } , [ ] ) ;
105103
106- const handleCreateKey = async ( ) => {
104+ const handleCreateKey = useCallback ( async ( ) => {
107105 try {
108106 let isEu = false ;
109107 if ( typeof window !== "undefined" ) {
110108 isEu = window . location . hostname . includes ( "eu." ) ;
111109 }
112- setIsCreatingKey ( true ) ;
113- const { apiKey } = await addKey . mutateAsync ( {
114- permission : "rw" ,
115- keyName : "Quickstart" ,
116- isEu,
117- } ) ;
118- if ( apiKey ) {
119- setQuickstartKey ( apiKey ) ;
120- }
110+
111+ addKey . mutateAsync (
112+ {
113+ permission : "rw" ,
114+ keyName : "Quickstart" ,
115+ isEu,
116+ } ,
117+ {
118+ onSuccess : ( key ) => {
119+ setQuickstartKey ( key . apiKey ) ;
120+ } ,
121+ } ,
122+ ) ;
121123 } catch ( error ) {
122124 console . error ( "Failed to create API key:" , error ) ;
123- } finally {
124- setIsCreatingKey ( false ) ;
125125 }
126- } ;
126+ } , [ addKey , setQuickstartKey ] ) ;
127127
128128 const handleHelixSubmit = ( message : string ) => {
129129 const helpMessage = {
@@ -312,13 +312,16 @@ const QuickstartPage = () => {
312312 </ div >
313313
314314 { /* BYOK Option - Simple text link */ }
315- < div className = "flex items-center justify-start pl-4 pt-4 pb-2 " >
315+ < div className = "flex items-center justify-start pb-2 pt-4" >
316316 < button
317317 onClick = { ( ) => setIsProviderSheetOpen ( true ) }
318318 className = "group flex items-center gap-1 text-sm text-muted-foreground transition-colors hover:text-foreground"
319319 >
320320 < span > or use your own provider keys</ span >
321- < ArrowRight size = { 14 } className = "transition-transform group-hover:translate-x-0.5" />
321+ < ArrowRight
322+ size = { 14 }
323+ className = "transition-transform group-hover:translate-x-0.5"
324+ />
322325 { hasProviderKeys && (
323326 < span className = "ml-1 inline-flex items-center gap-1 rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-700 dark:bg-green-900 dark:text-green-300" >
324327 < Zap size = { 10 } />
@@ -354,11 +357,11 @@ const QuickstartPage = () => {
354357 < div className = "flex flex-col gap-2" >
355358 < Button
356359 onClick = { handleCreateKey }
357- disabled = { isCreatingKey }
360+ disabled = { addKey . isPending }
358361 className = "w-fit"
359362 variant = "outline"
360363 >
361- { isCreatingKey ? "Creating..." : "Create API Key" }
364+ { addKey . isPending ? "Creating..." : "Create API Key" }
362365 </ Button >
363366 </ div >
364367 ) }
@@ -588,7 +591,10 @@ const QuickstartPage = () => {
588591 < SheetHeader >
589592 < SheetTitle > Add Provider Keys</ SheetTitle >
590593 < SheetDescription >
591- Add your own provider API keys (BYOK). When "Enable for AI Gateway" is toggled on, requests will attempt to use these keys first, then automatically fall back to Helicone credits if they fail.
594+ Add your own provider API keys (BYOK). When "Enable for AI
595+ Gateway" is toggled on, requests will attempt to use these keys
596+ first, then automatically fall back to Helicone credits if they
597+ fail.
592598 </ SheetDescription >
593599 </ SheetHeader >
594600 < div className = "mt-6" >
0 commit comments