2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Redirect, Route } from 'react-router-dom';
|
2020-10-06 20:28:38 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default function FeatureToggledRoute({ flag, redirectRoute, ...props }) {
|
2020-10-06 20:28:38 +02:00
|
|
|
if (flag) {
|
2021-02-04 19:15:23 +01:00
|
|
|
return <Route {...props} />;
|
2020-10-06 20:28:38 +02:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
return <Redirect to={{ pathname: redirectRoute }} />;
|
2020-10-06 20:28:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FeatureToggledRoute.propTypes = {
|
|
|
|
flag: PropTypes.bool.isRequired,
|
|
|
|
redirectRoute: PropTypes.string.isRequired,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|