mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-07-19 18:21:54 +00:00
Fix coding standards for typescript-eslint 8
This commit is contained in:
@@ -60,7 +60,11 @@ const CreateServer: FCWithDeps<CreateServerProps, CreateServerDeps> = ({ servers
|
||||
({ url, apiKey }) => serverData?.url === url && serverData?.apiKey === apiKey,
|
||||
);
|
||||
|
||||
serverExists ? toggleConfirmModal() : saveNewServer(serverData);
|
||||
if (serverExists) {
|
||||
toggleConfirmModal();
|
||||
} else {
|
||||
saveNewServer(serverData);
|
||||
}
|
||||
}, [saveNewServer, serverData, servers, toggleConfirmModal]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -30,7 +30,9 @@ export const DeleteServerModal: FC<DeleteServerModalConnectProps> = (
|
||||
}
|
||||
|
||||
deleteServer(server);
|
||||
redirectHome && navigate('/');
|
||||
if (redirectHome) {
|
||||
navigate('/');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -31,7 +31,9 @@ const EditServer: FCWithDeps<EditServerProps, EditServerDeps> = withSelectedServ
|
||||
|
||||
const handleSubmit = (serverData: ServerData) => {
|
||||
editServer(selectedServer.id, serverData);
|
||||
reconnect === 'true' && selectServer(selectedServer.id);
|
||||
if (reconnect === 'true') {
|
||||
selectServer(selectedServer.id);
|
||||
}
|
||||
goBack();
|
||||
};
|
||||
|
||||
|
||||
@@ -58,8 +58,12 @@ const ImportServersBtn: FCWithDeps<ImportServersBtnConnectProps, ImportServersBt
|
||||
const dupServers = newServers.filter((server) => serversInclude(existingServers, server));
|
||||
const hasDuplicatedServers = !!dupServers.length;
|
||||
|
||||
!hasDuplicatedServers ? create(newServers) : setDuplicatedServers(dupServers);
|
||||
hasDuplicatedServers && showModal();
|
||||
if (!hasDuplicatedServers) {
|
||||
create(newServers);
|
||||
} else {
|
||||
setDuplicatedServers(dupServers);
|
||||
showModal();
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
// Reset input after processing file
|
||||
|
||||
@@ -17,9 +17,11 @@ export const ServerForm: FC<ServerFormProps> = ({ onSubmit, initialValues, child
|
||||
const handleSubmit = handleEventPreventingDefault(() => onSubmit({ name, url, apiKey }));
|
||||
|
||||
useEffect(() => {
|
||||
initialValues && setName(initialValues.name);
|
||||
initialValues && setUrl(initialValues.url);
|
||||
initialValues && setApiKey(initialValues.apiKey);
|
||||
if (initialValues) {
|
||||
setName(initialValues.name);
|
||||
setUrl(initialValues.url);
|
||||
setApiKey(initialValues.apiKey);
|
||||
}
|
||||
}, [initialValues]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,7 +17,7 @@ type WithSelectedServerPropsDeps = {
|
||||
ServerError: FC;
|
||||
};
|
||||
|
||||
export function withSelectedServer<T = {}>(
|
||||
export function withSelectedServer<T extends object>(
|
||||
WrappedComponent: FCWithDeps<WithSelectedServerProps & T, WithSelectedServerPropsDeps>,
|
||||
) {
|
||||
const ComponentWrapper: FCWithDeps<WithSelectedServerProps & T, WithSelectedServerPropsDeps> = (props) => {
|
||||
@@ -26,7 +26,9 @@ export function withSelectedServer<T = {}>(
|
||||
const { selectServer, selectedServer } = props;
|
||||
|
||||
useEffect(() => {
|
||||
params.serverId && selectServer(params.serverId);
|
||||
if (params.serverId) {
|
||||
selectServer(params.serverId);
|
||||
}
|
||||
}, [params.serverId, selectServer]);
|
||||
|
||||
if (!selectedServer) {
|
||||
|
||||
@@ -2,10 +2,10 @@ import type { FC } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
interface WithoutSelectedServerProps {
|
||||
resetSelectedServer: Function;
|
||||
resetSelectedServer: () => unknown;
|
||||
}
|
||||
|
||||
export function withoutSelectedServer<T = {}>(WrappedComponent: FC<WithoutSelectedServerProps & T>) {
|
||||
export function withoutSelectedServer<T extends object>(WrappedComponent: FC<WithoutSelectedServerProps & T>) {
|
||||
return (props: WithoutSelectedServerProps & T) => {
|
||||
const { resetSelectedServer } = props;
|
||||
useEffect(() => {
|
||||
|
||||
@@ -50,7 +50,7 @@ export const selectServer = (buildShlinkApiClient: ShlinkApiClientBuilder) => cr
|
||||
version,
|
||||
printableVersion,
|
||||
};
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return { ...selectedServer, serverNotReachable: true };
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user