ENCOA-100: Changed the login/register photo
This commit is contained in:
BIN
public/orange-stock-photo.jpg
Normal file
BIN
public/orange-stock-photo.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.0 MiB |
BIN
public/red-stock-photo.jpg
Normal file
BIN
public/red-stock-photo.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 MiB |
@@ -1,29 +1,27 @@
|
|||||||
/* eslint-disable @next/next/no-img-element */
|
/* eslint-disable @next/next/no-img-element */
|
||||||
import { User } from "@/interfaces/user";
|
import {User} from "@/interfaces/user";
|
||||||
import { toast, ToastContainer } from "react-toastify";
|
import {toast, ToastContainer} from "react-toastify";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { FormEvent, useEffect, useState } from "react";
|
import {FormEvent, useEffect, useState} from "react";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import useUser from "@/hooks/useUser";
|
import useUser from "@/hooks/useUser";
|
||||||
import { Divider } from "primereact/divider";
|
import {Divider} from "primereact/divider";
|
||||||
import Button from "@/components/Low/Button";
|
import Button from "@/components/Low/Button";
|
||||||
import { BsArrowRepeat, BsCheck } from "react-icons/bs";
|
import {BsArrowRepeat, BsCheck} from "react-icons/bs";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import Input from "@/components/Low/Input";
|
import Input from "@/components/Low/Input";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { useRouter } from "next/router";
|
import {useRouter} from "next/router";
|
||||||
import EmailVerification from "./(auth)/EmailVerification";
|
import EmailVerification from "./(auth)/EmailVerification";
|
||||||
import { withIronSessionSsr } from "iron-session/next";
|
import {withIronSessionSsr} from "iron-session/next";
|
||||||
import { sessionOptions } from "@/lib/session";
|
import {sessionOptions} from "@/lib/session";
|
||||||
|
|
||||||
const EMAIL_REGEX = new RegExp(
|
const EMAIL_REGEX = new RegExp(/^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$/g);
|
||||||
/^[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*@[a-zA-Z0-9]+(?:\.[a-zA-Z0-9]+)*$/g,
|
|
||||||
);
|
|
||||||
|
|
||||||
export const getServerSideProps = withIronSessionSsr(({ req, res }) => {
|
export const getServerSideProps = withIronSessionSsr(({req, res}) => {
|
||||||
const user = req.session.user;
|
const user = req.session.user;
|
||||||
|
|
||||||
const envVariables: { [key: string]: string } = {};
|
const envVariables: {[key: string]: string} = {};
|
||||||
Object.keys(process.env)
|
Object.keys(process.env)
|
||||||
.filter((x) => x.startsWith("NEXT_PUBLIC"))
|
.filter((x) => x.startsWith("NEXT_PUBLIC"))
|
||||||
.forEach((x: string) => {
|
.forEach((x: string) => {
|
||||||
@@ -35,12 +33,12 @@ export const getServerSideProps = withIronSessionSsr(({ req, res }) => {
|
|||||||
redirect: {
|
redirect: {
|
||||||
destination: "/",
|
destination: "/",
|
||||||
permanent: false,
|
permanent: false,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: { user: null, envVariables },
|
props: {user: null, envVariables},
|
||||||
};
|
};
|
||||||
}, sessionOptions);
|
}, sessionOptions);
|
||||||
|
|
||||||
@@ -52,7 +50,7 @@ export default function Login() {
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const { user, mutateUser } = useUser({
|
const {user, mutateUser} = useUser({
|
||||||
redirectTo: "/",
|
redirectTo: "/",
|
||||||
redirectIfFound: true,
|
redirectIfFound: true,
|
||||||
});
|
});
|
||||||
@@ -70,13 +68,10 @@ export default function Login() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.post<{ ok: boolean }>("/api/reset", { email })
|
.post<{ok: boolean}>("/api/reset", {email})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (response.data.ok) {
|
if (response.data.ok) {
|
||||||
toast.success(
|
toast.success("You should receive an e-mail to reset your password!", {toastId: "forgot-success"});
|
||||||
"You should receive an e-mail to reset your password!",
|
|
||||||
{ toastId: "forgot-success" },
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +91,7 @@ export default function Login() {
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
axios
|
axios
|
||||||
.post<User>("/api/login", { email, password })
|
.post<User>("/api/login", {email, password})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
toast.success("You have been logged in!", {
|
toast.success("You have been logged in!", {
|
||||||
toastId: "login-successful",
|
toastId: "login-successful",
|
||||||
@@ -109,7 +104,7 @@ export default function Login() {
|
|||||||
toastId: "wrong-credentials",
|
toastId: "wrong-credentials",
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.error("Something went wrong!", { toastId: "server-error" });
|
toast.error("Something went wrong!", {toastId: "server-error"});
|
||||||
}
|
}
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
})
|
})
|
||||||
@@ -127,82 +122,45 @@ export default function Login() {
|
|||||||
<main className="flex h-[100vh] w-full bg-white text-black">
|
<main className="flex h-[100vh] w-full bg-white text-black">
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
<section className="relative hidden h-full w-fit min-w-fit lg:flex">
|
<section className="relative hidden h-full w-fit min-w-fit lg:flex">
|
||||||
<div className="bg-mti-rose-light absolute z-10 h-full w-full bg-opacity-50" />
|
{/* <div className="bg-mti-rose-light absolute z-10 h-full w-full bg-opacity-50" /> */}
|
||||||
<img
|
<img src="/red-stock-photo.jpg" alt="People smiling looking at a tablet" className="aspect-auto h-full" />
|
||||||
src="/people-talking-tablet.png"
|
|
||||||
alt="People smiling looking at a tablet"
|
|
||||||
className="aspect-auto h-full"
|
|
||||||
/>
|
|
||||||
</section>
|
</section>
|
||||||
<section className="flex h-full w-full flex-col items-center justify-center gap-2">
|
<section className="flex h-full w-full flex-col items-center justify-center gap-2">
|
||||||
<div className={clsx("flex flex-col items-center", !user && "mb-4")}>
|
<div className={clsx("flex flex-col items-center", !user && "mb-4")}>
|
||||||
<img
|
<img src="/logo_title.png" alt="EnCoach's Logo" className="w-36 lg:w-56" />
|
||||||
src="/logo_title.png"
|
<h1 className="text-2xl font-bold lg:text-4xl">Login to your account</h1>
|
||||||
alt="EnCoach's Logo"
|
<p className="text-mti-gray-cool self-start text-sm font-normal lg:text-base">with your registered Email Address</p>
|
||||||
className="w-36 lg:w-56"
|
|
||||||
/>
|
|
||||||
<h1 className="text-2xl font-bold lg:text-4xl">
|
|
||||||
Login to your account
|
|
||||||
</h1>
|
|
||||||
<p className="text-mti-gray-cool self-start text-sm font-normal lg:text-base">
|
|
||||||
with your registered Email Address
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<Divider className="max-w-xs lg:max-w-md" />
|
<Divider className="max-w-xs lg:max-w-md" />
|
||||||
{!user && (
|
{!user && (
|
||||||
<>
|
<>
|
||||||
<form
|
<form className="-lg:px-8 flex w-full flex-col items-center gap-6 lg:w-1/2" onSubmit={login}>
|
||||||
className="-lg:px-8 flex w-full flex-col items-center gap-6 lg:w-1/2"
|
<Input type="email" name="email" onChange={(e) => setEmail(e.toLowerCase())} placeholder="Enter email address" />
|
||||||
onSubmit={login}
|
<Input type="password" name="password" onChange={(e) => setPassword(e)} placeholder="Password" />
|
||||||
>
|
|
||||||
<Input
|
|
||||||
type="email"
|
|
||||||
name="email"
|
|
||||||
onChange={(e) => setEmail(e.toLowerCase())}
|
|
||||||
placeholder="Enter email address"
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
type="password"
|
|
||||||
name="password"
|
|
||||||
onChange={(e) => setPassword(e)}
|
|
||||||
placeholder="Password"
|
|
||||||
/>
|
|
||||||
<div className="flex w-full justify-between px-4">
|
<div className="flex w-full justify-between px-4">
|
||||||
<div
|
<div
|
||||||
className="text-mti-gray-dim flex cursor-pointer gap-3 text-xs"
|
className="text-mti-gray-dim flex cursor-pointer gap-3 text-xs"
|
||||||
onClick={() => setRememberPassword((prev) => !prev)}
|
onClick={() => setRememberPassword((prev) => !prev)}>
|
||||||
>
|
|
||||||
<input type="checkbox" className="hidden" />
|
<input type="checkbox" className="hidden" />
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"border-mti-purple-light flex h-4 w-4 items-center justify-center rounded-sm border bg-white",
|
"border-mti-purple-light flex h-4 w-4 items-center justify-center rounded-sm border bg-white",
|
||||||
"transition duration-300 ease-in-out",
|
"transition duration-300 ease-in-out",
|
||||||
rememberPassword && "!bg-mti-purple-light ",
|
rememberPassword && "!bg-mti-purple-light ",
|
||||||
)}
|
)}>
|
||||||
>
|
|
||||||
<BsCheck color="white" className="h-full w-full" />
|
<BsCheck color="white" className="h-full w-full" />
|
||||||
</div>
|
</div>
|
||||||
<span>Remember my password</span>
|
<span>Remember my password</span>
|
||||||
</div>
|
</div>
|
||||||
<span
|
<span className="text-mti-purple-light cursor-pointer text-xs hover:underline" onClick={forgotPassword}>
|
||||||
className="text-mti-purple-light cursor-pointer text-xs hover:underline"
|
|
||||||
onClick={forgotPassword}
|
|
||||||
>
|
|
||||||
Forgot Password?
|
Forgot Password?
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button className="mt-8 w-full" color="purple" disabled={isLoading}>
|
||||||
className="mt-8 w-full"
|
|
||||||
color="purple"
|
|
||||||
disabled={isLoading}
|
|
||||||
>
|
|
||||||
{!isLoading && "Login"}
|
{!isLoading && "Login"}
|
||||||
{isLoading && (
|
{isLoading && (
|
||||||
<div className="flex items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
<BsArrowRepeat
|
<BsArrowRepeat className="animate-spin text-white" size={25} />
|
||||||
className="animate-spin text-white"
|
|
||||||
size={25}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -215,13 +173,7 @@ export default function Login() {
|
|||||||
</span>
|
</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{user && !user.isVerified && (
|
{user && !user.isVerified && <EmailVerification user={user} isLoading={isLoading} setIsLoading={setIsLoading} />}
|
||||||
<EmailVerification
|
|
||||||
user={user}
|
|
||||||
isLoading={isLoading}
|
|
||||||
setIsLoading={setIsLoading}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ export default function Register({code: queryCode}: {code: string}) {
|
|||||||
<main className="w-full h-[100vh] flex bg-white text-black">
|
<main className="w-full h-[100vh] flex bg-white text-black">
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
<section className="h-full w-fit min-w-fit relative hidden lg:flex">
|
<section className="h-full w-fit min-w-fit relative hidden lg:flex">
|
||||||
<div className="absolute h-full w-full bg-mti-rose-light z-10 bg-opacity-50" />
|
<img src="/red-stock-photo.jpg" alt="People smiling looking at a tablet" className="aspect-auto h-full" />
|
||||||
<img src="/people-talking-tablet.png" alt="People smiling looking at a tablet" className="h-full aspect-auto" />
|
|
||||||
</section>
|
</section>
|
||||||
<section className="h-full w-full flex flex-col items-center justify-center gap-4">
|
<section className="h-full w-full flex flex-col items-center justify-center gap-4">
|
||||||
<div className={clsx("flex flex-col items-center", !user && "mb-4")}>
|
<div className={clsx("flex flex-col items-center", !user && "mb-4")}>
|
||||||
|
|||||||
Reference in New Issue
Block a user