Skip to content

Commit

Permalink
feat(ui): rename to filterButton
Browse files Browse the repository at this point in the history
feat(ui): rename
  • Loading branch information
sbenfares committed Nov 22, 2023
1 parent cb415c7 commit 3e2cb5d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Badge, Button, HStack, Stack, Text } from "@chakra-ui/react";
import { Dispatch, SetStateAction } from "react";

interface OrganismesFilterButtonProps {
interface FilterButtonProps {
isOpen: boolean;
setIsOpen: Dispatch<SetStateAction<boolean>>;
buttonLabel: string;
badge?: number;
}

export function OrganismesFilterButton(props: OrganismesFilterButtonProps) {
export function FilterButton(props: FilterButtonProps) {
const hasFilters = props.badge !== undefined && props.badge > 0;
return (
<Button
Expand Down
4 changes: 2 additions & 2 deletions ui/modules/admin/users/filters/FiltreUsersType.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Checkbox, CheckboxGroup, Stack } from "@chakra-ui/react";
import { useState } from "react";

import { TYPES_ORGANISATION } from "@/common/internal/Organisation";
import { FilterButton } from "@/components/FilterButton/FilterButton";
import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";
import { OrganismesFilterButton } from "@/modules/organismes/filters/OrganismesFilterButton";

interface FiltreUsersTypesProps {
value: string[];
Expand All @@ -16,7 +16,7 @@ function FiltreUserTypes(props: FiltreUsersTypesProps) {

return (
<div>
<OrganismesFilterButton
<FilterButton
isOpen={isOpen}
setIsOpen={setIsOpen}
buttonLabel="Type d'utilisateur"
Expand Down
9 changes: 2 additions & 7 deletions ui/modules/organismes/filters/FiltreOrganismeDepartements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DEPARTEMENTS_SORTED } from "shared";
import useAuth from "@/hooks/useAuth";
import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";

import { OrganismesFilterButton } from "./OrganismesFilterButton";
import { FilterButton } from "../../../components/FilterButton/FilterButton";

interface FiltreOrganismeDepartementsProps {
value: string[];
Expand Down Expand Up @@ -35,12 +35,7 @@ function FiltreOrganismeDepartements(props: FiltreOrganismeDepartementsProps) {

return (
<div>
<OrganismesFilterButton
isOpen={isOpen}
setIsOpen={setIsOpen}
buttonLabel="Département"
badge={departements?.length}
/>
<FilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="Département" badge={departements?.length} />
{isOpen && (
<SimpleOverlayMenu onClose={() => setIsOpen(false)} width="auto" p="3w">
<CheckboxGroup
Expand Down
4 changes: 2 additions & 2 deletions ui/modules/organismes/filters/FiltreOrganismeEtat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react";

import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";

import { OrganismesFilterButton } from "./OrganismesFilterButton";
import { FilterButton } from "../../../components/FilterButton/FilterButton";

interface FiltreOrganismesEtatProps {
value: boolean[];
Expand All @@ -16,7 +16,7 @@ function FiltreOrganismesEtat(props: FiltreOrganismesEtatProps) {

return (
<div>
<OrganismesFilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="État" badge={etats?.length} />
<FilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="État" badge={etats?.length} />
{isOpen && (
<SimpleOverlayMenu onClose={() => setIsOpen(false)} width="auto" p="3w">
<CheckboxGroup
Expand Down
4 changes: 2 additions & 2 deletions ui/modules/organismes/filters/FiltreOrganismeNature.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react";

import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";

import { OrganismesFilterButton } from "./OrganismesFilterButton";
import { FilterButton } from "../../../components/FilterButton/FilterButton";

interface FiltreOrganismesNatureProps {
value: string[];
Expand All @@ -16,7 +16,7 @@ function FiltreOrganismesNature(props: FiltreOrganismesNatureProps) {

return (
<div>
<OrganismesFilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="Nature" badge={natures?.length} />
<FilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="Nature" badge={natures?.length} />
{isOpen && (
<SimpleOverlayMenu onClose={() => setIsOpen(false)} width="auto" p="3w">
<CheckboxGroup value={props.value} onChange={(value) => props.onChange(value.map((v: string) => v))}>
Expand Down
4 changes: 2 additions & 2 deletions ui/modules/organismes/filters/FiltreOrganismeRegions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { REGIONS_SORTED } from "shared";

import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";

import { OrganismesFilterButton } from "./OrganismesFilterButton";
import { FilterButton } from "../../../components/FilterButton/FilterButton";

interface FiltreOrganismeRegionsProps {
value: string[];
Expand All @@ -17,7 +17,7 @@ function FiltreOrganismeRegions(props: FiltreOrganismeRegionsProps) {

return (
<div>
<OrganismesFilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="Région" badge={regions?.length} />
<FilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="Région" badge={regions?.length} />
{isOpen && (
<SimpleOverlayMenu onClose={() => setIsOpen(false)} width="auto" p="3w">
<CheckboxGroup
Expand Down
9 changes: 2 additions & 7 deletions ui/modules/organismes/filters/FiltreOrganismeTransmission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react";

import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";

import { OrganismesFilterButton } from "./OrganismesFilterButton";
import { FilterButton } from "../../../components/FilterButton/FilterButton";

interface FiltreOrganismeTransmissionProps {
fieldName: string;
Expand All @@ -17,12 +17,7 @@ function FiltreOrganismeTransmission(props: FiltreOrganismeTransmissionProps) {

return (
<div>
<OrganismesFilterButton
isOpen={isOpen}
setIsOpen={setIsOpen}
buttonLabel="Transmission"
badge={transmissions?.length}
/>
<FilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="Transmission" badge={transmissions?.length} />
{isOpen && (
<SimpleOverlayMenu onClose={() => setIsOpen(false)} width="auto" p="3w">
<CheckboxGroup
Expand Down
4 changes: 2 additions & 2 deletions ui/modules/organismes/filters/FiltreOrganismeUai.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react";

import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";

import { OrganismesFilterButton } from "./OrganismesFilterButton";
import { FilterButton } from "../../../components/FilterButton/FilterButton";

interface FiltreOrganismeUaiProps {
value: boolean[];
Expand All @@ -16,7 +16,7 @@ function FiltreOrganismeUai(props: FiltreOrganismeUaiProps) {

return (
<div>
<OrganismesFilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="UAI" badge={etatUAI?.length} />
<FilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel="UAI" badge={etatUAI?.length} />
{isOpen && (
<SimpleOverlayMenu onClose={() => setIsOpen(false)} width="auto" p="3w">
<CheckboxGroup
Expand Down
9 changes: 2 additions & 7 deletions ui/modules/organismes/filters/FiltreYesNo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from "react";

import SimpleOverlayMenu from "@/modules/dashboard/SimpleOverlayMenu";

import { OrganismesFilterButton } from "./OrganismesFilterButton";
import { FilterButton } from "../../../components/FilterButton/FilterButton";

interface FiltreYesNoProps {
fieldName: string;
Expand All @@ -19,12 +19,7 @@ function FiltreYesNo(props: FiltreYesNoProps) {

return (
<div>
<OrganismesFilterButton
isOpen={isOpen}
setIsOpen={setIsOpen}
buttonLabel={buttonLabel}
badge={selectionItems?.length}
/>
<FilterButton isOpen={isOpen} setIsOpen={setIsOpen} buttonLabel={buttonLabel} badge={selectionItems?.length} />
{isOpen && (
<SimpleOverlayMenu onClose={() => setIsOpen(false)} width="auto" p="3w">
<CheckboxGroup
Expand Down

0 comments on commit 3e2cb5d

Please sign in to comment.