diff --git a/apps/dashboard/app/api-keys/server-actions.ts b/apps/dashboard/app/api-keys/server-actions.ts index b3cd1f4570..116fa2cdd9 100644 --- a/apps/dashboard/app/api-keys/server-actions.ts +++ b/apps/dashboard/app/api-keys/server-actions.ts @@ -51,8 +51,10 @@ export const createApiKeyServerAction = async ( _prevState: ApiKeyResponse, form: FormData, ): Promise => { + let apiKeyExpiresInDays: number | null = null const apiKeyName = form.get("apiKeyName") const readOnly = form.get("apiScope") === "readOnly" + const apiKeyExpiresInDaysSelect = form.get("apiKeyExpiresInDaysSelect") if (!apiKeyName || typeof apiKeyName !== "string") { return { @@ -62,10 +64,14 @@ export const createApiKeyServerAction = async ( } } - const apiKeyExpiresInDaysFormData = form.get("apiKeyExpiresInDays") - const apiKeyExpiresInDays = apiKeyExpiresInDaysFormData - ? parseInt(String(apiKeyExpiresInDaysFormData)) - : null + if (apiKeyExpiresInDaysSelect === "custom") { + const customValue = form.get("apiKeyExpiresInDaysCustom") + apiKeyExpiresInDays = customValue ? parseInt(customValue as string, 10) : null + } else { + apiKeyExpiresInDays = apiKeyExpiresInDaysSelect + ? parseInt(apiKeyExpiresInDaysSelect as string, 10) + : null + } const session = await getServerSession(authOptions) const token = session?.accessToken diff --git a/apps/dashboard/components/api-keys/create.tsx b/apps/dashboard/components/api-keys/create.tsx index c4001bf576..3656681e8d 100644 --- a/apps/dashboard/components/api-keys/create.tsx +++ b/apps/dashboard/components/api-keys/create.tsx @@ -204,13 +204,10 @@ const ApiKeyCreate = () => { }} > Expires In -