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