mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
refactor: remove unused getStageCount function and simplify LifecycleFilters usage
This commit is contained in:
parent
92db5a02c3
commit
2a248ec085
@ -64,12 +64,11 @@ export const LifecycleFilters = ({
|
||||
total,
|
||||
children,
|
||||
countData,
|
||||
sx,
|
||||
}: ILifecycleFiltersBaseProps) => {
|
||||
const current = state.lifecycle?.values ?? [];
|
||||
|
||||
return (
|
||||
<Wrapper sx={sx}>
|
||||
<Wrapper>
|
||||
<StyledContainer>
|
||||
{lifecycleOptions.map(({ label, value }) => {
|
||||
const isActive =
|
||||
|
@ -1,31 +1,9 @@
|
||||
import type { FC, ReactNode } from 'react';
|
||||
import { Box } from '@mui/material';
|
||||
import type { FilterItemParamHolder } from '../../../filter/Filters/Filters.tsx';
|
||||
import type { LifecycleStage } from '../../FeatureView/FeatureOverview/FeatureLifecycle/LifecycleStage.tsx';
|
||||
import { useLifecycleCount } from 'hooks/api/getters/useLifecycleCount/useLifecycleCount';
|
||||
import type { FeatureLifecycleCountSchema } from 'openapi';
|
||||
import { LifecycleFilters } from '../../../common/LifecycleFilters/LifecycleFilters.tsx';
|
||||
|
||||
const getStageCount = (
|
||||
lifecycle: LifecycleStage['name'] | null,
|
||||
lifecycleCount?: FeatureLifecycleCountSchema,
|
||||
) => {
|
||||
if (!lifecycleCount) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (lifecycle === null) {
|
||||
return (
|
||||
(lifecycleCount.initial || 0) +
|
||||
(lifecycleCount.preLive || 0) +
|
||||
(lifecycleCount.live || 0) +
|
||||
(lifecycleCount.completed || 0)
|
||||
);
|
||||
}
|
||||
|
||||
const key = lifecycle === 'pre-live' ? 'preLive' : lifecycle;
|
||||
return lifecycleCount[key];
|
||||
};
|
||||
|
||||
interface ILifecycleFiltersProps {
|
||||
state: FilterItemParamHolder;
|
||||
onChange: (value: FilterItemParamHolder) => void;
|
||||
@ -49,17 +27,15 @@ export const FeatureLifecycleFilters: FC<ILifecycleFiltersProps> = ({
|
||||
);
|
||||
|
||||
return (
|
||||
<Box sx={(theme) => ({ padding: theme.spacing(1.5, 3, 0, 3) })}>
|
||||
<LifecycleFilters
|
||||
state={state}
|
||||
onChange={onChange}
|
||||
total={total}
|
||||
countData={countData}
|
||||
sx={{
|
||||
padding: (theme) =>
|
||||
`${theme.spacing(1.5)} ${theme.spacing(3)} 0 ${theme.spacing(3)}`,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</LifecycleFilters>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user