-
Notifications
You must be signed in to change notification settings - Fork 67
/
Rest.tsx
56 lines (50 loc) 路 1.94 KB
/
Rest.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {Form, Tabs} from 'antd';
import {DEFAULT_HEADERS} from 'constants/Test.constants';
import {Body} from 'components/Inputs';
import TriggerTab from 'components/TriggerTab';
import useQueryTabs from 'hooks/useQueryTabs';
import {Auth, SSL, KeyValueList, SkipTraceCollection} from 'components/Fields';
import {TDraftTest} from 'types/Test.types';
import * as S from './Rest.styled';
const Rest = () => {
const [activeKey, setActiveKey] = useQueryTabs('auth', 'triggerTab');
const form = Form.useFormInstance<TDraftTest>();
const authType = Form.useWatch(['auth', 'type'], form);
const body = Form.useWatch('body', form);
const headers = Form.useWatch('headers', form);
const sslVerification = Form.useWatch('sslVerification', form);
const skipTraceCollection = Form.useWatch('skipTraceCollection', form);
return (
<Tabs defaultActiveKey={activeKey} activeKey={activeKey} onChange={setActiveKey}>
<Tabs.TabPane forceRender tab={<TriggerTab hasContent={!!authType} label="Auth" />} key="auth">
<Auth />
</Tabs.TabPane>
<Tabs.TabPane forceRender tab={<TriggerTab hasContent={!!body} label="Body" />} key="body">
<Form.Item name="body" noStyle>
<Body />
</Form.Item>
</Tabs.TabPane>
<Tabs.TabPane forceRender tab={<TriggerTab totalItems={headers?.length} label="Headers" />} key="headers">
<KeyValueList
name="headers"
label=""
addButtonLabel="Add Header"
keyPlaceholder="Header"
valuePlaceholder="Value"
initialValue={DEFAULT_HEADERS}
/>
</Tabs.TabPane>
<Tabs.TabPane
forceRender
tab={<TriggerTab hasContent={!!sslVerification || !!skipTraceCollection} label="Settings" />}
key="settings"
>
<S.SettingsContainer>
<SSL formID="rest" />
<SkipTraceCollection />
</S.SettingsContainer>
</Tabs.TabPane>
</Tabs>
);
};
export default Rest;