()
| 147 | }; |
| 148 | |
| 149 | const onRevokeKey = async () => { |
| 150 | if (!canGenerateKey) return; |
| 151 | |
| 152 | setGenerating(true); |
| 153 | try { |
| 154 | const payload = {}; |
| 155 | if (authUser.user_level == USER_LEVELS.ADMIN && user?.id) { |
| 156 | payload.user_id = user.id; |
| 157 | } |
| 158 | |
| 159 | const resp = await revokeApiKey(payload); |
| 160 | // backend returns { success: true } - clear local state |
| 161 | if (resp && resp.success) { |
| 162 | setGeneratedKey(null); |
| 163 | setUserAPIKey(null); |
| 164 | |
| 165 | if (user?.id && authUser?.id === user.id) { |
| 166 | setUser({ ...authUser, api_key: null }); |
| 167 | } |
| 168 | } |
| 169 | } catch { |
| 170 | // API shows notifications |
| 171 | } finally { |
| 172 | setGenerating(false); |
| 173 | } |
| 174 | }; |
| 175 | |
| 176 | return ( |
| 177 | <Modal opened={isOpen} onClose={onClose} title="User" size="xl"> |
nothing calls this directly
no test coverage detected