@@ -22,7 +22,7 @@ import ConfirmDialog from "../components/ui/confirm-dialog";
2222export default function Environments ( ) {
2323 const [ isAddingVariable , setIsAddingVariable ] = useState ( false ) ;
2424 const [ isAddingEnv , setIsAddingEnv ] = useState ( false ) ;
25- const [ isRotatingKey , setIsRotatingKey ] = useState ( false ) ;
25+ const [ isRotatingKey , setIsRotatingKey ] = useState ( null ) ;
2626 const [ isEditingVariable , setIsEditingVariable ] = useState ( false ) ;
2727 const [ isTogglingVariable , setIsToggligVariable ] = useState ( null ) ;
2828 const [ isDeletingVariable , setIsDeletingVariable ] = useState ( null ) ;
@@ -148,14 +148,14 @@ function openDeleteProjectDialog() {
148148 // 🔹 Rotate Key
149149 async function rotate ( envId ) {
150150 if ( isRotatingKey ) return ;
151- setIsRotatingKey ( true ) ;
151+ setIsRotatingKey ( envId ) ;
152152 try {
153153 const res = await api . post ( `/api/environments/${ envId } /rotate-key` , { } , token ) ;
154154 setRotatedKey ( res . apiKey ) ;
155155 } catch ( error ) {
156156
157157 } finally {
158- setIsRotatingKey ( false ) ;
158+ setIsRotatingKey ( null ) ;
159159 }
160160
161161 }
@@ -339,8 +339,8 @@ function openDeleteProjectDialog() {
339339 </ div >
340340 < div className = "flex gap-2 flex-row flex-wrap" >
341341 < Button onClick = { ( ) => rotate ( env . _id ) } variant = "outline" size = "sm" className = "gap-2" >
342- { isRotatingKey && < > < RotateCcw className = "w-4 h-4 animate-spin" /> Rotate Key </ > }
343- { ! isRotatingKey && < > < RotateCcw className = "w-4 h-4" /> Rotate Key </ > }
342+ { isRotatingKey === env . _id && < > < RotateCcw className = "w-4 h-4 animate-spin" /> Rotating Key </ > }
343+ { isRotatingKey !== env . _id && < > < RotateCcw className = "w-4 h-4" /> Rotate Key </ > }
344344 </ Button >
345345 < Button onClick = { ( ) => toggleEnv ( env . _id ) } variant = "outline" size = "sm" className = "gap-2" >
346346 { selectedEnv === env . _id ? (
0 commit comments