Skip to content

Commit

Permalink
ref #313 Pas d'affichage de la pagination si aucun résultat
Browse files Browse the repository at this point in the history
  • Loading branch information
pprev94 committed Apr 26, 2024
1 parent 88654a6 commit 255ef08
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 33 deletions.
36 changes: 21 additions & 15 deletions assets/espaceco/pages/communities/Communities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ const Communities: FC = () => {
{communityQuery.isLoading || communitiesAsMember.isLoading ? (
<Skeleton count={10} />
) : community ? (
<CommunityList communities={[community]} filter={filter} />
<CommunityList communities={[community]} />
) : filter === "public" ? (
communityQuery.data && (
communityQuery.data && communityQuery.data.content.length ? (
<div>
<CommunityList communities={communityQuery.data.content} filter={filter} />
<CommunityList communities={communityQuery.data.content} />
<div className={fr.cx("fr-grid-row", "fr-grid-row--center")}>
<Pagination
count={communityQuery.data.totalPages}
Expand All @@ -128,20 +128,26 @@ const Communities: FC = () => {
/>
</div>
</div>
)
) : (
communitiesAsMember.data && (
<div>
<CommunityList communities={communitiesAsMember.data.content} filter={filter} />
<div className={fr.cx("fr-grid-row", "fr-grid-row--center")}>
<Pagination
count={communitiesAsMember.data.totalPages}
defaultPage={queryParams.page}
getPageLinkProps={(pageNumber) => routes.espaceco_community_list({ filter: filter, page: pageNumber }).link}
/>
</div>
) : (
<div className={fr.cx("fr-my-2v")}>
<Alert severity={"info"} title={t("no_result", { filter: filter })} closable />
</div>
)
) : communitiesAsMember.data && communitiesAsMember.data.content.length ? (
<div>
<CommunityList communities={communitiesAsMember.data.content} />
<div className={fr.cx("fr-grid-row", "fr-grid-row--center")}>
<Pagination
count={communitiesAsMember.data.totalPages}
defaultPage={queryParams.page}
getPageLinkProps={(pageNumber) => routes.espaceco_community_list({ filter: filter, page: pageNumber }).link}
/>
</div>
</div>
) : (
<div className={fr.cx("fr-my-2v")}>
<Alert severity={"info"} title={t("no_result", { filter: filter })} closable />
</div>
)}
</div>
</div>
Expand Down
23 changes: 5 additions & 18 deletions assets/espaceco/pages/communities/CommunityList.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
import { fr } from "@codegouvfr/react-dsfr";
import Alert from "@codegouvfr/react-dsfr/Alert";
import { FC } from "react";
import { CommunityResponseDTO } from "../../../@types/espaceco";
import CommunityListItem from "./CommunityListItem";
import { CommunityListFilter } from "../../../@types/app_espaceco";
import { useTranslation } from "../../../i18n/i18n";

type CommunityListProps = {
communities: CommunityResponseDTO[];
filter: CommunityListFilter;
};

const CommunityList: FC<CommunityListProps> = ({ communities, filter }) => {
const { t } = useTranslation("EspaceCoCommunities");

const CommunityList: FC<CommunityListProps> = ({ communities }) => {
return (
<div>
{communities.length === 0 ? (
<div className={fr.cx("fr-my-2v")}>
<Alert severity={"info"} title={t("no_result", { filter: filter })} closable />
</div>
) : (
communities.map((community, index) => {
const className = index % 2 === 0 ? "frx-community-even" : "";
return <CommunityListItem key={community.id} className={className} community={community} />;
})
)}
{communities.map((community, index) => {
const className = index % 2 === 0 ? "frx-community-even" : "";
return <CommunityListItem key={community.id} className={className} community={community} />;
})}
</div>
);
};
Expand Down

0 comments on commit 255ef08

Please sign in to comment.