Skip to content

Commit

Permalink
Remove duplicate component CompanySelectorWrapper (#3791)
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitguigal authored Nov 28, 2024
2 parents 30549fb + ba6e683 commit fdd6c71
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 320 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { removeEmptyKeys } from "../../../../../../common/helper";
import WorkSiteAddress from "../../../../../../form/common/components/work-site/WorkSiteAddress";
import RhfCompanyContactInfo from "../../../../../Forms/Components/RhfCompanyContactInfo/RhfCompanyContactInfo";
import { Loader } from "../../../../../common/Components";
import RhfCompanySelectorWrapper from "../../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";
import RhfOperationModeSelect from "../../../../../common/Components/OperationModeSelect/RhfOperationModeSelect";
import { CREATE_BSDA_REVISION_REQUEST } from "../../../../../common/queries/reviews/BsdaReviewQuery";
import { BsdTypename } from "../../../../../common/types/bsdTypes";
Expand Down Expand Up @@ -371,7 +371,7 @@ export function BsdaRequestRevision({ bsda }: Props) {
}
defaultValue={initialBsdaReview.broker}
>
<RhfCompanySelectorWrapper
<CompanySelectorWrapper
orgId={siret}
favoriteType={FavoriteType.Broker}
onCompanySelected={onCompanyBrokerSeleted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { z } from "zod";
import WasteCodeSelector from "../../../../../common/Components/WasteCodeSelector/WasteCodeSelector";
import { getPackagingInfosSummary } from "../../../../../common/utils/packagingsBsddSummary";
import RhfCompanyContactInfo from "../../../../../Forms/Components/RhfCompanyContactInfo/RhfCompanyContactInfo";
import RhfCompanySelectorWrapper from "../../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";
import RhfOperationModeSelect from "../../../../../common/Components/OperationModeSelect/RhfOperationModeSelect";
import { BsdTypename } from "../../../../../common/types/bsdTypes";
import RhfReviewableField from "../../common/Components/ReviewableField/RhfReviewableField";
Expand Down Expand Up @@ -459,7 +459,7 @@ export function BsddRequestRevision({ bsdd }: Props) {
}
defaultValue={initialBsddReview.broker}
>
<RhfCompanySelectorWrapper
<CompanySelectorWrapper
orgId={siret}
favoriteType={FavoriteType.Broker}
onCompanySelected={onCompanyBrokerSeleted}
Expand Down Expand Up @@ -501,7 +501,7 @@ export function BsddRequestRevision({ bsdd }: Props) {
}
defaultValue={initialBsddReview.trader}
>
<RhfCompanySelectorWrapper
<CompanySelectorWrapper
orgId={siret}
favoriteType={FavoriteType.Trader}
onCompanySelected={onCompanyTraderSeleted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
WasteProcessorType
} from "@td/codegen-ui";
import { useFormContext, useWatch } from "react-hook-form";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";
import { useParams } from "react-router-dom";
import CompanyContactInfo from "../../../../Forms/Components/RhfCompanyContactInfo/RhfCompanyContactInfo";
import { SealedFieldsContext } from "../../../../Dashboard/Creation/context";
Expand Down
2 changes: 1 addition & 1 deletion front/src/Apps/Dashboard/Creation/bspaoh/steps/Emitter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useMemo, useEffect, useContext } from "react";
import { Input } from "@codegouvfr/react-dsfr/Input";

import { useFormContext } from "react-hook-form";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";

import { FavoriteType } from "@td/codegen-ui";
import { useParams } from "react-router-dom";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import RecepisseExemption from "../../../../Forms/Components/RecepisseExemption/
import CompanyContactInfo from "../../../../Forms/Components/RhfCompanyContactInfo/RhfCompanyContactInfo";
import { RhfTagsInputWrapper } from "../../../../Forms/Components/TagsInput/TagsInputWrapper";
import TransporterRecepisse from "../../../../Forms/Components/TransporterRecepisse/TransporterRecepisse";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";
import { SealedFieldsContext } from "../../context";
import { clearCompanyError, setFieldError } from "../../utils";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, { useEffect, useMemo, useState, useContext } from "react";
import { useFormContext } from "react-hook-form";
import { useParams } from "react-router-dom";
import CompanyContactInfo from "../../../../Forms/Components/RhfCompanyContactInfo/RhfCompanyContactInfo";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";
import Alert from "@codegouvfr/react-dsfr/Alert";
import { SealedFieldsContext } from "../../../../Dashboard/Creation/context";
import DisabledParagraphStep from "../../DisabledParagraphStep";
Expand Down
2 changes: 1 addition & 1 deletion front/src/Apps/Dashboard/Creation/bsvhu/steps/Emitter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Input } from "@codegouvfr/react-dsfr/Input";
import React, { useEffect, useMemo, useContext } from "react";

import { useFormContext } from "react-hook-form";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";

import { CompanySearchResult, FavoriteType } from "@td/codegen-ui";
import { useParams } from "react-router-dom";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useFormContext } from "react-hook-form";
import { useParams } from "react-router-dom";
import RecepisseExemption from "../../../../Forms/Components/RecepisseExemption/RecepiceExemption";
import CompanyContactInfo from "../../../../Forms/Components/RhfCompanyContactInfo/RhfCompanyContactInfo";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/RhfCompanySelectorWrapper";
import CompanySelectorWrapper from "../../../../common/Components/CompanySelectorWrapper/CompanySelectorWrapper";
import DisabledParagraphStep from "../../DisabledParagraphStep";
import { SealedFieldsContext } from "../../../../Dashboard/Creation/context";
import { clearCompanyError, setFieldError } from "../../utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

import { useLazyQuery, ApolloError } from "@apollo/client";
import React, { useCallback, useEffect, useState } from "react";
import CompanySelector from "../../../../Apps/common/Components/CompanySelector/CompanySelector";
import CompanySelector from "../CompanySelector/CompanySelector";
import {
CompanySearchResult,
FavoriteType,
Query,
QueryFavoritesArgs,
QuerySearchCompaniesArgs
} from "@td/codegen-ui";
import { NotificationError } from "../../../../Apps/common/Components/Error/Error";
import {
FAVORITES,
SEARCH_COMPANIES
} from "../../../../Apps/common/queries/company/query";
import { NotificationError } from "../Error/Error";
import { FAVORITES, SEARCH_COMPANIES } from "../../queries/company/query";

interface CompanySelectorWrapperProps {
// Expose le state depuis le composant parent
Expand Down Expand Up @@ -43,10 +40,10 @@ interface CompanySelectorWrapperProps {
* - Il implémente le search et gère les erreurs.
* - Il initialise l'établissement sélectionné à partir des données du store (Formik).
* - Il propage l'événement de sélection d'un établissement au parent pour modifier.
* les données du store (Formik)
* les données du store (Formik ou RHF)
*/

export default function RhfCompanySelectorWrapper({
export default function CompanySelectorWrapper({
selectedCompanyOrgId,
favoriteType = FavoriteType.Emitter,
allowForeignCompanies = false,
Expand Down Expand Up @@ -92,7 +89,7 @@ export default function RhfCompanySelectorWrapper({
const onSelectCompany = useCallback(
(company: CompanySearchResult) => {
setSelectedCompany(company);
// propage l'événement au parent pour modifier les données du store (Formik)
// propage l'événement au parent pour modifier les données du store (Formik ou RHF)
onCompanySelected && onCompanySelected(company);
},
[setSelectedCompany, onCompanySelected]
Expand Down

This file was deleted.

Loading

0 comments on commit fdd6c71

Please sign in to comment.