Skip to content

Commit

Permalink
feat: migrate login with email and password form
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisostome01 committed Jun 7, 2024
1 parent 373bcbb commit b157e9d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
3 changes: 0 additions & 3 deletions components/shared/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import IconButton from "../IconButton/IconButton"
import { ArrowLeft, Dots } from "../Icons/Icons"
import styles from "./Navigation.module.css"
import { useState } from "react"
import { useAuth } from "@/hooks/auth"
import { useApp } from "@/context/AppContext"
import { Popover } from "react-tiny-popover"
import Menu from "../Menu/Menu"
import { useNavigate } from "react-router-dom"

const Navigation = () => {
const { user, logout } = useAuth({ middleware: "auth" })
const { toggleMenu, menuOpen, closeMenu } = useApp()
const pathname = window.location.pathname
const navigate = useNavigate()
Expand Down
16 changes: 13 additions & 3 deletions views/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import AppLayout from "./app/layout"
import Login from "./auth/login/page"
import AuthLayout from "./auth/layout"
import NotFoundPage from "./not-found"
import LoginWithPassword from "./auth/login-with-password/page"

const App = () => {
return (
Expand Down Expand Up @@ -65,9 +66,18 @@ const App = () => {
}
/>

<Route path="*" element={
<NotFoundPage />
} />
<Route
path="/login-with-password"
element={
<RootLayout>
<AppLayout>
<LoginWithPassword />
</AppLayout>
</RootLayout>
}
/>

<Route path="*" element={<NotFoundPage />} />
{/* </RootLayout> */}
</Routes>
</BrowserRouter>
Expand Down
9 changes: 5 additions & 4 deletions views/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import Header from "@/components/shared/Header/Header"
const AppLayout = ({ children, header }: any) => {
const { user } = useAuth({ middleware: "auth" })

if (!user) {
return <Loading />
}
// TODO Loading progress should be handled deferently
// if (!user) {
// return <Loading />
// }

return (
<div className={styles.container}>
<Header>{header}</Header>
{header && <Header>{header}</Header>}
<main>{children}</main>
</div>
)
Expand Down
33 changes: 14 additions & 19 deletions views/auth/login-with-password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
"use client";

import { useAuth } from "../../../hooks/auth";
import { useEffect, useState } from "react";
import { useRouter } from "next/navigation";
import {useState } from "react";
import styles from "./LoginWithPassword.module.css";
import AuthSessionStatus from "../AuthSessionStatus";

import styles from "./LoginWithPassword.module.css";

import { Button, Link } from "@radix-ui/themes";
import AuthCard from "../AuthCard/AuthCard";
import InputField from "@/components/shared/InputField/InputField";
import { useAuth } from "@/hooks/auth";

const Login = () => {
const router = useRouter();

const LoginWithPassword = () => {
const { login } = useAuth({
middleware: "guest",
redirectIfAuthenticated: "/dashboard",
Expand All @@ -24,15 +19,15 @@ const Login = () => {
const [errors, setErrors] = useState<any>([]);
const [status, setStatus] = useState(null);

useEffect(() => {
// @ts-ignore
if (router.reset?.length > 0 && errors.length === 0) {
// @ts-ignore
setStatus(atob(router.reset));
} else {
setStatus(null);
}
});
// useEffect(() => {
// // @ts-ignore
// if (router.reset?.length > 0 && errors.length === 0) {
// // @ts-ignore
// setStatus(atob(router.reset));
// } else {
// setStatus(null);
// }
// });

const submitForm = async (event) => {
event.preventDefault();
Expand Down Expand Up @@ -94,4 +89,4 @@ const Login = () => {
);
};

export default Login;
export default LoginWithPassword;

0 comments on commit b157e9d

Please sign in to comment.