mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
36 lines
No EOL
860 B
TypeScript
36 lines
No EOL
860 B
TypeScript
'use client';
|
|
|
|
import { useRouter } from "next/navigation";
|
|
import { useDomain } from "@/hooks/useDomain";
|
|
import { useCallback } from "react";
|
|
import { getBrowsePath, GetBrowsePathProps } from "./utils";
|
|
|
|
export const useBrowseNavigation = () => {
|
|
const router = useRouter();
|
|
const domain = useDomain();
|
|
|
|
const navigateToPath = useCallback(({
|
|
repoName,
|
|
revisionName = 'HEAD',
|
|
path,
|
|
pathType,
|
|
highlightRange,
|
|
setBrowseState,
|
|
}: Omit<GetBrowsePathProps, 'domain'>) => {
|
|
const browsePath = getBrowsePath({
|
|
repoName,
|
|
revisionName,
|
|
path,
|
|
pathType,
|
|
highlightRange,
|
|
setBrowseState,
|
|
domain,
|
|
});
|
|
|
|
router.push(browsePath);
|
|
}, [domain, router]);
|
|
|
|
return {
|
|
navigateToPath,
|
|
};
|
|
};
|