Skip to content

Commit

Permalink
Supprime la propriété withPassword uniquement utilisée dans storybook…
Browse files Browse the repository at this point in the history
… qui apporte de la confusion
  • Loading branch information
cparthur committed Jan 20, 2025
1 parent 03f8a24 commit e3c9124
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 46 deletions.
36 changes: 14 additions & 22 deletions packages/auth/components/Login/Login.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {useState} from 'react';
import {Meta, StoryObj} from '@storybook/react';
import {action} from '@storybook/addon-actions';
import {Login} from './Login';
import {LoginView} from './type';
import { action } from '@storybook/addon-actions';
import { Meta, StoryObj } from '@storybook/react';
import { useState } from 'react';
import { Login } from './Login';
import { LoginView } from './type';

const meta: Meta<typeof Login> = {
component: Login,
Expand All @@ -14,9 +14,9 @@ const meta: Meta<typeof Login> = {
action('getPasswordStrength')(...args);
return null;
},
defaultValues: {email: '[email protected]', otp: ''},
defaultValues: { email: '[email protected]', otp: '' },
},
render: props => {
render: (props) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [view, setView] = useState<LoginView>(props.view || 'etape1');
const onSetView: typeof setView = (...args) => {
Expand All @@ -31,38 +31,30 @@ export default meta;

type Story = StoryObj<typeof Login>;

export const SansMotDePasse: Story = {
export const Default: Story = {
args: {},
};

export const MsgLienEnvoye: Story = {
args: {view: 'msg_lien_envoye'},
args: { view: 'msg_lien_envoye' },
};

export const AvecErreur: Story = {
args: {error: 'Une erreur est survenue...'},
};

export const AvecMotDePasse: Story = {
args: {withPassword: true},
};

export const AvecMotDePasseEtErreur: Story = {
args: {withPassword: true, error: 'Une erreur est survenue...'},
args: { error: 'Une erreur est survenue...' },
};

export const MotDePasseOublie: Story = {
args: {view: 'mdp_oublie'},
args: { view: 'mdp_oublie' },
};

export const MsgInitMdp: Story = {
args: {view: 'msg_init_mdp'},
args: { view: 'msg_init_mdp' },
};

export const Recover: Story = {
args: {view: 'recover'},
args: { view: 'recover' },
};

export const ReinitMotDePasse: Story = {
args: {view: 'reset_mdp'},
args: { view: 'reset_mdp' },
};
2 changes: 1 addition & 1 deletion packages/auth/components/Login/LoginTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const useLoginForm = (isPasswordless: boolean, email: string) => {
* (saisir un email et éventuellement un mot de passe)
*/
export const LoginTabs = (props: LoginPropsWithState) => {
const { formState: signupState, withPassword } = props;
const { formState: signupState } = props;
const { email } = signupState;
const [isPasswordless, setIsPasswordless] = useState(false);
const form = useLoginForm(isPasswordless, email);
Expand Down
2 changes: 0 additions & 2 deletions packages/auth/components/Login/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export type LoginProps = {
error: string | null;
/** Indique qu'un appel réseau est en cours */
isLoading?: boolean;
/** Indique que l'option "avec mot de passe" est activée */
withPassword?: boolean;
/** Fonction appelée à l'envoi du formulaire */
onSubmit: (formData: LoginData) => void;
/** Fonction appelée à l'annulation du formulaire */
Expand Down
29 changes: 11 additions & 18 deletions packages/auth/components/Signup/Signup.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {useState} from 'react';
import {Meta, StoryObj} from '@storybook/react';
import {action} from '@storybook/addon-actions';
import {Signup} from './Signup';
import {SignupView} from './type';
import { action } from '@storybook/addon-actions';
import { Meta, StoryObj } from '@storybook/react';
import { useState } from 'react';
import { Signup } from './Signup';
import { SignupView } from './type';

const meta: Meta<typeof Signup> = {
component: Signup,
Expand All @@ -11,8 +11,8 @@ const meta: Meta<typeof Signup> = {
email: '[email protected]',
},
collectivites: [
{value: 1270, label: 'Grenoble'},
{value: 5460, label: '#Collectivité Test'},
{ value: 1270, label: 'Grenoble' },
{ value: 5460, label: '#Collectivité Test' },
],
onSubmit: action('onSubmit'),
onCancel: action('onCancel'),
Expand All @@ -22,7 +22,7 @@ const meta: Meta<typeof Signup> = {
return null;
},
},
render: props => {
render: (props) => {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [view, setView] = useState<SignupView>(props.view || 'etape1');
const onSetView: typeof setView = (...args) => {
Expand All @@ -41,27 +41,20 @@ export const Default: Story = {
args: {},
};

export const Etape1AvecMdp: Story = {
args: {
view: 'etape1',
withPassword: true,
},
};

export const Etape2: Story = {
args: {
view: 'etape2',
},
};

export const Etape2Erreur: Story = {
args: {view: 'etape2', error: "Message d'erreur"},
args: { view: 'etape2', error: "Message d'erreur" },
};

export const Etape3: Story = {
args: {view: 'etape3'},
args: { view: 'etape3' },
};

export const Etape3Erreur: Story = {
args: {view: 'etape3', error: "Message d'erreur"},
args: { view: 'etape3', error: "Message d'erreur" },
};
2 changes: 1 addition & 1 deletion packages/auth/components/Signup/SignupStep1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const useSignupStep1 = (isPasswordless: boolean, email: string) => {
* (saisir un email et éventuellement un mot de passe)
*/
export const SignupStep1 = (props: SignupPropsWithState) => {
const { formState, withPassword } = props;
const { formState } = props;
const { email } = formState;
const [isPasswordless, setIsPasswordless] = useState(false);
const form = useSignupStep1(isPasswordless, email);
Expand Down
2 changes: 0 additions & 2 deletions packages/auth/components/Signup/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export type SignupProps = {
error: string | null;
/** Indique qu'un appel réseau est en cours */
isLoading?: boolean;
/** Indique que l'option "avec mot de passe" est activée */
withPassword?: boolean;
/** Liste de collectivités auxquelles le compte peut être rattaché */
collectivites: Array<{ value: number; label: string }>;
/** Appelé pour filtrer la liste des collectivités */
Expand Down

0 comments on commit e3c9124

Please sign in to comment.