mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-03 22:31:52 +00:00
Migrated to TS all servers helpers
This commit is contained in:
24
src/servers/helpers/ForServerVersion.tsx
Normal file
24
src/servers/helpers/ForServerVersion.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import React, { FC } from 'react';
|
||||
import { versionMatch, Versions } from '../../utils/helpers/version';
|
||||
import { isReachableServer, SelectedServer } from '../data';
|
||||
|
||||
interface ForServerVersionProps extends Versions {
|
||||
selectedServer: SelectedServer;
|
||||
}
|
||||
|
||||
const ForServerVersion: FC<ForServerVersionProps> = ({ minVersion, maxVersion, selectedServer, children }) => {
|
||||
if (!isReachableServer(selectedServer)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { version } = selectedServer;
|
||||
const matchesVersion = versionMatch(version, { maxVersion, minVersion });
|
||||
|
||||
if (!matchesVersion) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return <React.Fragment>{children}</React.Fragment>;
|
||||
};
|
||||
|
||||
export default ForServerVersion;
|
||||
Reference in New Issue
Block a user