11'use client' ;
22
33import { createApiKeyAction } from '@/actions/organization/create-api-key-action' ;
4+ import { Accordion , AccordionContent , AccordionItem , AccordionTrigger } from '@comp/ui/accordion' ;
45import { Button } from '@comp/ui/button' ;
56import {
67 Drawer ,
@@ -14,7 +15,7 @@ import { Input } from '@comp/ui/input';
1415import { ScrollArea } from '@comp/ui/scroll-area' ;
1516import { Select , SelectContent , SelectItem , SelectTrigger , SelectValue } from '@comp/ui/select' ;
1617import { Sheet , SheetContent , SheetDescription , SheetHeader , SheetTitle } from '@comp/ui/sheet' ;
17- import { Check , Copy , Loader2 , X } from 'lucide-react' ;
18+ import { Check , Copy , X } from 'lucide-react' ;
1819import { useAction } from 'next-safe-action/hooks' ;
1920import { useState } from 'react' ;
2021import { toast } from 'sonner' ;
@@ -82,49 +83,58 @@ export function CreateApiKeyDialog({ open, onOpenChange, onSuccess }: CreateApiK
8283
8384 // Form content for reuse in both Dialog and Sheet/Drawer
8485 const renderFormContent = ( ) => (
85- < form onSubmit = { handleSubmit } className = "space-y-4 p-1" >
86- < div className = "space-y-2" >
87- < label htmlFor = "name" className = "text-sm leading-none font-medium" >
88- { 'Name' }
89- </ label >
90- < Input
91- id = "name"
92- value = { name }
93- onChange = { ( e ) => setName ( e . target . value ) }
94- placeholder = { 'Enter a name for this API key' }
95- required
96- className = "w-full"
97- />
98- </ div >
99- < div className = "space-y-2" >
100- < label htmlFor = "expiration" className = "text-sm leading-none font-medium" >
101- { 'Expiration' }
102- </ label >
103- < Select
104- value = { expiration }
105- onValueChange = { ( value ) => setExpiration ( value as 'never' | '30days' | '90days' | '1year' ) }
106- >
107- < SelectTrigger id = "expiration" className = "w-full" >
108- < SelectValue placeholder = { 'Select expiration' } />
109- </ SelectTrigger >
110- < SelectContent >
111- < SelectItem value = "never" > { 'Never' } </ SelectItem >
112- < SelectItem value = "30days" > { '30 days' } </ SelectItem >
113- < SelectItem value = "90days" > { '90 days' } </ SelectItem >
114- < SelectItem value = "1year" > { '1 year' } </ SelectItem >
115- </ SelectContent >
116- </ Select >
117- </ div >
118- < div className = "flex flex-col justify-end gap-2 pt-2 sm:flex-row" >
119- < Button type = "button" variant = "outline" onClick = { handleClose } >
120- { 'Cancel' }
121- </ Button >
122- < Button type = "submit" disabled = { isCreating === 'executing' } className = "w-full sm:w-auto" >
123- { isCreating === 'executing' && < Loader2 className = "mr-2 h-4 w-4 animate-spin" /> }
124- { 'New API Key' }
125- </ Button >
126- </ div >
127- </ form >
86+ < div className = "scrollbar-hide h-[calc(100vh-250px)] overflow-auto" >
87+ < Accordion type = "multiple" defaultValue = { [ 'api-key' ] } >
88+ < AccordionItem value = "api-key" >
89+ < AccordionTrigger > { 'API Key' } </ AccordionTrigger >
90+ < AccordionContent >
91+ < form onSubmit = { handleSubmit } className = "space-y-4" >
92+ < div className = "space-y-2" >
93+ < label htmlFor = "name" className = "text-sm leading-none font-medium" >
94+ { 'Name' }
95+ </ label >
96+ < div className = "mt-3" >
97+ < Input
98+ id = "name"
99+ value = { name }
100+ onChange = { ( e ) => setName ( e . target . value ) }
101+ placeholder = { 'Enter a name for this API key' }
102+ required
103+ className = "w-full"
104+ />
105+ </ div >
106+ </ div >
107+ < div className = "space-y-2" >
108+ < label htmlFor = "expiration" className = "text-sm leading-none font-medium" >
109+ { 'Expiration' }
110+ </ label >
111+ < div className = "mt-3" >
112+ < Select
113+ value = { expiration }
114+ onValueChange = { ( value ) =>
115+ setExpiration ( value as 'never' | '30days' | '90days' | '1year' )
116+ }
117+ >
118+ < SelectTrigger id = "expiration" className = "w-full" >
119+ < SelectValue placeholder = { 'Select expiration' } />
120+ </ SelectTrigger >
121+ < SelectContent >
122+ < SelectItem value = "never" > { 'Never' } </ SelectItem >
123+ < SelectItem value = "30days" > { '30 days' } </ SelectItem >
124+ < SelectItem value = "90days" > { '90 days' } </ SelectItem >
125+ < SelectItem value = "1year" > { '1 year' } </ SelectItem >
126+ </ SelectContent >
127+ </ Select >
128+ </ div >
129+ </ div >
130+ < Button type = "submit" className = "justify-self-end w-full" >
131+ { 'Create' }
132+ </ Button >
133+ </ form >
134+ </ AccordionContent >
135+ </ AccordionItem >
136+ </ Accordion >
137+ </ div >
128138 ) ;
129139
130140 // Created key content for reuse in both Dialog and Sheet/Drawer
0 commit comments