From ab3c8e4e7e48cf164337a95d220e8f73dc18ce86 Mon Sep 17 00:00:00 2001 From: Puranjay Savar Mattas Date: Fri, 1 Aug 2025 13:21:48 +0000 Subject: [PATCH] refactor(oidc): remove explanatory comments Removes unnecessary tutorial-style comments from the OIDC components. The code is now self-documenting, and these comments added noise without providing additional value. This change cleans up the code and aligns it with the project's established style. Addresses https://github.com/michaelhthomas/jellyseerr/pull/4#pullrequestreview-3079128668 --- src/components/Login/OidcLoginButton.tsx | 4 +--- src/components/Settings/EditOidcModal/index.tsx | 10 +--------- src/components/Settings/SettingsOidc/index.tsx | 4 +--- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/components/Login/OidcLoginButton.tsx b/src/components/Login/OidcLoginButton.tsx index b822e2c0e..7657ac80d 100644 --- a/src/components/Login/OidcLoginButton.tsx +++ b/src/components/Login/OidcLoginButton.tsx @@ -1,6 +1,6 @@ import defineMessages from '@app/utils/defineMessages'; import type { PublicOidcProvider } from '@server/lib/settings'; -import axios, { isAxiosError } from 'axios'; // <-- isAxiosError is now needed here +import axios, { isAxiosError } from 'axios'; import { useRouter, useSearchParams } from 'next/navigation'; import { useCallback, useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; @@ -10,7 +10,6 @@ const messages = defineMessages('components.Login', { oidcLoginError: 'An error occurred while logging in with {provider}.', }); -// The function from src/utils/oidc.ts is now here as a local helper async function processCallback(params: URLSearchParams, provider: string) { const url = new URL( `/api/v1/auth/oidc/callback/${encodeURIComponent(provider)}`, @@ -69,7 +68,6 @@ export default function OidcLoginButton({ }, [provider, intl, onError]); const handleCallback = useCallback(async () => { - // This now calls the local helper function const result = await processCallback(searchParams, provider.slug); if (result.type === 'success') { // redirect to homepage diff --git a/src/components/Settings/EditOidcModal/index.tsx b/src/components/Settings/EditOidcModal/index.tsx index f698c296d..9f4b831f3 100644 --- a/src/components/Settings/EditOidcModal/index.tsx +++ b/src/components/Settings/EditOidcModal/index.tsx @@ -8,13 +8,7 @@ import { ChevronRightIcon } from '@heroicons/react/20/solid'; import { MagnifyingGlassIcon } from '@heroicons/react/24/solid'; import type { OidcProvider } from '@server/lib/settings'; import axios from 'axios'; -import { - // ErrorMessage has been removed from the import - Field, - Formik, - useFormikContext, - type FieldAttributes, -} from 'formik'; +import { Field, Formik, useFormikContext, type FieldAttributes } from 'formik'; import { useEffect } from 'react'; import { useIntl } from 'react-intl'; import { useToasts } from 'react-toast-notifications'; @@ -134,7 +128,6 @@ export default function EditOidcModal(props: EditOidcModalProps) { onSubmit={onSubmit} enableReinitialize > - {/* Get errors and touched from Formik render props */} {({ handleSubmit, isValid, errors, touched }) => (
- {/* Replaced ErrorMessage component with manual div */} {errors.name && touched.name && typeof errors.name === 'string' && ( diff --git a/src/components/Settings/SettingsOidc/index.tsx b/src/components/Settings/SettingsOidc/index.tsx index d7e01d1e0..cdfc56487 100644 --- a/src/components/Settings/SettingsOidc/index.tsx +++ b/src/components/Settings/SettingsOidc/index.tsx @@ -8,7 +8,7 @@ import { Transition } from '@headlessui/react'; import { PlusIcon } from '@heroicons/react/24/outline'; import { PencilIcon, TrashIcon } from '@heroicons/react/24/solid'; import type { OidcProvider, OidcSettings } from '@server/lib/settings'; -import axios from 'axios'; // <-- Import axios +import axios from 'axios'; import { useState } from 'react'; import { useIntl } from 'react-intl'; import { useToasts } from 'react-toast-notifications'; @@ -48,8 +48,6 @@ export default function SettingsOidc(props: SettingsOidcProps) { async function onDelete(provider: OidcProvider) { try { - // The fetch call is replaced with axios.delete. - // Axios automatically throws for non-2xx responses and handles JSON parsing. const response = await axios.delete( `/api/v1/settings/oidc/${provider.slug}` );