Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Jul 19, 2024
1 parent b44350e commit 5a2c8cd
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 255 deletions.
38 changes: 23 additions & 15 deletions dashboard/src/components/Filter/CheckboxSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@ import { useCallback, useMemo } from 'react';

import Checkbox from '../Checkbox/Checkbox';

type TOnClickItem = (itemIdx: number, isChecked: boolean) => void;
type TOnClickItem = (value: string, isChecked: boolean) => void;

type TItems = { [key: string]: boolean };

interface ICheckboxSectionItem {
text: string;
value: string;
onClickItem: TOnClickItem;
idx: number;
isSelected: boolean;
}

interface ICheckboxList {
items: string[];
items: TItems;
onClickItem: TOnClickItem;
}

interface ICheckboxSubsection {
items: string[];
items: TItems;
title: string;
onClickItem: TOnClickItem;
}

export interface ICheckboxSection {
items?: string[];
items?: TItems;
title: string;
subtitle?: string;
subsections?: ICheckboxSubsection[];
Expand All @@ -33,26 +35,32 @@ export interface ICheckboxSection {
}

const CheckboxSectionItem = ({
text,
value,
onClickItem,
idx,
isSelected,
}: ICheckboxSectionItem): JSX.Element => {
const handleOnToggle = useCallback(
(isChecked: boolean) => onClickItem(idx, isChecked),
[idx, onClickItem],
(isChecked: boolean) => onClickItem(value, isChecked),
[value, onClickItem],
);
return (
<Checkbox
onToggle={handleOnToggle}
text={value}
startChecked={isSelected}
/>
);
return <Checkbox onToggle={handleOnToggle} text={text} />;
};

const CheckboxList = ({ items, onClickItem }: ICheckboxList): JSX.Element => {
const itemComponents = useMemo(
() =>
items.map((text, idx) => (
Object.keys(items).map(key => (
<CheckboxSectionItem
key={text}
text={text}
idx={idx}
key={key}
value={key}
onClickItem={onClickItem}
isSelected={items[key]}
/>
)),
[items, onClickItem],
Expand Down

This file was deleted.

85 changes: 0 additions & 85 deletions dashboard/src/components/Filter/stories/FilterDrawer.stories.tsx

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5a2c8cd

Please sign in to comment.