forked from extern/bruno
* fix collection headers in code generator * remove logs
This commit is contained in:
parent
d62982d52d
commit
d0c25d46c9
@ -8,12 +8,20 @@ import { useSelector } from 'react-redux';
|
||||
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
||||
import toast from 'react-hot-toast';
|
||||
import { IconCopy } from '@tabler/icons';
|
||||
import { findCollectionByItemUid } from '../../../../../../../utils/collections/index';
|
||||
|
||||
const CodeView = ({ language, item }) => {
|
||||
const { storedTheme } = useTheme();
|
||||
const preferences = useSelector((state) => state.app.preferences);
|
||||
const { target, client, language: lang } = language;
|
||||
const headers = item.draft ? get(item, 'draft.request.headers') : get(item, 'request.headers');
|
||||
const requestHeaders = item.draft ? get(item, 'draft.request.headers') : get(item, 'request.headers');
|
||||
const collection = findCollectionByItemUid(
|
||||
useSelector((state) => state.collections.collections),
|
||||
item.uid
|
||||
);
|
||||
|
||||
const headers = [...collection?.root?.request?.headers, ...requestHeaders];
|
||||
|
||||
let snippet = '';
|
||||
|
||||
try {
|
||||
|
@ -91,6 +91,12 @@ export const findCollectionByPathname = (collections, pathname) => {
|
||||
return find(collections, (c) => c.pathname === pathname);
|
||||
};
|
||||
|
||||
export const findCollectionByItemUid = (collections, itemUid) => {
|
||||
return find(collections, (c) => {
|
||||
return findItemInCollection(c, itemUid);
|
||||
});
|
||||
};
|
||||
|
||||
export const findItemByPathname = (items = [], pathname) => {
|
||||
return find(items, (i) => i.pathname === pathname);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user