Introduce prettier
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
import { useContext } from "react";
|
||||
import { Avatar, Card, CardHeader, CardBody, Divider } from "@nextui-org/react";
|
||||
import { TokenContext } from "../TokenProvider";
|
||||
'use client';
|
||||
import { useContext } from 'react';
|
||||
import { Avatar, Card, CardHeader, CardBody, Divider } from '@nextui-org/react';
|
||||
import { TokenContext } from '../TokenProvider';
|
||||
|
||||
type AccountPageMessages = {
|
||||
yourProjects: string;
|
||||
@@ -20,19 +20,10 @@ export default function AccountPage({ messages, locale }: Props) {
|
||||
{context.token && context.token.user && (
|
||||
<Card className="w-[600px] mt-16 mx-3">
|
||||
<CardHeader className="flex gap-6">
|
||||
<Avatar
|
||||
isBordered
|
||||
radius="full"
|
||||
className="w-16 h-16 text-large"
|
||||
src={context.token.user.avatarPath}
|
||||
/>
|
||||
<Avatar isBordered radius="full" className="w-16 h-16 text-large" src={context.token.user.avatarPath} />
|
||||
<div className="flex flex-col">
|
||||
<p className="text-2xl font-bold">
|
||||
{context.token.user.username}
|
||||
</p>
|
||||
<p className="text-lg text-default-500">
|
||||
{context.token.user.email}
|
||||
</p>
|
||||
<p className="text-2xl font-bold">{context.token.user.username}</p>
|
||||
<p className="text-lg text-default-500">{context.token.user.email}</p>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<Divider />
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
"use client";
|
||||
import React from "react";
|
||||
import { useState, useContext } from "react";
|
||||
import { Input, Button, Card, CardHeader, CardBody } from "@nextui-org/react";
|
||||
import { Link } from "@/src/navigation";
|
||||
import { ChevronRight, Eye, EyeOff } from "lucide-react";
|
||||
import { UserType, AuthMessages } from "@/types/user";
|
||||
import { roles } from "@/config/selection";
|
||||
import { signUp, signIn, getRandomAvatarPath } from "./authControl";
|
||||
import { isValidEmail, isValidPassword } from "./validate";
|
||||
import { TokenContext } from "../TokenProvider";
|
||||
import { useRouter } from "@/src/navigation";
|
||||
'use client';
|
||||
import React from 'react';
|
||||
import { useState, useContext } from 'react';
|
||||
import { Input, Button, Card, CardHeader, CardBody } from '@nextui-org/react';
|
||||
import { Link } from '@/src/navigation';
|
||||
import { ChevronRight, Eye, EyeOff } from 'lucide-react';
|
||||
import { UserType, AuthMessages } from '@/types/user';
|
||||
import { roles } from '@/config/selection';
|
||||
import { signUp, signIn, getRandomAvatarPath } from './authControl';
|
||||
import { isValidEmail, isValidPassword } from './validate';
|
||||
import { TokenContext } from '../TokenProvider';
|
||||
import { useRouter } from '@/src/navigation';
|
||||
|
||||
type Props = {
|
||||
isSignup: Boolean;
|
||||
@@ -22,18 +22,17 @@ export default function AuthPage({ isSignup, messages, locale }: Props) {
|
||||
const context = useContext(TokenContext);
|
||||
const [user, setUser] = useState<UserType>({
|
||||
id: null,
|
||||
email: "",
|
||||
password: "",
|
||||
username: "",
|
||||
role: roles.findIndex((entry) => entry.uid === "user"),
|
||||
avatarPath: "",
|
||||
email: '',
|
||||
password: '',
|
||||
username: '',
|
||||
role: roles.findIndex((entry) => entry.uid === 'user'),
|
||||
avatarPath: '',
|
||||
});
|
||||
const [confirmPassword, setConfirmPassword] = useState("");
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
const [confirmPassword, setConfirmPassword] = useState('');
|
||||
const [errorMessage, setErrorMessage] = useState('');
|
||||
|
||||
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
||||
const togglePasswordVisibility = () =>
|
||||
setIsPasswordVisible(!isPasswordVisible);
|
||||
const togglePasswordVisibility = () => setIsPasswordVisible(!isPasswordVisible);
|
||||
|
||||
const validate = async () => {
|
||||
if (!isValidEmail(user.email)) {
|
||||
@@ -83,31 +82,22 @@ export default function AuthPage({ isSignup, messages, locale }: Props) {
|
||||
|
||||
context.setToken(token);
|
||||
context.storeTokenToLocalStorage(token);
|
||||
router.push("/account", { locale: locale });
|
||||
router.push('/account', { locale: locale });
|
||||
};
|
||||
|
||||
return (
|
||||
<Card className="w-[480px] mt-16">
|
||||
<CardHeader className="px-4 pt-4 pb-0 flex justify-between">
|
||||
<h4 className="font-bold text-large">{messages.title}</h4>
|
||||
<Link
|
||||
href={isSignup ? "/account/signin" : "/account/signup"}
|
||||
locale={locale}
|
||||
>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="light"
|
||||
endContent={<ChevronRight size={16} />}
|
||||
>
|
||||
<Link href={isSignup ? '/account/signin' : '/account/signup'} locale={locale}>
|
||||
<Button color="primary" variant="light" endContent={<ChevronRight size={16} />}>
|
||||
{messages.linkTitle}
|
||||
</Button>
|
||||
</Link>
|
||||
</CardHeader>
|
||||
<CardBody className="overflow-visible px-4 pt-0 pb-4">
|
||||
<form>
|
||||
{errorMessage && (
|
||||
<div className="my-3 text-danger">{errorMessage}</div>
|
||||
)}
|
||||
{errorMessage && <div className="my-3 text-danger">{errorMessage}</div>}
|
||||
<Input
|
||||
isRequired
|
||||
type="email"
|
||||
@@ -139,15 +129,11 @@ export default function AuthPage({ isSignup, messages, locale }: Props) {
|
||||
<Input
|
||||
label={messages.password}
|
||||
variant="bordered"
|
||||
autoComplete={isSignup ? "new-password" : "current-password"}
|
||||
autoComplete={isSignup ? 'new-password' : 'current-password'}
|
||||
className="mt-3"
|
||||
type={isPasswordVisible ? "text" : "password"}
|
||||
type={isPasswordVisible ? 'text' : 'password'}
|
||||
endContent={
|
||||
<button
|
||||
className="focus:outline-none"
|
||||
type="button"
|
||||
onClick={togglePasswordVisibility}
|
||||
>
|
||||
<button className="focus:outline-none" type="button" onClick={togglePasswordVisibility}>
|
||||
{isPasswordVisible ? <Eye size={20} /> : <EyeOff size={20} />}
|
||||
</button>
|
||||
}
|
||||
@@ -164,13 +150,9 @@ export default function AuthPage({ isSignup, messages, locale }: Props) {
|
||||
variant="bordered"
|
||||
autoComplete="new-password"
|
||||
className="mt-3"
|
||||
type={isPasswordVisible ? "text" : "password"}
|
||||
type={isPasswordVisible ? 'text' : 'password'}
|
||||
endContent={
|
||||
<button
|
||||
className="focus:outline-none"
|
||||
type="button"
|
||||
onClick={togglePasswordVisibility}
|
||||
>
|
||||
<button className="focus:outline-none" type="button" onClick={togglePasswordVisibility}>
|
||||
{isPasswordVisible ? <Eye size={20} /> : <EyeOff size={20} />}
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
export default function AuthLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
export default function AuthLayout({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<>
|
||||
<div className="w-full flex items-center justify-center">{children}</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useTranslations } from "next-intl";
|
||||
import AccountPage from "./AccountPage";
|
||||
import { useTranslations } from 'next-intl';
|
||||
import AccountPage from './AccountPage';
|
||||
export default function Page(params: { locale: string }) {
|
||||
const t = useTranslations("Auth");
|
||||
const t = useTranslations('Auth');
|
||||
const messages = {
|
||||
yourProjects: t("your_projects"),
|
||||
yourProjects: t('your_projects'),
|
||||
};
|
||||
|
||||
return <AccountPage messages={messages} locale={params.locale} />;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import AuthPage from "../authPage";
|
||||
import { useTranslations } from "next-intl";
|
||||
import AuthPage from '../authPage';
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
export default function Page(params: { locale: string }) {
|
||||
const t = useTranslations("Auth");
|
||||
const t = useTranslations('Auth');
|
||||
const messages = {
|
||||
title: t("signin"),
|
||||
linkTitle: t("or_signup"),
|
||||
submitTitle: t("signin"),
|
||||
email: t("email"),
|
||||
username: t("username"),
|
||||
password: t("password"),
|
||||
confirmPassword: t("confirm_password"),
|
||||
invalidEmail: t("invalid_email"),
|
||||
invalidPassword: t("invalid_password"),
|
||||
usernameEmpty: t("username_empty"),
|
||||
passwordDoesNotMatch: t("password_not_match"),
|
||||
EmailAlreadyExist: t("email_already_exist"),
|
||||
emailNotExist: t("email_not_exist"),
|
||||
signupError: t("signup_error"),
|
||||
signinError: t("signin_error"),
|
||||
title: t('signin'),
|
||||
linkTitle: t('or_signup'),
|
||||
submitTitle: t('signin'),
|
||||
email: t('email'),
|
||||
username: t('username'),
|
||||
password: t('password'),
|
||||
confirmPassword: t('confirm_password'),
|
||||
invalidEmail: t('invalid_email'),
|
||||
invalidPassword: t('invalid_password'),
|
||||
usernameEmpty: t('username_empty'),
|
||||
passwordDoesNotMatch: t('password_not_match'),
|
||||
EmailAlreadyExist: t('email_already_exist'),
|
||||
emailNotExist: t('email_not_exist'),
|
||||
signupError: t('signup_error'),
|
||||
signinError: t('signin_error'),
|
||||
};
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import AuthPage from "../authPage";
|
||||
import { useTranslations } from "next-intl";
|
||||
import AuthPage from '../authPage';
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
export default function Page(params: { locale: string }) {
|
||||
const t = useTranslations("Auth");
|
||||
const t = useTranslations('Auth');
|
||||
const messages = {
|
||||
title: t("signup"),
|
||||
linkTitle: t("or_signin"),
|
||||
submitTitle: t("signup"),
|
||||
email: t("email"),
|
||||
username: t("username"),
|
||||
password: t("password"),
|
||||
confirmPassword: t("confirm_password"),
|
||||
invalidEmail: t("invalid_email"),
|
||||
invalidPassword: t("invalid_password"),
|
||||
usernameEmpty: t("username_empty"),
|
||||
passwordDoesNotMatch: t("password_not_match"),
|
||||
EmailAlreadyExist: t("email_already_exist"),
|
||||
emailNotExist: t("email_not_exist"),
|
||||
signupError: t("signup_error"),
|
||||
signinError: t("signin_error"),
|
||||
title: t('signup'),
|
||||
linkTitle: t('or_signin'),
|
||||
submitTitle: t('signup'),
|
||||
email: t('email'),
|
||||
username: t('username'),
|
||||
password: t('password'),
|
||||
confirmPassword: t('confirm_password'),
|
||||
invalidEmail: t('invalid_email'),
|
||||
invalidPassword: t('invalid_password'),
|
||||
usernameEmpty: t('username_empty'),
|
||||
passwordDoesNotMatch: t('password_not_match'),
|
||||
EmailAlreadyExist: t('email_already_exist'),
|
||||
emailNotExist: t('email_not_exist'),
|
||||
signupError: t('signup_error'),
|
||||
signinError: t('signin_error'),
|
||||
};
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user