0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-30 20:33:54 -05:00

chore(console): code cleanup (#4390)

This commit is contained in:
Charles Zhao 2023-08-24 15:58:36 +08:00 committed by GitHub
parent dcff078d68
commit 8459cb55ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 8 additions and 12 deletions

View file

@ -1,6 +1,5 @@
import type { FormEventHandler, KeyboardEventHandler } from 'react'; import type { FormEventHandler, KeyboardEventHandler } from 'react';
import { useState } from 'react'; import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import SearchIcon from '@/assets/icons/search.svg'; import SearchIcon from '@/assets/icons/search.svg';
@ -27,8 +26,6 @@ function Search({
onClearSearch, onClearSearch,
}: Props) { }: Props) {
const [inputValue, setInputValue] = useState<string>(defaultValue); const [inputValue, setInputValue] = useState<string>(defaultValue);
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const handleSearchKeyPress: KeyboardEventHandler<HTMLInputElement> = (event) => { const handleSearchKeyPress: KeyboardEventHandler<HTMLInputElement> = (event) => {
if (event.key === 'Enter' && inputValue) { if (event.key === 'Enter' && inputValue) {
onSearch?.(inputValue); onSearch?.(inputValue);

View file

@ -3,6 +3,7 @@ import { useLogto } from '@logto/react';
import { getManagementApiResourceIndicator, type RequestErrorBody } from '@logto/schemas'; import { getManagementApiResourceIndicator, type RequestErrorBody } from '@logto/schemas';
import { conditionalArray } from '@silverhand/essentials'; import { conditionalArray } from '@silverhand/essentials';
import ky from 'ky'; import ky from 'ky';
import { type KyInstance } from 'node_modules/ky/distribution/types/ky';
import { useCallback, useContext, useMemo } from 'react'; import { useCallback, useContext, useMemo } from 'react';
import { toast } from 'react-hot-toast'; import { toast } from 'react-hot-toast';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
@ -29,7 +30,11 @@ export type StaticApiProps = {
resourceIndicator: string; resourceIndicator: string;
}; };
export const useStaticApi = ({ prefixUrl, hideErrorToast, resourceIndicator }: StaticApiProps) => { export const useStaticApi = ({
prefixUrl,
hideErrorToast,
resourceIndicator,
}: StaticApiProps): KyInstance => {
const { isAuthenticated, getAccessToken, signOut } = useLogto(); const { isAuthenticated, getAccessToken, signOut } = useLogto();
const { t, i18n } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const { t, i18n } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const { show } = useConfirmModal(); const { show } = useConfirmModal();

View file

@ -1,7 +1,6 @@
import type { AdminConsoleKey } from '@logto/phrases'; import type { AdminConsoleKey } from '@logto/phrases';
import classNames from 'classnames'; import classNames from 'classnames';
import type { ReactNode } from 'react'; import type { ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
import type { PreviewPlatform } from '@/components/SignInExperiencePreview/types'; import type { PreviewPlatform } from '@/components/SignInExperiencePreview/types';
import DynamicT from '@/ds-components/DynamicT'; import DynamicT from '@/ds-components/DynamicT';
@ -18,8 +17,6 @@ type Props = {
}; };
function PlatformTab({ isSelected, icon, title, tab, onClick }: Props) { function PlatformTab({ isSelected, icon, title, tab, onClick }: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
return ( return (
<div <div
role="tab" role="tab"

View file

@ -51,7 +51,6 @@ const mapToUriOriginFormatArrays = (value?: string[]) =>
function ApplicationDetails() { function ApplicationDetails() {
const { id, guideId, tab } = useParams(); const { id, guideId, tab } = useParams();
console.log(tab);
const { navigate, match } = useTenantPathname(); const { navigate, match } = useTenantPathname();
const isGuideView = id && guideId && match(`/applications/${id}/guide/${guideId}`); const isGuideView = id && guideId && match(`/applications/${id}/guide/${guideId}`);

View file

@ -1,7 +1,6 @@
import type { AdminConsoleKey } from '@logto/phrases'; import type { AdminConsoleKey } from '@logto/phrases';
import { conditionalString } from '@silverhand/essentials'; import { conditionalString } from '@silverhand/essentials';
import classNames from 'classnames'; import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import ArrowDown from '@/assets/icons/arrow-down.svg'; import ArrowDown from '@/assets/icons/arrow-down.svg';
import ArrowUp from '@/assets/icons/arrow-up.svg'; import ArrowUp from '@/assets/icons/arrow-up.svg';
@ -24,8 +23,6 @@ type Props = {
}; };
function Block({ variant = 'default', count, delta, title, tip }: Props) { function Block({ variant = 'default', count, delta, title, tip }: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const deltaLabel = delta !== undefined && `${conditionalString(delta >= 0 && '+')}${delta}`; const deltaLabel = delta !== undefined && `${conditionalString(delta >= 0 && '+')}${delta}`;
return ( return (

View file

@ -125,6 +125,7 @@ function LinkAccountSection({ user, connectors, onUpdate }: Props) {
t, t,
onUpdate, onUpdate,
getSocialAuthorizationUri, getSocialAuthorizationUri,
getUrl,
]); ]);
return ( return (

View file

@ -48,7 +48,7 @@ function CustomHeaderField() {
}; };
const revalidate = () => { const revalidate = () => {
for (const [index, _] of fields.entries()) { for (const [index] of fields.entries()) {
void trigger(`headers.${index}.key`); void trigger(`headers.${index}.key`);
if (submitCount > 0) { if (submitCount > 0) {
void trigger(`headers.${index}.value`); void trigger(`headers.${index}.value`);