Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX - ajout de l'ID de l'agence dans la page agences de l'admin IF (et possibilité de copier) #2897

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions front/src/app/components/agency/CopyAgencyId.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Badge } from "@codegouvfr/react-dsfr/Badge";
import { Button } from "@codegouvfr/react-dsfr/Button";
import React from "react";
import { AgencyId } from "shared";
import { useCopyButton } from "src/app/hooks/useCopyButton";

export const CopyAgencyId = ({ agencyId }: { agencyId: AgencyId }) => {
const { copyButtonIsDisabled, copyButtonLabel, onCopyButtonClick } =
useCopyButton("Copier");

return (
<div>
Id de l'agence : <Badge severity="success">{agencyId}</Badge>{" "}
<Button
type="button"
disabled={copyButtonIsDisabled}
iconId={"fr-icon-clipboard-fill"}
onClick={() => onCopyButtonClick(agencyId)}
>
{copyButtonLabel}
</Button>
</div>
);
};
2 changes: 2 additions & 0 deletions front/src/app/components/agency/EditAgency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import { AgencyStatusBadge } from "src/app/components/agency/AgencyStatusBadge";
import { AgencyTag } from "src/app/components/agency/AgencyTag";
import { AgencyUsers } from "src/app/components/agency/AgencyUsers";
import { CopyAgencyId } from "src/app/components/agency/CopyAgencyId";
import { useAppSelector } from "src/app/hooks/reduxHooks";
import "src/assets/admin.css";
import { agencyAdminSelectors } from "src/core-logic/domain/admin/agenciesAdmin/agencyAdmin.selectors";
Expand All @@ -28,6 +29,7 @@ export const EditAgency = () => {
{/* //Todo remove this from agency tab to redirect on agency detail admin page when select an agency in autocomplete */}
{agency && (
<>
<CopyAgencyId agencyId={agency.id} />
<AgencyTag
refersToAgencyName={agency.refersToAgencyName}
className={fr.cx("fr-my-4w")}
Expand Down
24 changes: 5 additions & 19 deletions front/src/app/components/forms/agency/AgencyOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { fr } from "@codegouvfr/react-dsfr";
import { Badge } from "@codegouvfr/react-dsfr/Badge";
import { Button } from "@codegouvfr/react-dsfr/Button";
import React from "react";
import { AgencyDto } from "shared";

import { SubmitFeedbackNotification } from "src/app/components/SubmitFeedbackNotification";
import { AgencyStatusBadge } from "src/app/components/agency/AgencyStatusBadge";
import { agencyAdminSubmitMessageByKind } from "src/app/components/agency/AgencySubmitFeedback";
import { AgencyTag } from "src/app/components/agency/AgencyTag";
import { AgencyUsers } from "src/app/components/agency/AgencyUsers";
import { CopyAgencyId } from "src/app/components/agency/CopyAgencyId";
import { Feedback } from "src/app/components/feedback/Feedback";
import { EditAgencyForm } from "src/app/components/forms/agency/EditAgencyForm";

import { SubmitFeedbackNotification } from "src/app/components/SubmitFeedbackNotification";
import { useAppSelector } from "src/app/hooks/reduxHooks";
import { useCopyButton } from "src/app/hooks/useCopyButton";
import { routes } from "src/app/routes/routes";

import { agencyAdminSelectors } from "src/core-logic/domain/admin/agenciesAdmin/agencyAdmin.selectors";
Expand Down Expand Up @@ -40,23 +38,11 @@ export const AgencyOverview = ({
}: AgencyOverviewProps) => {
const feedback = useAppSelector(agencyAdminSelectors.feedback);

const { copyButtonIsDisabled, copyButtonLabel, onCopyButtonClick } =
useCopyButton("Copier");

return (
<div>
<h1 className={fr.cx("fr-h1")}>{agency.name}</h1>
<div>
Id de l'agence : <Badge severity="success">{agency.id}</Badge>{" "}
<Button
type="button"
disabled={copyButtonIsDisabled}
iconId={"fr-icon-clipboard-fill"}
onClick={() => onCopyButtonClick(agency.id)}
>
{copyButtonLabel}
</Button>
</div>
<CopyAgencyId agencyId={agency.id} />

{/* //Todo remove after feedback refactor */}
{routeName === "adminAgencies" || routeName === "adminAgencyDetail" ? (
<SubmitFeedbackNotification
Expand Down
Loading