openreplay/frontend/app/components/hocs/withSiteIdRouter.js
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +01:00

27 lines
817 B
JavaScript

import React from 'react';
import { withRouter } from 'react-router-dom';
import { withSiteId } from 'App/routes';
import { observer } from 'mobx-react-lite';
import { useStore } from 'App/mstore';
export default (BaseComponent) =>
withRouter(
observer((props) => {
const { history, ...other } = props;
const { projectsStore } = useStore();
const { siteId } = projectsStore;
const push = (location) => {
if (typeof location === 'string') {
history.push(withSiteId(location, siteId));
} else if (typeof location === 'object') {
history.push({
...location,
pathname: withSiteId(location.pathname, siteId),
});
}
};
return <BaseComponent {...other} history={{ ...history, push }} />;
}),
);