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
This commit is contained in:
committed by
Michael Thomas
parent
05b0a1fa99
commit
ab3c8e4e7e
@@ -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
|
||||
|
||||
@@ -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 }) => (
|
||||
<Modal
|
||||
onCancel={props.onClose}
|
||||
@@ -162,7 +155,6 @@ export default function EditOidcModal(props: EditOidcModalProps) {
|
||||
</label>
|
||||
<div className="form-input-area">
|
||||
<Field id="oidcName" name="name" type="text" />
|
||||
{/* Replaced ErrorMessage component with manual div */}
|
||||
{errors.name &&
|
||||
touched.name &&
|
||||
typeof errors.name === 'string' && (
|
||||
|
||||
@@ -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<OidcSettings>(
|
||||
`/api/v1/settings/oidc/${provider.slug}`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user