import React from 'react';
import { JSONTree, NoContent, Tabs } from 'UI';
import { Button } from 'antd';
import cn from 'classnames';
import AnimatedSVG, { ICONS } from 'Shared/AnimatedSVG/AnimatedSVG';
import stl from './fetchDetails.module.css';
import Headers from './components/Headers';
const HEADERS = 'HEADERS';
const REQUEST = 'REQUEST';
const RESPONSE = 'RESPONSE';
const TABS = [HEADERS, REQUEST, RESPONSE].map((tab) => ({ text: tab, key: tab }));
export default class FetchDetails extends React.PureComponent {
state = { activeTab: REQUEST, tabs: [] };
onTabClick = (activeTab) => this.setState({ activeTab });
componentDidMount() {
this.checkTabs();
}
renderActiveTab = (tab) => {
const { resource: { payload, response = this.props.resource.body } } = this.props;
let jsonPayload; let jsonResponse; let requestHeaders; let
responseHeaders;
try {
jsonPayload = typeof payload === 'string' ? JSON.parse(payload) : payload;
requestHeaders = jsonPayload.headers;
jsonPayload.body = typeof jsonPayload.body === 'string' ? JSON.parse(jsonPayload.body) : jsonPayload.body;
delete jsonPayload.headers;
} catch (e) {}
try {
jsonResponse = typeof response === 'string' ? JSON.parse(response) : response;
responseHeaders = jsonResponse.headers;
jsonResponse.body = typeof jsonResponse.body === 'string' ? JSON.parse(jsonResponse.body) : jsonResponse.body;
delete jsonResponse.headers;
} catch (e) {}
switch (tab) {
case REQUEST:
return (