Skip to content

Commit

Permalink
feat(admin-react):complete agency info summary card and fix bug on ba…
Browse files Browse the repository at this point in the history
…ck navigation from form
  • Loading branch information
pierreavizou committed Sep 5, 2024
1 parent 5ddb88a commit dad5693
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { EnhancedSectionCard } from "@/components/card/enhanced-section-card/Enh
import { useAgencySettings } from "@/app/(aap)/agencies-settings-v3/_components/agencies-settings-summary/agencySettings.hook";
import { AgencySettingsSummarySectionRemote } from "@/app/(aap)/agencies-settings-v3/_components/AgencySettingsSummarySectionRemote";
import Button from "@codegouvfr/react-dsfr/Button";
import Badge from "@codegouvfr/react-dsfr/Badge";

export const AgencySettingsSummary = () => {
const { organism, account } = useAgencySettings();

if (!account || !organism) return null;

return (
<>
<p className="text-xl">
Expand All @@ -24,9 +27,35 @@ export const AgencySettingsSummary = () => {
buttonOnClickHref="/agencies-settings-v3/on-site"
titleIconClass="fr-icon-home-4-fill"
>
<p className="md:w-4/5">
Ici le lieu d'accueil et son statut de visibilité
</p>
<div className="flex items-center justify-between pt-4 pb-3 border-neutral-300 border-t last:border-b">
<span className="font-bold">
{organism.label}{" "}
<Badge
small
className="ml-2"
severity={
organism.isVisibleInCandidateSearchResults
? "success"
: "error"
}
>
{organism.isVisibleInCandidateSearchResults
? "Visible"
: "Invisible"}
</Badge>
</span>
<span>
<Button
priority="tertiary no outline"
size="small"
linkProps={{
href: `/agencies-settings-v3/organisms/${organism.id}/on-site`,
}}
>
Modifier
</Button>
</span>
</div>
</EnhancedSectionCard>
)}
<EnhancedSectionCard
Expand All @@ -43,8 +72,7 @@ export const AgencySettingsSummary = () => {
<span className="font-bold">
{account?.firstname} {account?.lastname}
</span>{" "}
- {account?.email}
</span>{" "}
</span>
<span>
<Button
priority="tertiary no outline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const AgencySettingsInfoQuery = graphql(`
account_getAccountForConnectedUser {
organism {
id
label
isOnSite
isRemote
isVisibleInCandidateSearchResults
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ const getOrganismQuery = graphql(`
telephone
siteInternet
emailContact
adresseNumeroEtNomDeRue
conformeNormesAccessbilite
adresseInformationsComplementaires
adresseCodePostal
adresseVille
}
remoteZones
managedDegrees {
id
degree {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@
import { EnhancedSectionCard } from "@/components/card/enhanced-section-card/EnhancedSectionCard";
import Accordion from "@codegouvfr/react-dsfr/Accordion";
import { Breadcrumb } from "@codegouvfr/react-dsfr/Breadcrumb";
import { Highlight } from "@codegouvfr/react-dsfr/Highlight";
import Tag from "@codegouvfr/react-dsfr/Tag";
import Link from "next/link";
import { getRemoteZoneLabel } from "../../../_components/getRemoteZoneLabel";
import { OrganismVisibilityToggle } from "../_components/organism-visibility-toggle/OrganismVisibilityToggle";
import { useOnSiteOrganism } from "./_components/onSiteOrganism.hook";

export default function RemotePage() {
const { organism, organismId, organismName } = useOnSiteOrganism();

if (!organism) return null;

const isDomainAndLevelsComplete =
organism?.managedDegrees?.[0] &&
(organism?.domaines?.[0] || organism?.conventionCollectives?.[0]);
organism.managedDegrees?.[0] &&
(organism.domaines?.[0] || organism.conventionCollectives?.[0]);

if (!organism) return null;

const isAgencyInformationComplete =
organism.informationsCommerciales?.nom &&
organism.informationsCommerciales?.adresseNumeroEtNomDeRue &&
organism.informationsCommerciales?.adresseVille &&
organism.informationsCommerciales?.adresseCodePostal;
organism.informationsCommerciales?.telephone &&
organism.informationsCommerciales?.emailContact;

return (
<div className="flex flex-col w-full">
Expand All @@ -41,30 +50,49 @@ export default function RemotePage() {
title="Informations affichées aux candidats"
titleIconClass="fr-icon-information-fill"
isEditable
status={isAgencyInformationComplete ? "COMPLETED" : "TO_COMPLETE"}
buttonOnClickHref={`/agencies-settings-v3/organisms/${organismId}/on-site/information`}
>
<div className="flex flex-col gap-2">
<div className="font-bold">
{organism?.informationsCommerciales?.nom}
{organism.informationsCommerciales?.nom}
</div>
<div>
{organism?.informationsCommerciales?.telephone}{" "}
{organism?.informationsCommerciales?.emailContact}
{organism.informationsCommerciales?.adresseNumeroEtNomDeRue}{" "}
{organism.informationsCommerciales?.adresseCodePostal}{" "}
{organism.informationsCommerciales?.adresseVille}
<br />
{organism.informationsCommerciales
?.adresseInformationsComplementaires && (
<>
{
organism.informationsCommerciales
?.adresseInformationsComplementaires
}{" "}
<br />
</>
)}
{organism.informationsCommerciales?.telephone}{" "}
{organism.informationsCommerciales?.emailContact}
</div>
{organism?.informationsCommerciales?.siteInternet && (
{organism.informationsCommerciales?.siteInternet && (
<Link
className="fr-link mr-auto"
target="_blank"
href={organism?.informationsCommerciales?.siteInternet}
href={organism.informationsCommerciales?.siteInternet}
>
Site internet
</Link>
)}
<ul className="list-none pl-0">
{organism?.remoteZones.map((r) => (
<li key={r}>{getRemoteZoneLabel(r)}</li>
))}
</ul>
{organism.informationsCommerciales?.conformeNormesAccessbilite && (
<Highlight
classes={{
content: "mb-0",
}}
>
Accessible PMR
</Highlight>
)}
</div>
</EnhancedSectionCard>
<EnhancedSectionCard
Expand All @@ -74,28 +102,28 @@ export default function RemotePage() {
buttonOnClickHref={`/agencies-settings-v3/organisms/${organismId}/on-site/domaines-ccns-degrees`}
status={isDomainAndLevelsComplete ? "COMPLETED" : "TO_COMPLETE"}
>
{organism?.domaines?.[0] && (
{organism.domaines?.[0] && (
<Accordion label="Filières">
<div className="flex flex-wrap gap-2">
{organism?.domaines?.map((d) => (
{organism.domaines?.map((d) => (
<Tag key={d.id}>{d.label}</Tag>
))}
</div>
</Accordion>
)}
{organism?.conventionCollectives?.[0] && (
{organism.conventionCollectives?.[0] && (
<Accordion label="Branches">
<div className="flex flex-wrap gap-2">
{organism?.conventionCollectives?.map((ccn) => (
{organism.conventionCollectives?.map((ccn) => (
<Tag key={ccn.id}>{ccn.label}</Tag>
))}
</div>
</Accordion>
)}
{organism?.managedDegrees?.[0] && (
{organism.managedDegrees?.[0] && (
<Accordion label="Niveaux">
<div className="flex flex-wrap gap-2">
{organism?.managedDegrees?.map((d) => (
{organism.managedDegrees?.map((d) => (
<Tag key={d.id}>{d.degree.label}</Tag>
))}
</div>
Expand Down

0 comments on commit dad5693

Please sign in to comment.