mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 01:13:55 +00:00
657cc22b44
* feat: parse cue * refactor: get delay from backend * feat: add cue to UI * refactor: remove deprecated delay logic * refactor: extract studio clock specific logic * refactor: extract utilities * refactor: fix issue with missing key * style: prevent cue overflow * style: prevent whitespace wrap * feat: add support for cues in integrations
30 lines
909 B
TypeScript
30 lines
909 B
TypeScript
/* eslint-disable react/display-name */
|
|
import { ComponentType, useEffect } from 'react';
|
|
import { useLocation, useNavigate, useSearchParams } from 'react-router-dom';
|
|
|
|
import useAliases from '../common/hooks-query/useAliases';
|
|
import { getAliasRoute } from '../common/utils/aliases';
|
|
|
|
const withAlias = <P extends object>(Component: ComponentType<P>) => {
|
|
return (props: Partial<P>) => {
|
|
const { data } = useAliases();
|
|
const [searchParams] = useSearchParams();
|
|
const navigate = useNavigate();
|
|
const location = useLocation();
|
|
|
|
// navigate if is alias route
|
|
useEffect(() => {
|
|
if (!data) return;
|
|
const url = getAliasRoute(location, data, searchParams);
|
|
// navigate to this route if its not empty
|
|
if (url) {
|
|
navigate(url);
|
|
}
|
|
}, [data, searchParams, navigate, location]);
|
|
|
|
return <Component {...props} />;
|
|
};
|
|
};
|
|
|
|
export default withAlias;
|