Skip to content

Commit

Permalink
moved headerFooterDisplayItem in footer
Browse files Browse the repository at this point in the history
  • Loading branch information
enguerranws authored and JeromeBu committed Sep 20, 2024
1 parent 7d232a2 commit e2abaa7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ describe("Pg implementation of ConventionQueries", () => {
describe("PG implementation of method getConventionsByFilters", () => {
const agencyId = "bbbbbc15-9c0a-1aaa-aa6d-6aa9ad38aaff";
const agency = AgencyDtoBuilder.create().withId(agencyId).build();
const siret1 = "11110000111100";
const siret2 = "22220000222200";
const siret3 = "33330000333300";

const conventionCancelledAndDateStart20230327 = new ConventionDtoBuilder()
.withSiret(siret1)
.withId("bbbbbc15-9c0a-1aaa-aa6d-6aa9ad38aa01")
.withDateStart(new Date("2023-03-27").toISOString())
.withDateEnd(new Date("2023-03-28").toISOString())
Expand All @@ -346,6 +351,7 @@ describe("Pg implementation of ConventionQueries", () => {
.build();

const conventionDraftAndDateStart20230330 = new ConventionDtoBuilder()
.withSiret(siret3)
.withId("bbbbbc15-9c0a-1aaa-aa6d-6aa9ad38aa02")
.withDateSubmission(new Date("2023-03-05").toISOString())
.withDateStart(new Date("2023-03-30").toISOString())
Expand All @@ -356,6 +362,7 @@ describe("Pg implementation of ConventionQueries", () => {
.build();

const firstValidatedConvention = new ConventionDtoBuilder()
.withSiret(siret1)
.withId("bbbbbc15-9c0a-1aaa-aa6d-6aa9ad38aa03")
.withDateSubmission(new Date("2024-06-20").toISOString())
.withDateStart(new Date("2024-07-01").toISOString())
Expand All @@ -368,6 +375,7 @@ describe("Pg implementation of ConventionQueries", () => {
.build();

const secondValidatedConvention = new ConventionDtoBuilder()
.withSiret(siret2)
.withId("bbbbbc15-9c0a-1aaa-aa6d-6aa9ad38aa04")
.withDateSubmission(new Date("2024-06-21").toISOString())
.withDateStart(new Date("2024-07-02").toISOString())
Expand Down Expand Up @@ -523,6 +531,21 @@ describe("Pg implementation of ConventionQueries", () => {
firstValidatedConvention,
]);
});

it("getConventionsByFilters with some sirets", async () => {
const resultAll = await conventionQueries.getConventions({
filters: {
withSirets: [siret1, siret2],
},
sortBy: "dateStart",
});

expectToEqual(resultAll, [
secondValidatedConvention,
firstValidatedConvention,
conventionCancelledAndDateStart20230327,
]);
});
});

describe("findSimilarConventions", () => {
Expand Down
3 changes: 2 additions & 1 deletion back/src/domains/convention/adapters/PgConventionQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ConventionStatus,
DateRange,
FindSimilarConventionsParams,
SiretDto,
conventionReadSchema,
conventionSchema,
pipeWithValue,
Expand Down Expand Up @@ -279,7 +280,7 @@ const addFiltersToBuilder =

const addWithSiretsIfNeeded: AddToBuilder = (b) =>
withSirets && withSirets.length > 0
? b.where("conventions.siret", "in", withSirets)
? b.where("conventions.siret", "=", sql<SiretDto>`ANY(${withSirets})`)
: b;

return pipeWithValue(
Expand Down
8 changes: 7 additions & 1 deletion front/src/app/components/layout/LayoutFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { fr } from "@codegouvfr/react-dsfr";
import {
Display,
headerFooterDisplayItem,
} from "@codegouvfr/react-dsfr/Display";
import { useIsDark } from "@codegouvfr/react-dsfr/useIsDark";
import React from "react";
import {
Expand Down Expand Up @@ -139,7 +143,7 @@ const links: NavLink[] = [
target: "_blank",
},
];
const bottomsLinks: NavLink[] = [
const bottomsLinks: (NavLink | typeof headerFooterDisplayItem)[] = [
{
label: "Accessibilité : partiellement conforme",
...routes.standard({ pagePath: "accessibilite" }).link,
Expand Down Expand Up @@ -207,6 +211,7 @@ const bottomsLinks: NavLink[] = [
id: bottomsLinksIds.communicationKit,
target: "_blank",
},
headerFooterDisplayItem,
];

const navTopGroupLinks: NavTopGroupLinks[] = [
Expand Down Expand Up @@ -282,6 +287,7 @@ export const LayoutFooter = () => (
bottomLinks={bottomsLinks}
plateformeInclusionLogo={<PlateformeInclusionLogo />}
/>
<Display />
</>
);

Expand Down
6 changes: 0 additions & 6 deletions front/src/app/components/layout/LayoutHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { fr } from "@codegouvfr/react-dsfr";
import {
Display,
headerFooterDisplayItem,
} from "@codegouvfr/react-dsfr/Display";
import { Header, HeaderProps } from "@codegouvfr/react-dsfr/Header";
import { MainNavigationProps } from "@codegouvfr/react-dsfr/MainNavigation";
import { useIsDark } from "@codegouvfr/react-dsfr/useIsDark";
Expand Down Expand Up @@ -54,7 +50,6 @@ export const LayoutHeader = () => {
const isAdminConnected = useAppSelector(authSelectors.isAdminConnected);
const isPeConnected = useAppSelector(authSelectors.isPeConnected);
const tools: HeaderProps["quickAccessItems"] = [
headerFooterDisplayItem,
{
text: "Remplir la demande de convention",
iconId: "fr-icon-draft-line",
Expand Down Expand Up @@ -318,7 +313,6 @@ export const LayoutHeader = () => {
navigation={links}
quickAccessItems={tools}
/>
<Display />
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fr } from "@codegouvfr/react-dsfr";
import { FooterProps as FooterPropsDsfr } from "@codegouvfr/react-dsfr/Footer";
import React from "react";
import { useStyles } from "tss-react/dsfr";
import FooterStyles from "./Footer.styles";
Expand All @@ -24,7 +25,7 @@ export type NavTopGroupLinks = {
export type FooterProps = {
links?: NavLink[];
navTopGroupLinks?: NavTopGroupLinks[];
bottomLinks?: NavLink[];
bottomLinks?: (NavLink | FooterPropsDsfr.BottomItem.Button)[];
partnersLogos?: React.ReactNode;
plateformeInclusionLogo?: React.ReactNode;
};
Expand All @@ -47,13 +48,36 @@ const TopLink = ({ link }: { link: NavLink }) => {
);
};

const BottomLink = ({ link }: { link: NavLink }) => (
<li className={fr.cx("fr-footer__bottom-item")}>
<a className={fr.cx("fr-footer__bottom-link")} {...link}>
{link.label}
</a>
</li>
);
const BottomLink = ({
link,
}: { link: NavLink | FooterPropsDsfr.BottomItem }) => {
const { cx } = useStyles();
return (
<li className={fr.cx("fr-footer__bottom-item")}>
{"label" in link ? (
<a className={fr.cx("fr-footer__bottom-link")} {...link}>
{link.label}
</a>
) : (
<button
type="button"
className={cx(
fr.cx(
"fr-footer__bottom-link",
"fr-icon-theme-fill",
"fr-link--icon-left",
link.iconId,
),
link.buttonProps?.className,
)}
{...link.buttonProps}
>
{link.text}
</button>
)}
</li>
);
};

export const Footer = ({
links,
Expand Down

0 comments on commit e2abaa7

Please sign in to comment.