mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 13:47:15 +01:00
Typescript conversion.
This commit is contained in:
parent
366ef35d3d
commit
8775d696b8
29 changed files with 74 additions and 57 deletions
|
|
@ -1,27 +0,0 @@
|
|||
import { useMemo } from 'react';
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation';
|
||||
import { buildUrl } from 'next-basics';
|
||||
|
||||
export function useNavigation() {
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const params = useSearchParams();
|
||||
|
||||
const query = useMemo(() => {
|
||||
const obj = {};
|
||||
|
||||
for (const [key, value] of params.entries()) {
|
||||
obj[key] = decodeURIComponent(value);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}, [params]);
|
||||
|
||||
function makeUrl(params, reset) {
|
||||
return reset ? pathname : buildUrl(pathname, { ...query, ...params });
|
||||
}
|
||||
|
||||
return { pathname, query, router, makeUrl };
|
||||
}
|
||||
|
||||
export default useNavigation;
|
||||
Loading…
Add table
Add a link
Reference in a new issue