1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-24 17:51:14 +02:00
unleash.unleash/frontend/src/component/feature/FeatureToggleList/FeatureToggleFilters/FeatureToggleFilters.tsx
Tymoteusz Czech 755c22f3b9
feat: features list pagination (#5496)
New paginated table - tested on /features-new behind a flag
2023-12-01 14:53:05 +00:00

41 lines
1.2 KiB
TypeScript

import { VFC } from 'react';
import { Box } from '@mui/material';
import { FilterItem } from 'component/common/FilterItem/FilterItem';
import useProjects from 'hooks/api/getters/useProjects/useProjects';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
export type FeatureTogglesListFilters = {
projectId?: string;
};
interface IFeatureToggleFiltersProps {
state: FeatureTogglesListFilters;
onChange: (value: FeatureTogglesListFilters) => void;
}
export const FeatureToggleFilters: VFC<IFeatureToggleFiltersProps> = ({
state,
onChange,
}) => {
const { projects } = useProjects();
const projectsOptions = (projects || []).map((project) => ({
label: project.name,
value: project.id,
}));
return (
<Box sx={(theme) => ({ padding: theme.spacing(2, 3) })}>
<ConditionallyRender
condition={projectsOptions.length > 1}
show={() => (
<FilterItem
label='Project'
options={projectsOptions}
onChange={(value) => onChange({ projectId: value })}
/>
)}
/>
</Box>
);
};