vojo/src/app/hooks/router/useDirectSelected.ts

27 lines
624 B
TypeScript

import { useMatch } from 'react-router-dom';
import { getBotsPath, getDirectCreatePath, getDirectPath } from '../../pages/pathUtils';
export const useDirectSelected = (): boolean => {
const directMatch = useMatch({
path: getDirectPath(),
caseSensitive: true,
end: false,
});
const botsMatch = useMatch({
path: getBotsPath(),
caseSensitive: true,
end: false,
});
return !!directMatch || !!botsMatch;
};
export const useDirectCreateSelected = (): boolean => {
const match = useMatch({
path: getDirectCreatePath(),
caseSensitive: true,
end: false,
});
return !!match;
};