return url factory function for useAccountsUrl

This commit is contained in:
Karol Wypchlo 2022-02-02 19:05:30 +01:00
parent 75e7844c9d
commit e2dfc8a36f
No known key found for this signature in database
GPG Key ID: B515DE9EEBE241E1
3 changed files with 9 additions and 8 deletions

View File

@ -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>
</>

View File

@ -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

View File

@ -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;
}