Skip to content

Commit

Permalink
Merge pull request #998 from betagouv/tech_clean_loader
Browse files Browse the repository at this point in the history
Remplacement composant LoadingBouton et Loader anciens par nouveaux
  • Loading branch information
martinratinaud authored Feb 5, 2025
2 parents 6562336 + ca584a2 commit 7c70481
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 124 deletions.
13 changes: 4 additions & 9 deletions src/components/EligibilityForm/components/ContactForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Button } from '@codegouvfr/react-dsfr/Button';
import { Form, Formik } from 'formik';
import { useRouter } from 'next/router';
import { type ReactNode, useRef } from 'react';
import * as Yup from 'yup';

import Loader from '@/components/Loader';
import Button from '@/components/ui/Button';
import { AnalyticsFormId } from '@/services/analytics';
import { type ContactFormInfos } from '@/types/Summary/Demand';

Expand Down Expand Up @@ -53,13 +52,9 @@ export const ContactForm = ({ onSubmit, isLoading, cardMode, city, heatingTypeIn
<ContactInformation cardMode={cardMode} city={city} heatingTypeInput={heatingTypeInput} />
<ContactConsent />
<ContactFormFooter>
{isLoading ? (
<Loader color="#4550e5" show />
) : (
<Button type="submit" disabled={isLoading}>
Envoyer
</Button>
)}
<Button type="submit" loading={isLoading}>
Envoyer
</Button>
{formik.isSubmitting && !formik.isValid && (
<p className="fr-error-text">Veuillez remplir les champs obligatoires(*) avant d'envoyer votre demande</p>
)}
Expand Down
57 changes: 0 additions & 57 deletions src/components/Loader/Loader.style.tsx

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/Loader/Loader.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/Loader/index.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/ui/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Button: React.FC<ButtonProps> = ({
full,
href,
type = 'button',
disabled,
onClick: onExternalClick,
stopPropagation,
loading,
Expand All @@ -51,7 +52,7 @@ const Button: React.FC<ButtonProps> = ({
e.stopPropagation();
}

if (props.disabled) {
if (disabled) {
return;
}

Expand All @@ -64,6 +65,7 @@ const Button: React.FC<ButtonProps> = ({
iconId={loading ? 'ri-loader-3-line' : (iconId as any) /** FIXME */}
$full={full}
$loading={loading}
disabled={(disabled || loading) as any /** FIXME cause incompatibility with DSFR Button */}
type={type as any /** FIXME cause incompatibility with DSFR Button */}
{...props}
>
Expand Down
42 changes: 0 additions & 42 deletions src/components/ui/LoadingButton.tsx

This file was deleted.

9 changes: 4 additions & 5 deletions src/pages/reseaux/modifier.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Alert } from '@codegouvfr/react-dsfr/Alert';
import { Button } from '@codegouvfr/react-dsfr/Button';
import { RadioButtons } from '@codegouvfr/react-dsfr/RadioButtons';
import Link from 'next/link';
import { useRouter } from 'next/router';
Expand All @@ -10,9 +9,9 @@ import Input from '@/components/form/dsfr/Input';
import NetworkSearchInput from '@/components/Network/NetworkSearchInput';
import SimplePage from '@/components/shared/page/SimplePage';
import Box from '@/components/ui/Box';
import Button from '@/components/ui/Button';
import Heading from '@/components/ui/Heading';
import Icon from '@/components/ui/Icon';
import LoadingButton from '@/components/ui/LoadingButton';
import Text from '@/components/ui/Text';
import { type ModificationReseau } from '@/pages/api/modification-reseau';
import { type NetworkSearchResult } from '@/pages/api/networks/search';
Expand Down Expand Up @@ -366,7 +365,7 @@ function ModifierReseauxPage() {
aria-hidden
/>
<div className="fr-grid-row fr-grid-row--top">
<Button type="button" onClick={() => fileUploadInputRef.current!.click()} priority="secondary">
<Button onClick={() => fileUploadInputRef.current!.click()} priority="secondary">
Choisir un fichier
</Button>
<Box ml="2w">
Expand Down Expand Up @@ -405,9 +404,9 @@ function ModifierReseauxPage() {
)}
<Text mt="6w">Les informations transmises seront validées manuellement par France Chaleur Urbaine avant mise en ligne.</Text>

<LoadingButton className="fr-mt-2w" submit isLoading={isSubmitting} disabled={fichiersError !== null}>
<Button className="fr-mt-2w" type="submit" loading={isSubmitting} disabled={fichiersError !== null}>
Soumettre la demande de modification
</LoadingButton>
</Button>

{apiError && (
<Text color="error" mt="2w">
Expand Down

0 comments on commit 7c70481

Please sign in to comment.