chore: better Prettier config for easier reviews

This commit is contained in:
2023-10-23 23:33:39 +02:00
parent a8781724d4
commit 71ea41695f
209 changed files with 4093 additions and 4114 deletions

View File

@ -1,26 +1,26 @@
import type { NextPage } from 'next'
import Link from 'next/link'
import useTranslation from 'next-translate/useTranslation'
import axios from 'axios'
import { useForm } from 'react-component-form'
import type { HandleUseFormCallback } from 'react-component-form'
import type { NextPage } from "next"
import Link from "next/link"
import useTranslation from "next-translate/useTranslation"
import axios from "axios"
import { useForm } from "react-component-form"
import type { HandleUseFormCallback } from "react-component-form"
import { AuthenticationForm } from '../../components/Authentication'
import { Head } from '../../components/Head'
import { Header } from '../../components/Header'
import { Main } from '../../components/design/Main'
import type { FooterProps } from '../../components/Footer'
import { Footer } from '../../components/Footer'
import { Input } from '../../components/design/Input'
import { Button } from '../../components/design/Button'
import { FormState } from '../../components/design/FormState'
import { authenticationFromServerSide } from '../../tools/authentication'
import { userSchema } from '../../models/User'
import { api } from '../../tools/api'
import { useFormTranslation } from '../../hooks/useFormTranslation'
import { AuthenticationForm } from "../../components/Authentication"
import { Head } from "../../components/Head"
import { Header } from "../../components/Header"
import { Main } from "../../components/design/Main"
import type { FooterProps } from "../../components/Footer"
import { Footer } from "../../components/Footer"
import { Input } from "../../components/design/Input"
import { Button } from "../../components/design/Button"
import { FormState } from "../../components/design/FormState"
import { authenticationFromServerSide } from "../../tools/authentication"
import { userSchema } from "../../models/User"
import { api } from "../../tools/api"
import { useFormTranslation } from "../../hooks/useFormTranslation"
const schema = {
email: userSchema.email
email: userSchema.email,
}
const ForgotPassword: NextPage<FooterProps> = (props) => {
@ -32,50 +32,50 @@ const ForgotPassword: NextPage<FooterProps> = (props) => {
const onSubmit: HandleUseFormCallback<typeof schema> = async (
formData,
formElement
formElement,
) => {
try {
await api.post(
`/users/reset-password?redirectURI=${window.location.origin}/authentication/reset-password`,
formData
formData,
)
formElement.reset()
return {
type: 'success',
message: 'authentication:success-forgot-password'
type: "success",
message: "authentication:success-forgot-password",
}
} catch (error) {
if (axios.isAxiosError(error) && error.response?.status === 400) {
return {
type: 'error',
message: 'errors:invalid-email'
type: "error",
message: "errors:invalid-email",
}
}
return {
type: 'error',
message: 'errors:server-error'
type: "error",
message: "errors:server-error",
}
}
}
return (
<>
<Head title={`Thream | ${t('authentication:forgot-password')}`} />
<Head title={`Thream | ${t("authentication:forgot-password")}`} />
<Header />
<Main>
<AuthenticationForm onSubmit={handleUseForm(onSubmit)}>
<Input type='email' placeholder='Email' name='email' label='Email' />
<Button data-cy='submit' className='mt-6 w-full' type='submit'>
{t('authentication:submit')}
<Input type="email" placeholder="Email" name="email" label="Email" />
<Button data-cy="submit" className="mt-6 w-full" type="submit">
{t("authentication:submit")}
</Button>
<p className='mt-3 font-headline text-sm text-green-800 hover:underline dark:text-green-400'>
<Link href='/authentication/signin'>
{t('authentication:already-know-password')}
<p className="mt-3 font-headline text-sm text-green-800 hover:underline dark:text-green-400">
<Link href="/authentication/signin">
{t("authentication:already-know-password")}
</Link>
</p>
</AuthenticationForm>
<FormState
id='message'
id="message"
state={fetchState}
message={
message != null
@ -92,10 +92,10 @@ const ForgotPassword: NextPage<FooterProps> = (props) => {
export const getServerSideProps = authenticationFromServerSide({
shouldBeAuthenticated: false,
fetchData: async () => {
const { readPackage } = await import('read-pkg')
const { readPackage } = await import("read-pkg")
const { version } = await readPackage()
return { version }
}
},
})
export default ForgotPassword

View File

@ -1,26 +1,26 @@
import type { NextPage } from 'next'
import { useRouter } from 'next/router'
import useTranslation from 'next-translate/useTranslation'
import axios from 'axios'
import { useForm } from 'react-component-form'
import type { HandleUseFormCallback } from 'react-component-form'
import type { NextPage } from "next"
import { useRouter } from "next/router"
import useTranslation from "next-translate/useTranslation"
import axios from "axios"
import { useForm } from "react-component-form"
import type { HandleUseFormCallback } from "react-component-form"
import { Head } from '../../components/Head'
import { Header } from '../../components/Header'
import { FormState } from '../../components/design/FormState'
import { Main } from '../../components/design/Main'
import type { FooterProps } from '../../components/Footer'
import { Footer } from '../../components/Footer'
import { Input } from '../../components/design/Input'
import { Button } from '../../components/design/Button'
import { authenticationFromServerSide } from '../../tools/authentication'
import { AuthenticationForm } from '../../components/Authentication'
import { api } from '../../tools/api'
import { userSchema } from '../../models/User'
import { useFormTranslation } from '../../hooks/useFormTranslation'
import { Head } from "../../components/Head"
import { Header } from "../../components/Header"
import { FormState } from "../../components/design/FormState"
import { Main } from "../../components/design/Main"
import type { FooterProps } from "../../components/Footer"
import { Footer } from "../../components/Footer"
import { Input } from "../../components/design/Input"
import { Button } from "../../components/design/Button"
import { authenticationFromServerSide } from "../../tools/authentication"
import { AuthenticationForm } from "../../components/Authentication"
import { api } from "../../tools/api"
import { userSchema } from "../../models/User"
import { useFormTranslation } from "../../hooks/useFormTranslation"
const schema = {
password: userSchema.password
password: userSchema.password,
}
const ResetPassword: NextPage<FooterProps> = (props) => {
@ -35,42 +35,42 @@ const ResetPassword: NextPage<FooterProps> = (props) => {
try {
await api.put(`/users/reset-password`, {
...formData,
temporaryToken: router.query['temporaryToken']
temporaryToken: router.query["temporaryToken"],
})
await router.push('/authentication/signin')
await router.push("/authentication/signin")
return null
} catch (error) {
if (axios.isAxiosError(error) && error.response?.status === 400) {
return {
type: 'error',
message: 'errors:invalid'
type: "error",
message: "errors:invalid",
}
}
return {
type: 'error',
message: 'errors:server-error'
type: "error",
message: "errors:server-error",
}
}
}
return (
<>
<Head title={`Thream | ${t('authentication:reset-password')}`} />
<Head title={`Thream | ${t("authentication:reset-password")}`} />
<Header />
<Main>
<AuthenticationForm onSubmit={handleUseForm(onSubmit)}>
<Input
type='password'
placeholder='Password'
name='password'
label='Password'
type="password"
placeholder="Password"
name="password"
label="Password"
/>
<Button data-cy='submit' className='mt-6 w-full' type='submit'>
{t('authentication:submit')}
<Button data-cy="submit" className="mt-6 w-full" type="submit">
{t("authentication:submit")}
</Button>
</AuthenticationForm>
<FormState
id='message'
id="message"
state={fetchState}
message={
message != null
@ -87,10 +87,10 @@ const ResetPassword: NextPage<FooterProps> = (props) => {
export const getServerSideProps = authenticationFromServerSide({
shouldBeAuthenticated: false,
fetchData: async () => {
const { readPackage } = await import('read-pkg')
const { readPackage } = await import("read-pkg")
const { version } = await readPackage()
return { version }
}
},
})
export default ResetPassword

View File

@ -1,12 +1,12 @@
import type { NextPage } from 'next'
import useTranslation from 'next-translate/useTranslation'
import type { NextPage } from "next"
import useTranslation from "next-translate/useTranslation"
import { Head } from '../../components/Head'
import { Authentication } from '../../components/Authentication'
import { Header } from '../../components/Header'
import type { FooterProps } from '../../components/Footer'
import { Footer } from '../../components/Footer'
import { authenticationFromServerSide } from '../../tools/authentication'
import { Head } from "../../components/Head"
import { Authentication } from "../../components/Authentication"
import { Header } from "../../components/Header"
import type { FooterProps } from "../../components/Footer"
import { Footer } from "../../components/Footer"
import { authenticationFromServerSide } from "../../tools/authentication"
const Signin: NextPage<FooterProps> = (props) => {
const { version } = props
@ -14,9 +14,9 @@ const Signin: NextPage<FooterProps> = (props) => {
return (
<>
<Head title={`Thream | ${t('authentication:signin')}`} />
<Head title={`Thream | ${t("authentication:signin")}`} />
<Header />
<Authentication mode='signin' />
<Authentication mode="signin" />
<Footer version={version} />
</>
)
@ -25,10 +25,10 @@ const Signin: NextPage<FooterProps> = (props) => {
export const getServerSideProps = authenticationFromServerSide({
shouldBeAuthenticated: false,
fetchData: async () => {
const { readPackage } = await import('read-pkg')
const { readPackage } = await import("read-pkg")
const { version } = await readPackage()
return { version }
}
},
})
export default Signin

View File

@ -1,12 +1,12 @@
import type { NextPage } from 'next'
import useTranslation from 'next-translate/useTranslation'
import type { NextPage } from "next"
import useTranslation from "next-translate/useTranslation"
import { Head } from '../../components/Head'
import { Authentication } from '../../components/Authentication'
import { Header } from '../../components/Header'
import type { FooterProps } from '../../components/Footer'
import { Footer } from '../../components/Footer'
import { authenticationFromServerSide } from '../../tools/authentication'
import { Head } from "../../components/Head"
import { Authentication } from "../../components/Authentication"
import { Header } from "../../components/Header"
import type { FooterProps } from "../../components/Footer"
import { Footer } from "../../components/Footer"
import { authenticationFromServerSide } from "../../tools/authentication"
const Signup: NextPage<FooterProps> = (props) => {
const { version } = props
@ -14,9 +14,9 @@ const Signup: NextPage<FooterProps> = (props) => {
return (
<>
<Head title={`Thream | ${t('authentication:signup')}`} />
<Head title={`Thream | ${t("authentication:signup")}`} />
<Header />
<Authentication mode='signup' />
<Authentication mode="signup" />
<Footer version={version} />
</>
)
@ -25,10 +25,10 @@ const Signup: NextPage<FooterProps> = (props) => {
export const getServerSideProps = authenticationFromServerSide({
shouldBeAuthenticated: false,
fetchData: async () => {
const { readPackage } = await import('read-pkg')
const { readPackage } = await import("read-pkg")
const { version } = await readPackage()
return { version }
}
},
})
export default Signup