Add back and forth links for register and login

This commit is contained in:
mrjvs 2023-12-07 01:52:35 +01:00
parent e420049097
commit 1217bae7ee
6 changed files with 56 additions and 8 deletions

View File

@ -2,6 +2,8 @@
"auth": { "auth": {
"deviceNameLabel": "Device name", "deviceNameLabel": "Device name",
"deviceNamePlaceholder": "Personal phone", "deviceNamePlaceholder": "Personal phone",
"hasAccount": "Already have an account? <0>Login here.</0>",
"createAccount": "Dont have an account yet? <0>Create an account.</0>",
"register": { "register": {
"information": { "information": {
"title": "Account information", "title": "Account information",

View File

@ -1,3 +1,5 @@
import classNames from "classnames";
export function LargeCard(props: { export function LargeCard(props: {
children: React.ReactNode; children: React.ReactNode;
top?: React.ReactNode; top?: React.ReactNode;
@ -36,10 +38,19 @@ export function LargeCardText(props: {
); );
} }
export function LargeCardButtons(props: { children: React.ReactNode }) { export function LargeCardButtons(props: {
children: React.ReactNode;
splitAlign?: boolean;
}) {
return ( return (
<div className="flex justify-center mt-12"> <div className="mt-12">
<div className="mx-auto inline-grid grid-cols-1 gap-3 justify-center items-center"> <div
className={classNames("mx-auto", {
"flex flex-row-reverse justify-between items-center":
props.splitAlign,
"flex max-w-xs flex-col-reverse gap-3": !props.splitAlign,
})}
>
{props.children} {props.children}
</div> </div>
</div> </div>

View File

@ -0,0 +1,23 @@
import { ReactNode } from "react";
import { Link as LinkRouter } from "react-router-dom";
export function MwLink(props: {
children?: ReactNode;
to?: string;
url?: string;
onClick?: () => void;
}) {
const isExternal = !!props.url;
const isInternal = !!props.to;
const content = (
<span className="group mt-1 cursor-pointer font-bold text-type-link hover:text-type-linkHover active:scale-95">
{props.children}
</span>
);
if (isExternal) return <a href={props.url}>{content}</a>;
if (isInternal) return <LinkRouter to={props.to ?? ""}>{content}</LinkRouter>;
return (
<span onClick={() => props.onClick && props.onClick()}>{content}</span>
);
}

View File

@ -1,5 +1,5 @@
import { useState } from "react"; import { useState } from "react";
import { useTranslation } from "react-i18next"; import { Trans, useTranslation } from "react-i18next";
import { useAsyncFn } from "react-use"; import { useAsyncFn } from "react-use";
import { verifyValidMnemonic } from "@/backend/accounts/crypto"; import { verifyValidMnemonic } from "@/backend/accounts/crypto";
@ -10,6 +10,7 @@ import {
LargeCardButtons, LargeCardButtons,
LargeCardText, LargeCardText,
} from "@/components/layout/LargeCard"; } from "@/components/layout/LargeCard";
import { MwLink } from "@/components/text/Link";
import { AuthInputBox } from "@/components/text-inputs/AuthInputBox"; import { AuthInputBox } from "@/components/text-inputs/AuthInputBox";
import { useAuth } from "@/hooks/auth/useAuth"; import { useAuth } from "@/hooks/auth/useAuth";
import { useBookmarkStore } from "@/stores/bookmarks"; import { useBookmarkStore } from "@/stores/bookmarks";
@ -88,6 +89,11 @@ export function LoginFormPart(props: LoginFormPartProps) {
{t("auth.login.submit")} {t("auth.login.submit")}
</Button> </Button>
</LargeCardButtons> </LargeCardButtons>
<p className="text-center mt-6">
<Trans i18nKey="auth.createAccount">
<MwLink to="/register">.</MwLink>
</Trans>
</p>
</LargeCard> </LargeCard>
); );
} }

View File

@ -12,6 +12,7 @@ import {
LargeCardText, LargeCardText,
} from "@/components/layout/LargeCard"; } from "@/components/layout/LargeCard";
import { Loading } from "@/components/layout/Loading"; import { Loading } from "@/components/layout/Loading";
import { MwLink } from "@/components/text/Link";
import { useBackendUrl } from "@/hooks/auth/useBackendUrl"; import { useBackendUrl } from "@/hooks/auth/useBackendUrl";
import { conf } from "@/setup/config"; import { conf } from "@/setup/config";
@ -60,16 +61,21 @@ export function TrustBackendPart(props: TrustBackendPartProps) {
{cardContent} {cardContent}
</div> </div>
<LargeCardButtons> <LargeCardButtons>
<Button theme="secondary" onClick={() => history.push("/")}>
{t("auth.trust.no")}
</Button>
<Button <Button
theme="purple" theme="purple"
onClick={() => result.value && props.onNext?.(result.value)} onClick={() => result.value && props.onNext?.(result.value)}
> >
{t("auth.trust.yes")} {t("auth.trust.yes")}
</Button> </Button>
<Button theme="secondary" onClick={() => history.push("/")}>
{t("auth.trust.no")}
</Button>
</LargeCardButtons> </LargeCardButtons>
<p className="text-center mt-6">
<Trans i18nKey="auth.hasAccount">
<MwLink to="/login">.</MwLink>
</Trans>
</p>
</LargeCard> </LargeCard>
); );
} }

View File

@ -63,7 +63,7 @@ export const defaultTheme = {
secondary: "#64647B", secondary: "#64647B",
danger: "#F46E6E", danger: "#F46E6E",
link: "#A87FD1", link: "#A87FD1",
linkHover: "#A87FD1", linkHover: "#ba8fe6",
}, },
// search bar // search bar