feat: remove request headers

This commit is contained in:
Anoop M D 2021-12-31 22:28:40 +05:30
parent d7c3779e14
commit d89ae537c1
6 changed files with 606 additions and 476 deletions

1057
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,6 +7,7 @@
], ],
"devDependencies": { "devDependencies": {
"@babel/core": "^7.16.0", "@babel/core": "^7.16.0",
"@babel/plugin-transform-spread": "^7.16.7",
"@babel/preset-env": "^7.16.4", "@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0", "@babel/preset-react": "^7.16.0",
"@babel/runtime": "^7.16.3", "@babel/runtime": "^7.16.3",

View File

@ -2,5 +2,10 @@
"presets": [ "presets": [
"@babel/preset-env", "@babel/preset-env",
["@babel/preset-react", {"runtime": "automatic"}] ["@babel/preset-react", {"runtime": "automatic"}]
],
"plugins": [
["@babel/plugin-transform-spread", {
"loose": true
}]
] ]
} }

View File

@ -29,6 +29,7 @@
"codemirror": "^5.64.0", "codemirror": "^5.64.0",
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"markdown-it": "^12.2.0", "markdown-it": "^12.2.0",
"nanoid": "^3.1.30",
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-tabs": "^3.2.3", "react-tabs": "^3.2.3",

View File

@ -1,15 +1,22 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { nanoid } from 'nanoid';
import StyledWrapper from './StyledWrapper'; import StyledWrapper from './StyledWrapper';
const initialState = [{
uid: nanoid(),
enabled: true
}];
const RequestHeaders = () => { const RequestHeaders = () => {
const [headers, setHeaders] = useState([{enabled: true}]); const [headers, setHeaders] = useState(initialState);
const addHeader = () => { const addHeader = () => {
let newHeader = { let newHeader = {
uid: nanoid(),
key: '', key: '',
value: '', value: '',
description: '', description: '',
enabled: true, enabled: true
}; };
let newHeaders = [...headers, newHeader]; let newHeaders = [...headers, newHeader];
@ -22,7 +29,7 @@ const RequestHeaders = () => {
const handleRemoveHeader = (index) => { const handleRemoveHeader = (index) => {
headers.splice(index, 1); headers.splice(index, 1);
setHeaders(...headers); setHeaders([...headers]);
}; };
return ( return (
@ -40,7 +47,7 @@ const RequestHeaders = () => {
<tbody> <tbody>
{headers && headers.length && headers.map((header, index) => { {headers && headers.length && headers.map((header, index) => {
return ( return (
<tr key={index}> <tr key={header.uid}>
<td> <td>
<input <input
type="checkbox" type="checkbox"
@ -79,7 +86,7 @@ const RequestHeaders = () => {
</button> </button>
</td> </td>
</tr> </tr>
) );
})} })}
</tbody> </tbody>
</table> </table>

View File

@ -40,6 +40,7 @@ module.exports = {
'graphql': 'graphql', 'graphql': 'graphql',
'escape-html': 'escape-html', 'escape-html': 'escape-html',
'markdown-it': 'markdown-it', 'markdown-it': 'markdown-it',
'nanoid': 'nanoid',
'graphql-request': 'graphql-request' 'graphql-request': 'graphql-request'
}, },
plugins: [ plugins: [