@@ -20,9 +20,9 @@ const RawBodyTypeSelect = (props) => {
20
20
if ( ! dropdownEl . current . contains ( event . target ) ) {
21
21
setDropdownIsActive ( false ) ;
22
22
}
23
- }
24
- document . addEventListener ( ' click' , closeDropdown ) ;
25
- return ( ) => document . removeEventListener ( ' click' , closeDropdown ) ;
23
+ } ;
24
+ document . addEventListener ( " click" , closeDropdown ) ;
25
+ return ( ) => document . removeEventListener ( " click" , closeDropdown ) ;
26
26
} , [ ] ) ;
27
27
28
28
// const removeContentTypeHeader = () => {
@@ -39,93 +39,124 @@ const RawBodyTypeSelect = (props) => {
39
39
setNewRequestBody ( {
40
40
...newRequestBody ,
41
41
rawType : rawTypeStr ,
42
- } )
43
- }
42
+ } ) ;
43
+ const headersCopy = JSON . parse ( JSON . stringify ( newRequestHeaders ) ) ;
44
+ headersCopy . headersArr [ 0 ] = {
45
+ id : Math . random ( ) * 1000000 ,
46
+ active : true ,
47
+ key : "Content-type" ,
48
+ value : rawTypeStr ,
49
+ } ;
50
+ setNewRequestHeaders ( {
51
+ headersArr : headersCopy . headersArr ,
52
+ } ) ;
53
+ } ;
44
54
45
55
return (
46
- < div ref = { dropdownEl } className = { `mt-1 mr-3 dropdown ${ dropdownIsActive ? 'is-active' : '' } ` } >
47
-
56
+ < div
57
+ ref = { dropdownEl }
58
+ className = { `mt-1 mr-3 dropdown ${ dropdownIsActive ? "is-active" : "" } ` }
59
+ >
48
60
< div className = "dropdown-trigger" >
49
- < button className = "button is-small is-primary is-outlined add-header-or-cookie-button" aria-haspopup = "true" aria-controls = "dropdown-menu"
61
+ < button
62
+ className = "button is-small is-primary is-outlined add-header-or-cookie-button"
63
+ aria-haspopup = "true"
64
+ aria-controls = "dropdown-menu"
50
65
onClick = { ( ) => setDropdownIsActive ( ! dropdownIsActive ) }
51
66
>
52
67
< span > { newRequestBody . rawType } </ span >
53
68
< span className = "icon is-small" >
54
- < img src = { dropDownArrow } className = "is-awesome-icon" aria-hidden = "true" />
69
+ < img
70
+ src = { dropDownArrow }
71
+ className = "is-awesome-icon"
72
+ aria-hidden = "true"
73
+ />
55
74
</ span >
56
75
</ button >
57
76
</ div >
58
77
59
78
< div className = "dropdown-menu" >
60
79
< ul className = "dropdown-content" >
61
- { newRequestBody . rawType !== ' text/plain' &&
80
+ { newRequestBody . rawType !== " text/plain" && (
62
81
< a
63
82
onClick = { ( ) => {
64
- setDropdownIsActive ( false ) ;
65
- setNewRawBodyType ( "text/plain" )
66
- } }
67
- className = "dropdown-item"
68
- > text/plain</ a >
69
- }
70
- { newRequestBody . rawType !== 'application/json' &&
71
- < a
83
+ setDropdownIsActive ( false ) ;
84
+ setNewRawBodyType ( "text/plain" ) ;
85
+ } }
86
+ className = "dropdown-item"
87
+ >
88
+ text/plain
89
+ </ a >
90
+ ) }
91
+ { newRequestBody . rawType !== "application/json" && (
92
+ < a
72
93
onClick = { ( ) => {
73
94
setDropdownIsActive ( false ) ;
74
- setNewRawBodyType ( 'application/json' ) ;
75
- } }
76
- className = "dropdown-item"
77
- > application/json</ a >
78
- }
79
- { newRequestBody . rawType !== 'application/javascript' &&
95
+ setNewRawBodyType ( "application/json" ) ;
96
+ } }
97
+ className = "dropdown-item"
98
+ >
99
+ application/json
100
+ </ a >
101
+ ) }
102
+ { newRequestBody . rawType !== "application/javascript" && (
80
103
< a
81
104
onClick = { ( ) => {
82
105
setDropdownIsActive ( false ) ;
83
- setNewRawBodyType ( 'application/javascript' )
84
- } }
85
- className = "dropdown-item"
86
- > application/javascript</ a >
87
- }
88
- { newRequestBody . rawType !== 'application/xml' &&
106
+ setNewRawBodyType ( "application/javascript" ) ;
107
+ } }
108
+ className = "dropdown-item"
109
+ >
110
+ application/javascript
111
+ </ a >
112
+ ) }
113
+ { newRequestBody . rawType !== "application/xml" && (
89
114
< a
90
115
onClick = { ( ) => {
91
116
setDropdownIsActive ( false ) ;
92
- setNewRawBodyType ( 'application/xml' )
93
- } }
94
- className = "dropdown-item"
95
- > application/xml</ a >
96
- }
97
- { newRequestBody . rawType !== 'text/xml' &&
117
+ setNewRawBodyType ( "application/xml" ) ;
118
+ } }
119
+ className = "dropdown-item"
120
+ >
121
+ application/xml
122
+ </ a >
123
+ ) }
124
+ { newRequestBody . rawType !== "text/xml" && (
98
125
< a
99
126
onClick = { ( ) => {
100
127
setDropdownIsActive ( false ) ;
101
- setNewRawBodyType ( 'text/xml' )
102
- } }
103
- className = "dropdown-item"
104
- > text/xml</ a >
105
- }
106
- { newRequestBody . rawType !== 'text/html' &&
107
- < a
128
+ setNewRawBodyType ( "text/xml" ) ;
129
+ } }
130
+ className = "dropdown-item"
131
+ >
132
+ text/xml
133
+ </ a >
134
+ ) }
135
+ { newRequestBody . rawType !== "text/html" && (
136
+ < a
108
137
onClick = { ( ) => {
109
138
setDropdownIsActive ( false ) ;
110
- setNewRawBodyType ( 'text/html' )
111
- } }
112
- className = "dropdown-item"
113
- > text/html</ a >
114
- }
139
+ setNewRawBodyType ( "text/html" ) ;
140
+ } }
141
+ className = "dropdown-item"
142
+ >
143
+ text/html
144
+ </ a >
145
+ ) }
115
146
</ ul >
116
147
</ div >
117
148
</ div >
118
- ) ;
119
- }
120
-
121
- // <select
122
- // onChange={(e) =>
123
- // setNewRequestBody({
124
- // ...newRequestBody,
125
- // rawType: e.target.value,
126
- // })
127
- // }
128
- // value={newRequestBody.rawType}
149
+ ) ;
150
+ } ;
151
+
152
+ // <select
153
+ // onChange={(e) =>
154
+ // setNewRequestBody({
155
+ // ...newRequestBody,
156
+ // rawType: e.target.value,
157
+ // })
158
+ // }
159
+ // value={newRequestBody.rawType}
129
160
// >
130
161
// {/* Raw Type: */}
131
162
// <option value="text/plain">Text (text/plain)</option>
@@ -136,7 +167,6 @@ const RawBodyTypeSelect = (props) => {
136
167
// <option value="text/html">HTML (text/html)</option>
137
168
// </select>
138
169
139
-
140
170
RawBodyTypeSelect . propTypes = {
141
171
newRequestBody : PropTypes . object . isRequired ,
142
172
setNewRequestBody : PropTypes . func . isRequired ,
0 commit comments