Skip to content

Commit

Permalink
Merge pull request #32 from FlorianLeChat/dependabot/npm_and_yarn/dep…
Browse files Browse the repository at this point in the history
…endencies-bd9a6036d1

Bump the dependencies group with 41 updates
  • Loading branch information
github-actions[bot] authored Nov 3, 2024
2 parents ddc94a3 + eb8b049 commit 84da0f0
Show file tree
Hide file tree
Showing 59 changed files with 1,871 additions and 1,753 deletions.
2 changes: 1 addition & 1 deletion app/[locale]/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function updateReadState()

// On retourne enfin un message de succès si l'opération a réussi.
logger.debug(
{ source: __filename, count: notifications.count },
{ source: __dirname, count: notifications.count },
"Deleted all notifications"
);

Expand Down
14 changes: 7 additions & 7 deletions app/[locale]/authentication/actions/signin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function signInAccount(
// Si c'est le cas, on tente une authentification via le fournisseur
// d'authentification externe avant de rediriger l'utilisateur vers
// la page de son tableau de bord.
logger.info( { source: __filename, provider }, "Sign in with provider" );
logger.info( { source: __dirname, provider }, "Sign in with provider" );

await signIn( provider as string, {
redirectTo: "/dashboard"
Expand All @@ -56,7 +56,7 @@ export async function signInAccount(
{
// Si les données du formulaire sont invalides, on affiche le
// premier code d'erreur rencontré.
logger.error( { source: __filename, result }, "Invalid form data" );
logger.error( { source: __dirname, result }, "Invalid form data" );

return {
success: false,
Expand All @@ -77,7 +77,7 @@ export async function signInAccount(
} );

logger.info(
{ source: __filename, email: result.output.email },
{ source: __dirname, email: result.output.email },
"Sign in with email"
);

Expand All @@ -95,7 +95,7 @@ export async function signInAccount(
// les informations d'authentification fournies avant de rediriger
// l'utilisateur vers la page de son tableau de bord.
logger.info(
{ source: __filename, email: result.output.email },
{ source: __dirname, email: result.output.email },
"Sign in with credentials"
);

Expand All @@ -111,23 +111,23 @@ export async function signInAccount(
// d'authentification avant de relancer l'erreur.
if ( error instanceof AuthError )
{
logger.error( { source: __filename, error }, "Authentication error" );
logger.error( { source: __dirname, error }, "Authentication error" );

return {
success: false,
reason: messages( `authjs.errors.${ error.type }` )
};
}

logger.error( { source: __filename, error }, "Sign in error" );
logger.error( { source: __dirname, error }, "Sign in error" );

throw error;
}

// On retourne enfin un message d'erreur par défaut au l'utilisateur
// ne correspondant à aucun des cas précédents.
logger.error(
{ source: __filename, email: result.output.email },
{ source: __dirname, email: result.output.email },
"Sign in error"
);

Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/authentication/actions/signout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function signOutAccount()
{
// On tente de déconnecter l'utilisateur de son compte utilisateur
// avant de rediriger celui-ci vers la page d'accueil.
logger.debug( { source: __filename }, "Sign out" );
logger.debug( { source: __dirname }, "Sign out" );

await signOut( {
redirect: false
Expand Down
10 changes: 5 additions & 5 deletions app/[locale]/authentication/actions/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function signUpAccount(
{
// Si les données du formulaire sont invalides, on affiche le
// premier code d'erreur rencontré.
logger.error( { source: __filename, result }, "Invalid form data" );
logger.error( { source: __dirname, result }, "Invalid form data" );

return {
success: false,
Expand All @@ -60,7 +60,7 @@ export async function signUpAccount(
// Si c'est le cas, on indique à l'utilisateur que l'adresse
// électronique fournie est déjà utilisée.
logger.error(
{ source: __filename, email: result.output.email },
{ source: __dirname, email: result.output.email },
"Email already used"
);

Expand Down Expand Up @@ -90,7 +90,7 @@ export async function signUpAccount(
} );

logger.info(
{ source: __filename, email: result.output.email },
{ source: __dirname, email: result.output.email },
"Sign up with email"
);

Expand All @@ -100,7 +100,7 @@ export async function signUpAccount(
// semble ne pas renvoyer de réponse, on affiche un message
// d'erreur sur la page d'authentification.
logger.error(
{ source: __filename, email: result.output.email },
{ source: __dirname, email: result.output.email },
"Email validation request failed"
);

Expand All @@ -114,7 +114,7 @@ export async function signUpAccount(
// On retourne enfin un message de succès à l'utilisateur afin
// qu'il puisse valider son adresse électronique.
logger.info(
{ source: __filename, email: result.output.email },
{ source: __dirname, email: result.output.email },
"Email validation request sent"
);

Expand Down
37 changes: 14 additions & 23 deletions app/[locale]/authentication/components/oauth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import { toast } from "sonner";
import { Loader2 } from "lucide-react";
import { useForm } from "react-hook-form";
import serverAction from "@/utilities/recaptcha";
import { useFormState } from "react-dom";
import { useTranslations } from "next-intl";
import { valibotResolver } from "@hookform/resolvers/valibot";
import { useState, useEffect } from "react";
import { useEffect, useActionState, startTransition } from "react";

import { Button } from "../../components/ui/button";
import { signInAccount } from "../actions/signin";
Expand All @@ -22,8 +21,7 @@ export default function OAuthForm()
{
// Déclaration des variables d'état.
const messages = useTranslations( "form" );
const [ isLoading, setLoading ] = useState( false );
const [ signInState, signInAction ] = useFormState( signInAccount, {
const [ signInState, signInAction, isPending ] = useActionState( signInAccount, {
success: true,
reason: ""
} );
Expand All @@ -46,8 +44,6 @@ export default function OAuthForm()
{
// Si ce n'est pas le cas, quelque chose s'est mal passé au
// niveau du serveur.
setLoading( false );

toast.error( messages( "errors.auth_failed" ), {
description: messages( "errors.server_error" )
} );
Expand All @@ -64,9 +60,6 @@ export default function OAuthForm()
return;
}

// On informe après qu'une réponse a été reçue.
setLoading( false );

// On affiche enfin une notification avec la raison fournie
// avant de réinitialiser le formulaire en cas de succès.
if ( success )
Expand All @@ -92,21 +85,20 @@ export default function OAuthForm()
<form
action={( formData ) =>
{
serverAction( signInAction, formData );
startTransition( () =>
{
serverAction( signInAction, formData );
} );
}}
onSubmit={() => setLoading( true )}
>
<Button
name="provider"
value="google"
variant="outline"
disabled={
isLoading
|| process.env.NEXT_PUBLIC_AUTH_GOOGLE_ENABLED !== "true"
}
disabled={isPending || process.env.NEXT_PUBLIC_AUTH_GOOGLE_ENABLED !== "true"}
className="w-full"
>
{isLoading ? (
{isPending ? (
<Loader2 className="mr-2 size-4 animate-spin" />
) : (
<svg
Expand All @@ -131,21 +123,20 @@ export default function OAuthForm()
<form
action={( formData ) =>
{
serverAction( signInAction, formData );
startTransition( () =>
{
serverAction( signInAction, formData );
} );
}}
onSubmit={() => setLoading( true )}
>
<Button
name="provider"
value="github"
variant="outline"
disabled={
isLoading
|| process.env.NEXT_PUBLIC_AUTH_GITHUB_ENABLED !== "true"
}
disabled={isPending || process.env.NEXT_PUBLIC_AUTH_GITHUB_ENABLED !== "true"}
className="w-full"
>
{isLoading ? (
{isPending ? (
<Loader2 className="mr-2 size-4 animate-spin" />
) : (
<svg
Expand Down
27 changes: 10 additions & 17 deletions app/[locale]/authentication/components/signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import { toast } from "sonner";
import { merge } from "@/utilities/tailwind";
import { useForm } from "react-hook-form";
import serverAction from "@/utilities/recaptcha";
import { useFormState } from "react-dom";
import { useTranslations } from "next-intl";
import { valibotResolver } from "@hookform/resolvers/valibot";
import { useState, useEffect } from "react";
import { Eye, Mail, EyeOff, Loader2, KeyRound } from "lucide-react";
import { useState, useEffect, useActionState, startTransition } from "react";

import { Input } from "../../components/ui/input";
import { Form,
Expand All @@ -37,9 +36,8 @@ export default function SignInForm()
const messages = useTranslations( "form" );
const [ isLocked, setLocked ] = useState( false );
const [ isFocused, setFocused ] = useState( false );
const [ isLoading, setLoading ] = useState( false );
const [ inputType, setInputType ] = useState( "password" );
const [ signInState, signInAction ] = useFormState( signInAccount, {
const [ signInState, signInAction, isPending ] = useActionState( signInAccount, {
success: true,
reason: ""
} );
Expand All @@ -62,8 +60,6 @@ export default function SignInForm()
{
// Si ce n'est pas le cas, quelque chose s'est mal passé au
// niveau du serveur.
setLoading( false );

toast.error( messages( "errors.auth_failed" ), {
description: messages( "errors.server_error" )
} );
Expand All @@ -80,9 +76,6 @@ export default function SignInForm()
return;
}

// On informe après qu'une réponse a été reçue.
setLoading( false );

// On affiche enfin une notification avec la raison fournie
// avant de réinitialiser le formulaire en cas de succès.
if ( success )
Expand Down Expand Up @@ -115,11 +108,11 @@ export default function SignInForm()
return;
}

// Activation de l'état de chargement.
setLoading( true );

// Exécution de l'action côté serveur.
serverAction( signInAction, formData );
startTransition( () =>
{
serverAction( signInAction, formData );
} );
}}
className="space-y-6"
>
Expand All @@ -136,7 +129,7 @@ export default function SignInForm()
<FormControl>
<Input
{...field}
disabled={isLoading}
disabled={isPending}
maxLength={
schema.entries.email.pipe[ 2 ].requirement
}
Expand Down Expand Up @@ -180,7 +173,7 @@ export default function SignInForm()
)
)}
onFocus={() => setFocused( true )}
disabled={isLoading}
disabled={isPending}
className={`!mt-0 mr-2 inline-block w-[calc(100%-40px-0.5rem)] transition-opacity ${
!isFocused ? "opacity-50" : ""
}`}
Expand Down Expand Up @@ -248,8 +241,8 @@ export default function SignInForm()
)}

{/* Bouton de validation du formulaire */}
<Button disabled={isLoading}>
{isLoading ? (
<Button disabled={isPending}>
{isPending ? (
<>
<Loader2 className="mr-2 size-4 animate-spin" />
{messages( "loading" )}
Expand Down
25 changes: 9 additions & 16 deletions app/[locale]/authentication/components/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import schema from "@/schemas/authentication";
import { toast } from "sonner";
import { useForm } from "react-hook-form";
import serverAction from "@/utilities/recaptcha";
import { useFormState } from "react-dom";
import { Mail, Loader2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { valibotResolver } from "@hookform/resolvers/valibot";
import { useState, useEffect } from "react";
import { useEffect, useActionState, startTransition } from "react";

import { Input } from "../../components/ui/input";
import { Button } from "../../components/ui/button";
Expand All @@ -30,8 +29,7 @@ export default function SignUpForm()
{
// Déclaration des variables d'état.
const messages = useTranslations( "form" );
const [ isLoading, setLoading ] = useState( false );
const [ signUpState, signUpAction ] = useFormState( signUpAccount, {
const [ signUpState, signUpAction, isPending ] = useActionState( signUpAccount, {
success: true,
reason: ""
} );
Expand All @@ -54,8 +52,6 @@ export default function SignUpForm()
{
// Si ce n'est pas le cas, quelque chose s'est mal passé au
// niveau du serveur.
setLoading( false );

toast.error( messages( "errors.auth_failed" ), {
description: messages( "errors.server_error" )
} );
Expand All @@ -72,9 +68,6 @@ export default function SignUpForm()
return;
}

// On informe après qu'une réponse a été reçue.
setLoading( false );

// On affiche enfin une notification avec la raison fournie
// avant de réinitialiser le formulaire en cas de succès.
if ( success )
Expand Down Expand Up @@ -107,11 +100,11 @@ export default function SignUpForm()
return;
}

// Activation de l'état de chargement.
setLoading( true );

// Exécution de l'action côté serveur.
serverAction( signUpAction, formData );
startTransition( () =>
{
serverAction( signUpAction, formData );
} );
}}
className="space-y-6"
>
Expand All @@ -128,7 +121,7 @@ export default function SignUpForm()
<FormControl>
<Input
{...field}
disabled={isLoading}
disabled={isPending}
maxLength={
schema.entries.email.pipe[ 2 ].requirement
}
Expand All @@ -151,8 +144,8 @@ export default function SignUpForm()
/>

{/* Bouton de validation du formulaire */}
<Button disabled={isLoading}>
{isLoading ? (
<Button disabled={isPending}>
{isPending ? (
<>
<Loader2 className="mr-2 size-4 animate-spin" />
{messages( "loading" )}
Expand Down
Loading

0 comments on commit 84da0f0

Please sign in to comment.