mirror of
https://github.com/kremalicious/umami.git
synced 2024-06-30 13:41:50 +02:00
Get basePath from router.
This commit is contained in:
parent
c9e4003493
commit
ba9ddcac38
|
@ -10,9 +10,9 @@ import {
|
|||
} from 'react-basics';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { getRandomChars } from 'next-basics';
|
||||
import { useRouter } from 'next/router';
|
||||
import useApi from 'hooks/useApi';
|
||||
import useMessages from 'hooks/useMessages';
|
||||
import useConfig from 'hooks/useConfig';
|
||||
|
||||
const generateId = () => getRandomChars(16);
|
||||
|
||||
|
@ -21,13 +21,16 @@ export function ShareUrl({ websiteId, data, onSave }) {
|
|||
const { name, shareId } = data;
|
||||
const [id, setId] = useState(shareId);
|
||||
const { post, useMutation } = useApi();
|
||||
const { basePath } = useConfig();
|
||||
const { basePath } = useRouter();
|
||||
const { mutate, error } = useMutation(({ shareId }) =>
|
||||
post(`/websites/${websiteId}`, { shareId }),
|
||||
);
|
||||
const ref = useRef(null);
|
||||
const url = useMemo(
|
||||
() => `${process.env.analyticsUrl || location.origin}${basePath || ''}/share/${id}/${encodeURIComponent(name)}`,
|
||||
() =>
|
||||
`${process.env.analyticsUrl || location.origin}${basePath}/share/${id}/${encodeURIComponent(
|
||||
name,
|
||||
)}`,
|
||||
[id, name],
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user