diff --git a/src/common/components/atoms/about.tsx b/src/common/components/atoms/about.tsx index 64e18c5..bfe2f69 100644 --- a/src/common/components/atoms/about.tsx +++ b/src/common/components/atoms/about.tsx @@ -35,7 +35,7 @@ export const About = () => { className="link" href="https://www.linkedin.com/in/sytabaresa" > - @sytabares + @syta A product of diff --git a/src/common/components/atoms/icons/index.tsx b/src/common/components/atoms/icons/index.tsx index 492fe6c..bfcb93c 100644 --- a/src/common/components/atoms/icons/index.tsx +++ b/src/common/components/atoms/icons/index.tsx @@ -14,19 +14,23 @@ const IconGen = (meta: Record) => (props: IconProps) => { export const TestIcon = IconGen({ alt: "arc-icon", src: "" }) export function GoogleIcon(props) { - return - + return + + + + + } + + export function MicrosoftIcon(props) { return - - - - + + + + } diff --git a/src/common/components/atoms/langMenu.tsx b/src/common/components/atoms/langMenu.tsx index fc0ce52..b9def14 100644 --- a/src/common/components/atoms/langMenu.tsx +++ b/src/common/components/atoms/langMenu.tsx @@ -11,9 +11,9 @@ export const LangMenu = (props: HTMLAttributes) => { // console.log("lang", locales, lang) - return + return {t.common.lang()}: - {lang || '--'} + {lang || '--'} {locales.map((item, i) => diff --git a/src/common/components/atoms/smithButton.tsx b/src/common/components/atoms/smithButton.tsx index 098f053..2201178 100644 --- a/src/common/components/atoms/smithButton.tsx +++ b/src/common/components/atoms/smithButton.tsx @@ -8,7 +8,7 @@ const SmithButton = () => { const { t } = useTranslation(); return - {t.canvas.smith_mode()} ) { // console.log('set', e.target.checked) setTheme(e.target.checked ? "dark" : "light") } - return + return { + +} + +export function EmailLogin({ className }: EmailLoginProps) { + const [isLogin, setIsLogin] = useState(true); + const { t } = useTranslation(); + + + return + + setIsLogin(true)} + > + {t.login.login()} + + setIsLogin(false)} + > + {t.login.sign_up()} + + + + {isLogin ? ( + + ) : ( + + )} + + +} \ No newline at end of file diff --git a/src/common/components/organisms/login/loginForm.tsx b/src/common/components/organisms/login/loginForm.tsx index 8d6fddf..cfb81b3 100644 --- a/src/common/components/organisms/login/loginForm.tsx +++ b/src/common/components/organisms/login/loginForm.tsx @@ -20,7 +20,6 @@ const LoginForm = ({ }: LoginFormProps) => { const { login } = useAuthProvider() const onSubmitLogin = async (data) => { - const { email, password } = data; try { const user = await login(data) @@ -31,29 +30,8 @@ const LoginForm = ({ }: LoginFormProps) => { } }; - const onGoogleLogin = async (data) => { - try { - const user = await login({ provider: 'google' }) - } catch (err) { - setError("root.login", { message: err }) - } - } - - const onMicrosoftLogin = async (data) => { - try { - const user = await login({ provider: 'microsoft' }) - } catch (err) { - setError("root.login", { message: err }) - } - } - return ( - - - {errors?.root?.login?.message} - - {t.login.username()} @@ -95,26 +73,17 @@ const LoginForm = ({ }: LoginFormProps) => { )} {isSubmitting ? t.login.logging_in() + "..." : isSubmitSuccessful ? t.login.done() : t.login.login()} - - - - - {t.login.google_login()} - - - - - - {t.login.microsoft_login()} - - + + + {errors?.root?.login?.message} + + + ) } diff --git a/src/common/components/organisms/login/signupForm.tsx b/src/common/components/organisms/login/signupForm.tsx index e3f5004..4cd941c 100644 --- a/src/common/components/organisms/login/signupForm.tsx +++ b/src/common/components/organisms/login/signupForm.tsx @@ -38,11 +38,6 @@ const SingUpForm = ({ }: SignUpFormProps) => { return ( - - - {errors?.root?.login?.message} - - {t.login.username()} @@ -93,9 +88,14 @@ const SingUpForm = ({ }: SignUpFormProps) => { {t.login.password_match()} )} - + {t.login.sign_up()} + + + {errors?.root?.login?.message} + + ); }; diff --git a/src/common/components/organisms/primitivesMenu.tsx b/src/common/components/organisms/primitivesMenu.tsx index 6710eaa..f53b11b 100644 --- a/src/common/components/organisms/primitivesMenu.tsx +++ b/src/common/components/organisms/primitivesMenu.tsx @@ -91,7 +91,7 @@ const PrimitivesMenu = (props: PrimitivesMenuProps) => { @@ -112,7 +112,7 @@ const PrimitivesMenu = (props: PrimitivesMenuProps) => { send('EXIT')}> diff --git a/src/modules/i18n/en/index.ts b/src/modules/i18n/en/index.ts index 447b87e..5965d56 100644 --- a/src/modules/i18n/en/index.ts +++ b/src/modules/i18n/en/index.ts @@ -63,8 +63,10 @@ const en: Translation = { password_required: "Password Required", google_login: "with Google", microsoft_login: "with Microsoft", + email_login: "with Email", repeat_password: "Repeat Password", - login: "Login", + login: "Log in", + login_title: "Log in", sign_up: "Sign Up", logging_in: "Logging In", done: "Done", diff --git a/src/modules/i18n/es/index.ts b/src/modules/i18n/es/index.ts index e7db7ce..8a50b4c 100644 --- a/src/modules/i18n/es/index.ts +++ b/src/modules/i18n/es/index.ts @@ -62,10 +62,12 @@ const es: BaseTranslation = { password_required: "Contraseña Requerida", google_login: "con Google", microsoft_login: "con Microsoft", + email_login: "con email", repeat_password: "Repita Contraseña", sign_up: "Registrarse", - login: "Login", - logging_in: "Loguéandose", + login: "Iniciar", + login_title: "Inicia sesión", + logging_in: "Iniciando", done: "Hecho", password_match: "Contraseñas no concuerdan" }, diff --git a/src/modules/i18n/i18n-types.ts b/src/modules/i18n/i18n-types.ts index cd7d06a..cfad930 100644 --- a/src/modules/i18n/i18n-types.ts +++ b/src/modules/i18n/i18n-types.ts @@ -209,14 +209,22 @@ type RootTranslation = { * with Microsoft */ microsoft_login: string + /** + * with Email + */ + email_login: string /** * Repeat Password */ repeat_password: string /** - * Login + * Log in */ login: string + /** + * Log in + */ + login_title: string /** * Sign Up */ @@ -770,14 +778,22 @@ export type TranslationFunctions = { * with Microsoft */ microsoft_login: () => LocalizedString + /** + * with Email + */ + email_login: () => LocalizedString /** * Repeat Password */ repeat_password: () => LocalizedString /** - * Login + * Log in */ login: () => LocalizedString + /** + * Log in + */ + login_title: () => LocalizedString /** * Sign Up */ diff --git a/src/pages/login.page.tsx b/src/pages/login.page.tsx index e486a1e..5d5a7f5 100644 --- a/src/pages/login.page.tsx +++ b/src/pages/login.page.tsx @@ -1,10 +1,11 @@ import { useEffect, useState } from "react"; import Layout from "@components/templates/default"; -import { useUser } from "@hooks/useAuthProvider"; -import SingUpForm from "@components/organisms/login/signupForm"; -import LoginForm from "@components/organisms/login/loginForm"; +import { useAuthProvider, useUser } from "@hooks/useAuthProvider"; import { useLanguageQuery, useTranslation } from "@modules/i18n"; import { useRouter } from "@modules/router"; +import { GoogleIcon, MicrosoftIcon } from "@components/atoms/icons"; +import { AtSymbolIcon } from "@heroicons/react/outline"; +import { EmailLogin } from "@components/organisms/login/emailLogin"; import { cn } from "@utils/styles"; export { Login as Page } @@ -16,7 +17,6 @@ interface LoginProps { const Login = ({ homePage = "/saved" }: LoginProps) => { const { t } = useTranslation(); const [query] = useLanguageQuery() - const [isLogin, setIsLogin] = useState(true); const { useHistory, useParams } = useRouter() const { push } = useHistory(); @@ -24,6 +24,9 @@ const Login = ({ homePage = "/saved" }: LoginProps) => { const { isAuthenticated } = useUser(); // console.log(isAuthenticated) + const { login } = useAuthProvider() + + const [emailOpen, setEmailOpen] = useState(false) useEffect(() => { // console.log(params.redirect) @@ -36,6 +39,22 @@ const Login = ({ homePage = "/saved" }: LoginProps) => { } }, [isAuthenticated]) + const onGoogleLogin = async (data) => { + try { + const user = await login({ provider: 'google' }) + } catch (err) { + // setError("root.login", { message: err }) + } + } + + const onMicrosoftLogin = async (data) => { + try { + const user = await login({ provider: 'microsoft' }) + } catch (err) { + // setError("root.login", { message: err }) + } + } + return { > - - - SR Smith - - - setIsLogin(true)} - > - {t.login.login()} - - setIsLogin(false)} - > - {t.login.sign_up()} - + + + SR Smith - - {isLogin ? ( - - ) : ( - - )} + + {t.login.login()}: + + + {t.login.google_login()} + + + + {t.login.microsoft_login()} + + setEmailOpen(e => !e)}> + + {t.login.email_login()} + + + {/* + */} + + + + - + }; \ No newline at end of file