mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-12 07:45:14 -05:00
refactor(frontend): simplify default expiration date handling in APIKeyCredentialsModal
### Changes - Removed the `getDefaultExpirationDate` function and set the `expiresAt` default value to an empty string in the `useAPIKeyCredentialsModal` hook. This change streamlines the code by eliminating unnecessary complexity related to date handling. ### Impact - Enhances code readability and maintainability by simplifying the default value assignment for expiration dates.
This commit is contained in:
@@ -40,24 +40,12 @@ export function useAPIKeyCredentialsModal({
|
||||
expiresAt: z.string().optional(),
|
||||
});
|
||||
|
||||
function getDefaultExpirationDate(): string {
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
tomorrow.setHours(0, 0, 0, 0);
|
||||
const year = tomorrow.getFullYear();
|
||||
const month = String(tomorrow.getMonth() + 1).padStart(2, "0");
|
||||
const day = String(tomorrow.getDate()).padStart(2, "0");
|
||||
const hours = String(tomorrow.getHours()).padStart(2, "0");
|
||||
const minutes = String(tomorrow.getMinutes()).padStart(2, "0");
|
||||
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
||||
}
|
||||
|
||||
const form = useForm<APIKeyFormValues>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
apiKey: "",
|
||||
title: "",
|
||||
expiresAt: getDefaultExpirationDate(),
|
||||
expiresAt: "",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user