return url factory function for useAccountsUrl
This commit is contained in:
parent
75e7844c9d
commit
e2dfc8a36f
|
@ -26,7 +26,7 @@ const Navigation = ({ mode, uri }) => {
|
|||
const windowSize = useWindowSize();
|
||||
const isWindowTop = useWindowTop();
|
||||
const { data: accounts } = useAccounts();
|
||||
const accountsUrl = useAccountsUrl();
|
||||
const createAccountsUrl = useAccountsUrl();
|
||||
|
||||
React.useEffect(() => {
|
||||
setOpen(false);
|
||||
|
@ -90,11 +90,11 @@ const Navigation = ({ mode, uri }) => {
|
|||
|
||||
{showLoginNavigation && (
|
||||
<>
|
||||
<Link href={`${accountsUrl}auth/login`} className="button-link-primary">
|
||||
<Link href={createAccountsUrl("/auth/login")} className="button-link-primary">
|
||||
Log in
|
||||
</Link>
|
||||
|
||||
<Link href={`${accountsUrl}auth/registration`} className="button-primary">
|
||||
<Link href={createAccountsUrl("/auth/registration")} className="button-primary">
|
||||
Sign up
|
||||
</Link>
|
||||
</>
|
||||
|
|
|
@ -22,11 +22,11 @@ const getRootDirectory = (file) => {
|
|||
};
|
||||
|
||||
const RegistrationLink = () => {
|
||||
const accountsUrl = useAccountsUrl();
|
||||
const createAccountsUrl = useAccountsUrl();
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={`${accountsUrl}auth/registration`}
|
||||
href={createAccountsUrl("auth/registration")}
|
||||
className="uppercase underline-primary hover:text-primary transition-colors duration-200"
|
||||
>
|
||||
Sign up
|
||||
|
@ -35,11 +35,11 @@ const RegistrationLink = () => {
|
|||
};
|
||||
|
||||
const LogInLink = () => {
|
||||
const accountsUrl = useAccountsUrl();
|
||||
const createAccountsUrl = useAccountsUrl();
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={`${accountsUrl}auth/login`}
|
||||
href={createAccountsUrl("auth/login")}
|
||||
className="uppercase underline-primary hover:text-primary transition-colors duration-200"
|
||||
>
|
||||
Log in
|
||||
|
|
|
@ -3,6 +3,7 @@ import skynetClient from "./skynetClient";
|
|||
|
||||
export default function useAccountsUrl() {
|
||||
const [url, setUrl] = React.useState("");
|
||||
const createAccountsUrl = React.useCallback((path = "") => new URL(path, url).toString(), [url]);
|
||||
|
||||
React.useEffect(() => {
|
||||
(async function resolve() {
|
||||
|
@ -14,5 +15,5 @@ export default function useAccountsUrl() {
|
|||
})();
|
||||
}, [setUrl]);
|
||||
|
||||
return url;
|
||||
return createAccountsUrl;
|
||||
}
|
||||
|
|
Reference in New Issue