filter form tabs in Form component

This commit is contained in:
vchikalkin 2024-06-19 14:29:44 +03:00
parent b87c22b6ed
commit 5aad257058
2 changed files with 15 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import Payments from './Payments';
import SupplierAgent from './SupplierAgent';
import Unlimited from './Unlimited';
import Background from '@/Components/Layout/Background';
import { useStore } from '@/stores/hooks';
import { min } from '@/styles/mq';
import styled from 'styled-components';
import { Tabs } from 'ui/elements';
@ -44,19 +45,22 @@ const ComponentWrapper = styled.div`
}
`;
export function Form({ prune }) {
export function Form() {
const { $process } = useStore();
const filteredTabs =
$process.has('Unlimited') === false ? formTabs.filter((x) => x.id !== 'unlimited') : formTabs;
return (
<Wrapper>
<Tabs type="card" tabBarGutter="5px">
{formTabs
.filter((tab) => !prune?.includes(tab.id))
.map(({ Component, id, title }) => (
<Tabs.TabPane tab={title} key={id}>
<ComponentWrapper>
<Component />
</ComponentWrapper>
</Tabs.TabPane>
))}
{filteredTabs.map(({ Component, id, title }) => (
<Tabs.TabPane tab={title} key={id}>
<ComponentWrapper>
<Component />
</ComponentWrapper>
</Tabs.TabPane>
))}
</Tabs>
</Wrapper>
);

View File

@ -23,7 +23,7 @@ const tabs = [
title: 'Расчет',
},
{
Component: () => <Calculation.Form prune={['unlimited']} />,
Component: () => <Calculation.Form />,
key: 'form',
title: 'Параметры',
},