mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
25 lines
686 B
TypeScript
25 lines
686 B
TypeScript
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;
|