import React from 'react'; import get from 'lodash/get'; import { closeTabs } from 'providers/ReduxStore/slices/tabs'; import { useDispatch } from 'react-redux'; import { findItemInCollection } from 'utils/collections'; import StyledWrapper from './StyledWrapper'; import { IconAlertTriangle } from '@tabler/icons'; const RequestTab = ({tab, collection}) => { const dispatch = useDispatch(); const handleCloseClick = (event) => { event.stopPropagation(); event.preventDefault(); dispatch(closeTabs({ tabUids: [tab.uid] })) }; const getMethodColor = (method = '') => { let color = ''; method = method.toLocaleLowerCase(); switch(method) { case 'get': { color = 'rgb(5, 150, 105)'; break; } case 'post': { color = '#8e44ad'; break; } } return color; }; const item = findItemInCollection(collection, tab.uid); if(!item) { return (
Not Found
handleCloseClick(e)}>
); } const method = item.draft ? get(item, 'draft.request.method') : get(item, 'request.method'); return (
{method} {item.name}
handleCloseClick(e)}> {!item.draft ? ( ) : ( ) }
); }; export default RequestTab;