mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-10 22:41:41 +00:00
fix: address PR review comments on RegenerateKeyModal
- Remove redundant useEffect cleanup that duplicated handleClose logic - Remove unnecessary currentAccessToken state, use accessToken from hook directly
This commit is contained in:
parent
2e0af3795a
commit
7c6bd98fdf
1 changed files with 2 additions and 21 deletions
|
|
@ -26,9 +26,6 @@ export function RegenerateKeyModal({ selectedToken, visible, onClose, onKeyUpdat
|
|||
const [isRegenerating, setIsRegenerating] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
|
||||
// Keep track of the current valid access token locally
|
||||
const [currentAccessToken, setCurrentAccessToken] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (visible && selectedToken && accessToken) {
|
||||
form.setFieldsValue({
|
||||
|
|
@ -39,23 +36,9 @@ export function RegenerateKeyModal({ selectedToken, visible, onClose, onKeyUpdat
|
|||
duration: selectedToken.duration || "",
|
||||
grace_period: "",
|
||||
});
|
||||
|
||||
// Initialize the current access token
|
||||
setCurrentAccessToken(accessToken);
|
||||
}
|
||||
}, [visible, selectedToken, form, accessToken]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!visible) {
|
||||
// Reset states when modal is closed
|
||||
setRegeneratedKey(null);
|
||||
setIsRegenerating(false);
|
||||
setCurrentAccessToken(null);
|
||||
setCopied(false);
|
||||
form.resetFields();
|
||||
}
|
||||
}, [visible, form]);
|
||||
|
||||
const calculateNewExpiryTime = (duration: string | undefined): string | null => {
|
||||
if (!duration) return null;
|
||||
|
||||
|
|
@ -98,15 +81,14 @@ export function RegenerateKeyModal({ selectedToken, visible, onClose, onKeyUpdat
|
|||
}, [regenerateFormData?.duration]);
|
||||
|
||||
const handleRegenerateKey = async () => {
|
||||
if (!selectedToken || !currentAccessToken) return;
|
||||
if (!selectedToken || !accessToken) return;
|
||||
|
||||
setIsRegenerating(true);
|
||||
try {
|
||||
const formValues = await form.validateFields();
|
||||
|
||||
// Use the current access token for the API call
|
||||
const response = await regenerateKeyCall(
|
||||
currentAccessToken,
|
||||
accessToken,
|
||||
selectedToken.token || selectedToken.token_id,
|
||||
formValues,
|
||||
);
|
||||
|
|
@ -145,7 +127,6 @@ export function RegenerateKeyModal({ selectedToken, visible, onClose, onKeyUpdat
|
|||
const handleClose = () => {
|
||||
setRegeneratedKey(null);
|
||||
setIsRegenerating(false);
|
||||
setCurrentAccessToken(null);
|
||||
setCopied(false);
|
||||
form.resetFields();
|
||||
onClose();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue