-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds signup pages and completes login adds begining of a steppe…
…r compoenent
- Loading branch information
1 parent
2fff42b
commit 14e9ad3
Showing
30 changed files
with
1,112 additions
and
323 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
{ | ||
"login": "Anmelden" | ||
"form": { | ||
"email": { "label": "E-Mail", "placeholder": "Email eingeben" }, | ||
"password": { "label": "Passwort", "placeholder": "Passwort eingeben" } | ||
}, | ||
"noAccount": "Noch kein Konto? Registriere dich <signup>hier</signup>.", | ||
"title": "Anmelden", | ||
"validation": { | ||
"email": { | ||
"required": "E-Mail ist erforderlich", | ||
"invalid": "E-Mail ist ungültig" | ||
}, | ||
"password": { | ||
"required": "Passwort ist erforderlich" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"alreadyHaveAccount": "Bereits ein Konto? Melde dich <login>hier</login> an.", | ||
"form": { | ||
"name": { "label": "Name", "placeholder": "Name eingeben" }, | ||
"email": { "label": "E-Mail", "placeholder": "Email eingeben" }, | ||
"password": { "label": "Passwort", "placeholder": "Passwort eingeben" }, | ||
"confirmPassword": { "label": "Passwort bestätigen", "placeholder": "Passwort bestätigen" } | ||
}, | ||
"here": "hier", | ||
"passwordRequirements": { | ||
"lowerCase": "Mindestens ein Kleinbuchstabe", | ||
"upperCase": "Mindestens ein Grossbuchstaben", | ||
"number": "Mindestens eine Zahl", | ||
"special": "Mindestens ein Sonderzeichen", | ||
"minLength": "Mindestens 12 Zeichen" | ||
}, | ||
"title": "Registrieren", | ||
"validation": { | ||
"email": { | ||
"invalid": "Ungültige E-Mail-Adresse", | ||
"required": "E-Mail-Adresse ist erforderlich" | ||
}, | ||
"name": { | ||
"required": "Name ist erforderlich" | ||
}, | ||
"password": { | ||
"required": "Passwort ist erforderlich", | ||
"invalid": "Passwort entspricht nicht den Anforderungen" | ||
}, | ||
"confirmPassword": { | ||
"required": "Passwort bestätigen ist erforderlich", | ||
"match": "Passwörter stimmen nicht überein" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
{ | ||
"login": "Login" | ||
"form": { | ||
"email": { "label": "E-Mail", "placeholder": "Enter email" }, | ||
"password": { "label": "Password", "placeholder": "Enter password" } | ||
}, | ||
"noAccount": "Don't have an account yet? Register <signup>here</signup>.", | ||
"title": "Login", | ||
"validation": { | ||
"email": { | ||
"required": "Email is required", | ||
"invalid": "Email is invalid" | ||
}, | ||
"password": { | ||
"required": "Password is required" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"alreadyHaveAccount": "Already have an account? Login <login>here</login>.", | ||
"form": { | ||
"name": { "label": "Name", "placeholder": "Enter name" }, | ||
"email": { "label": "E-Mail", "placeholder": "Enter email" }, | ||
"password": { "label": "Password", "placeholder": "Enter password" }, | ||
"confirmPassword": { "label": "Confirm Password", "placeholder": "Confirm password" } | ||
}, | ||
"passwordRequirements": { | ||
"lowerCase": "At least one lowercase letter", | ||
"upperCase": "At least one uppercase letter", | ||
"number": "At least one number", | ||
"special": "At least one special character", | ||
"minLength": "At least 12 characters long" | ||
}, | ||
"title": "Sign Up", | ||
"validation": { | ||
"email": { | ||
"invalid": "Invalid email address", | ||
"required": "Email address is required" | ||
}, | ||
"name": { | ||
"required": "Name is required" | ||
}, | ||
"password": { | ||
"required": "Password is required", | ||
"invalid": "Password does not meet requirements" | ||
}, | ||
"confirmPassword": { | ||
"required": "Confirming password is required", | ||
"match": "Passwords do not match" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use server'; | ||
|
||
import { APIOperation } from '@/src/services/api-services/common'; | ||
import { makeRequest } from '@/src/services/api-services/request'; | ||
import { RequestResponse } from '@/src/types/request-response.type'; | ||
import { SignupResponse } from '@/src/types/response.types'; | ||
|
||
export const login = async (email?: string, password?: string): Promise<RequestResponse<SignupResponse>> => { | ||
const res = await makeRequest<APIOperation.LOGIN, SignupResponse>({ | ||
op: APIOperation.LOGIN, | ||
payload: { email, password }, | ||
}); | ||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Metadata } from 'next'; | ||
|
||
export const metadata: Metadata = { | ||
title: 'Login - EasyFlow', | ||
description: 'Login to EasyFlow', | ||
}; | ||
|
||
const RootLayout = ({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
params: { locale: string }; | ||
}>): JSX.Element => { | ||
return <main className="flex h-screen w-screen items-center justify-center">{children}</main>; | ||
}; | ||
|
||
export default RootLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { Metadata } from 'next'; | ||
|
||
export const metadata: Metadata = { | ||
title: 'Signup - EasyFlow', | ||
description: 'Signup for EasyFlow', | ||
}; | ||
|
||
const RootLayout = ({ | ||
children, | ||
}: Readonly<{ | ||
children: React.ReactNode; | ||
params: { locale: string }; | ||
}>): JSX.Element => { | ||
return <main className="flex h-screen w-screen items-center justify-center">{children}</main>; | ||
}; | ||
|
||
export default RootLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import SignupForm from '@/src/components/signup-form/SignupForm'; | ||
import TranslationsProvider from '@/src/components/translation-provider/TranslationsProvider'; | ||
import initTranslations from '@i18n'; | ||
import { FunctionComponent } from 'react'; | ||
|
||
interface HomeProps { | ||
params: { | ||
locale: string; | ||
}; | ||
} | ||
|
||
const i18nNamespaces = ['signup']; | ||
|
||
const Home: FunctionComponent<HomeProps> = async ({ params: { locale } }) => { | ||
const { t, resources } = await initTranslations(locale, i18nNamespaces); | ||
|
||
return ( | ||
<TranslationsProvider resources={resources} locale={locale} namespaces={i18nNamespaces}> | ||
<div> | ||
<h3>{t('signup:title')}</h3> | ||
<SignupForm /> | ||
</div> | ||
</TranslationsProvider> | ||
); | ||
}; | ||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
'use client'; | ||
import { login } from '@/src/app/[locale]/login/actions'; | ||
import { LoginType } from '@/src/types/login.type'; | ||
import { Button, Input, Link } from '@nextui-org/react'; | ||
import { Form, Formik } from 'formik'; | ||
import { FunctionComponent, ReactElement } from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
import PasswordInput from '../password-input/PasswordInput'; | ||
import createValidationSchema from './validation-schema'; | ||
|
||
const LoginForm: FunctionComponent = (): ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
const validationSchema = createValidationSchema(t); | ||
|
||
const initialValues: LoginType = { | ||
email: undefined, | ||
password: undefined, | ||
}; | ||
|
||
return ( | ||
<> | ||
<Formik | ||
initialValues={initialValues} | ||
validationSchema={validationSchema} | ||
onSubmit={async values => { | ||
const res = await login(values.email, values.password); | ||
if (!res.success) { | ||
console.log(res.errorCode); | ||
} else { | ||
console.log('Login success'); | ||
} | ||
}} | ||
> | ||
{({ setFieldTouched, setFieldValue, values, errors, touched, isSubmitting, submitCount, isValid }) => ( | ||
<Form> | ||
<Input | ||
className="mb-3" | ||
type="text" | ||
label={t('login:form.email.label')} | ||
placeholder={t('login:form.email.placeholder')} | ||
value={values.email} | ||
onChange={e => setFieldValue('email', e.target.value)} | ||
onBlur={() => setFieldTouched('email', true)} | ||
isInvalid={touched.email && !!errors.email} | ||
errorMessage={errors.email ? errors.email : undefined} | ||
isRequired | ||
/> | ||
<PasswordInput | ||
label={t('login:form.password.label')} | ||
value={values.password} | ||
placeholder={t('login:form.password.placeholder')} | ||
onChange={e => setFieldValue('password', e.target.value)} | ||
onBlur={() => setFieldTouched('password', true)} | ||
touched={!!touched.password} | ||
error={errors.password ? errors.password : undefined} | ||
/> | ||
<Button | ||
color="primary" | ||
type="submit" | ||
isLoading={isSubmitting} | ||
isDisabled={submitCount > 0 && !isValid} | ||
fullWidth | ||
> | ||
{t('login:title')} | ||
</Button> | ||
</Form> | ||
)} | ||
</Formik> | ||
|
||
<p className="mt-5 text-center text-content4-foreground"> | ||
<Trans | ||
i18nKey="login:noAccount" | ||
components={{ | ||
signup: <Link href="/signup" underline="hover" />, | ||
}} | ||
/> | ||
</p> | ||
</> | ||
); | ||
}; | ||
|
||
export default LoginForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TFunction } from 'i18next'; | ||
import { object, string } from 'yup'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
const createValidationSchema = (t: TFunction) => { | ||
return object().shape({ | ||
email: string().required(t('validation.email.required')).email(t('validation.email.invalid')), | ||
password: string().required(t('validation.password.required')), | ||
}); | ||
}; | ||
|
||
export default createValidationSchema; |
Oops, something went wrong.