Merge pull request #1643 from SkynetLabs/login-link-fix

Simple fix for Login URL formatting of double slash
This commit is contained in:
Karol Wypchło 2022-02-04 11:38:55 +01:00 committed by GitHub
commit 29f7502d90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 12 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,18 +90,18 @@ 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>
</>
)}
{showAccountNavigation && (
<Link href={accountsUrl} className="button-primary">
<Link href={createAccountsUrl()} className="button-primary">
My account
</Link>
)}
@ -144,18 +144,18 @@ const Navigation = ({ mode, uri }) => {
<div className="flex items-center justify-center px-4 space-x-6">
{showLoginNavigation && (
<>
<Link href={`${accountsUrl}/auth/login`} className="button-secondary-light">
<Link href={createAccountsUrl("auth/login")} className="button-secondary-light">
Log in
</Link>
<Link href={`${accountsUrl}/auth/registration`} className="button-primary">
<Link href={createAccountsUrl("/auth/registration")} className="button-primary">
Sign up
</Link>
</>
)}
{showAccountNavigation && (
<Link href={accountsUrl} className="button-primary">
<Link href={createAccountsUrl()} className="button-primary">
My account
</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 = "") => url && new URL(path, url).toString(), [url]);
React.useEffect(() => {
(async function resolve() {
@ -14,5 +15,5 @@ export default function useAccountsUrl() {
})();
}, [setUrl]);
return url;
return createAccountsUrl;
}