@@ -20,9 +20,9 @@ const RawBodyTypeSelect = (props) => {
2020 if ( ! dropdownEl . current . contains ( event . target ) ) {
2121 setDropdownIsActive ( false ) ;
2222 }
23- }
24- document . addEventListener ( ' click' , closeDropdown ) ;
25- return ( ) => document . removeEventListener ( ' click' , closeDropdown ) ;
23+ } ;
24+ document . addEventListener ( " click" , closeDropdown ) ;
25+ return ( ) => document . removeEventListener ( " click" , closeDropdown ) ;
2626 } , [ ] ) ;
2727
2828 // const removeContentTypeHeader = () => {
@@ -39,93 +39,124 @@ const RawBodyTypeSelect = (props) => {
3939 setNewRequestBody ( {
4040 ...newRequestBody ,
4141 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+ } ;
4454
4555 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+ >
4860 < 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"
5065 onClick = { ( ) => setDropdownIsActive ( ! dropdownIsActive ) }
5166 >
5267 < span > { newRequestBody . rawType } </ span >
5368 < 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+ />
5574 </ span >
5675 </ button >
5776 </ div >
5877
5978 < div className = "dropdown-menu" >
6079 < ul className = "dropdown-content" >
61- { newRequestBody . rawType !== ' text/plain' &&
80+ { newRequestBody . rawType !== " text/plain" && (
6281 < a
6382 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
7293 onClick = { ( ) => {
7394 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" && (
80103 < a
81104 onClick = { ( ) => {
82105 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" && (
89114 < a
90115 onClick = { ( ) => {
91116 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" && (
98125 < a
99126 onClick = { ( ) => {
100127 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
108137 onClick = { ( ) => {
109138 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+ ) }
115146 </ ul >
116147 </ div >
117148 </ 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}
129160// >
130161// {/* Raw Type: */}
131162// <option value="text/plain">Text (text/plain)</option>
@@ -136,7 +167,6 @@ const RawBodyTypeSelect = (props) => {
136167// <option value="text/html">HTML (text/html)</option>
137168// </select>
138169
139-
140170RawBodyTypeSelect . propTypes = {
141171 newRequestBody : PropTypes . object . isRequired ,
142172 setNewRequestBody : PropTypes . func . isRequired ,
0 commit comments