mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
25 lines
651 B
TypeScript
25 lines
651 B
TypeScript
import { 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 <>{children}</>;
|
|
};
|
|
|
|
export default ForServerVersion;
|