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:
abhi1992002
2026-02-12 18:10:54 +05:30
parent d09f1532a4
commit c88eaddafc

View File

@@ -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: "",
},
});