6d35f2b39d
Co-authored-by: Madalina Raicu <madalina@raygroup.uk>
16 lines
411 B
TypeScript
16 lines
411 B
TypeScript
import { routerConfig } from '../../pages/client-router';
|
|
import { matchRoutes, useLocation } from 'react-router-dom';
|
|
|
|
export const useGetCurrentRouteId = () => {
|
|
const location = useLocation();
|
|
const currentRoute = matchRoutes(routerConfig, location);
|
|
const lastRoute = currentRoute?.pop();
|
|
if (lastRoute) {
|
|
const {
|
|
route: { id },
|
|
} = lastRoute;
|
|
return id || '';
|
|
}
|
|
return '';
|
|
};
|