@@ -10,6 +10,7 @@ import { useSelector, useDispatch } from 'react-redux';
1010
1111import trpcController from '../../../controllers/trpcController' ;
1212import historyController from '../../../controllers/historyController' ;
13+ import connectionController from '../../../controllers/reqResController' ;
1314
1415// Import MUI components
1516import { Box } from '@mui/material' ;
@@ -257,76 +258,12 @@ export default function TRPCComposer(props) {
257258 const sendRequest = async ( ) => {
258259 const id = uuid ( ) ;
259260
260- // const headers = newRequest.newRequestHeaders.headersArr.filter(
261- // (x) => x.active
262- // );
261+ const headers = newRequest . newRequestHeaders . headersArr . filter (
262+ ( x ) => x . active
263+ ) ;
263264
264- // const cookie = cookiesArr.filter((x) => x.active);
265+ const cookie = cookiesArr . filter ( ( x ) => x . active ) ;
265266
266- // const reqRes = {
267- // id,
268- // createdAt: new Date(),
269- // protocol,
270- // trpc: true,
271- // url: 'http://localhost:3000/trpc',
272- // graphQL,
273- // gRPC,
274- // webrtc,
275- // timeSent: null,
276- // timeReceived: null,
277- // connection: 'uninitialized',
278- // connectionType: null,
279- // checkSelected: false,
280- // request: {
281- // method,
282- // headers,
283- // procedures,
284- // bodyType,
285- // rawType,
286- // network,
287- // restUrl,
288- // wsUrl,
289- // gqlUrl,
290- // cookie,
291- // },
292- // response: {
293- // cookies: [],
294- // headers: {},
295- // stream: null,
296- // events: [],
297- // },
298- // checked: false,
299- // minimized: false,
300- // tab: currentTab,
301- // };
302-
303- const cache = [
304- {
305- method : 'MUTATE' ,
306- endpoint : 'update' ,
307- variable : '{\n "userId": "1",\n "name": "nguyen"\n }' ,
308- } ,
309- { method : 'QUERY' , endpoint : 'sayHi' , variable : '' } ,
310- {
311- method : 'MUTATE' ,
312- endpoint : 'user.update' ,
313- variable : '{\n "userId": "1",\n "name": "justin"\n }' ,
314- } ,
315- {
316- method : 'QUERY' ,
317- endpoint : 'secretData' ,
318- variable : '{\n "userId": "1",\n "name": "justin"\n }' ,
319- } ,
320- ] ;
321-
322- const cookiCache = [
323- { id : 'cookie0' , active : true , key : 'cookie1' , value : 'cookie1Val' } ,
324- { id : 'cookie1' , active : true , key : 'cookie2' , value : 'cookie2Val' } ,
325- ] ;
326- const headerCache = [
327- { id : 351217.45631817693 , active : true , key : 'auth1' , value : 'auth2' } ,
328- { id : 87384.65282544694 , active : true , key : 'auth3' , value : 'auth4' } ,
329- ] ;
330267 const reqRes = {
331268 id,
332269 createdAt : new Date ( ) ,
@@ -341,17 +278,18 @@ export default function TRPCComposer(props) {
341278 connection : 'uninitialized' ,
342279 connectionType : null ,
343280 checkSelected : false ,
281+ host : 'http://localhost:3000' ,
344282 request : {
345283 method,
346- headers : headerCache ,
347- procedures : cache ,
284+ headers,
285+ procedures,
348286 bodyType,
349287 rawType,
350288 network,
351289 restUrl,
352290 wsUrl,
353291 gqlUrl,
354- cookie : cookiCache ,
292+ cookie,
355293 } ,
356294 response : {
357295 cookies : [ ] ,
@@ -363,12 +301,84 @@ export default function TRPCComposer(props) {
363301 minimized : false ,
364302 tab : currentTab ,
365303 } ;
304+
305+ const cache = [
306+ {
307+ method : 'MUTATE' ,
308+ endpoint : 'update' ,
309+ variable : '{\n "userId": "1",\n "name": "nguyen"\n }' ,
310+ } ,
311+ { method : 'QUERY' , endpoint : 'sayHi' , variable : '' } ,
312+ {
313+ method : 'MUTATE' ,
314+ endpoint : 'user.update' ,
315+ variable : '{\n "userId": "1",\n "name": "justin"\n }' ,
316+ } ,
317+ {
318+ method : 'QUERY' ,
319+ endpoint : 'secretData' ,
320+ variable : '{\n "userId": "1",\n "name": "justin"\n }' ,
321+ } ,
322+ {
323+ method : 'QUERY' ,
324+ endpoint : 'BLAHBLAH.BLAH' ,
325+ variable : '{\n "userId": "1",\n "name": "justin"\n }' ,
326+ } ,
327+ ] ;
328+
329+ // const cookiCache = [
330+ // { id: 'cookie0', active: true, key: 'cookie1', value: 'cookie1Val' },
331+ // { id: 'cookie1', active: true, key: 'cookie2', value: 'cookie2Val' },
332+ // ];
333+ // const headerCache = [
334+ // { id: 351217.45631817693, active: true, key: 'auth1', value: 'auth2' },
335+ // { id: 87384.65282544694, active: true, key: 'auth3', value: 'auth4' },
336+ // ];
337+ // const reqRes = {
338+ // id,
339+ // createdAt: new Date(),
340+ // protocol,
341+ // trpc: true,
342+ // url: 'http://localhost:3000/trpc',
343+ // graphQL,
344+ // gRPC,
345+ // webrtc,
346+ // timeSent: null,
347+ // timeReceived: null,
348+ // connection: 'uninitialized',
349+ // connectionType: null,
350+ // checkSelected: false,
351+ // host: 'http://localhost:3000',
352+ // request: {
353+ // method,
354+ // headers: headerCache,
355+ // procedures: cache,
356+ // bodyType,
357+ // rawType,
358+ // network,
359+ // restUrl,
360+ // wsUrl,
361+ // gqlUrl,
362+ // cookie: cookiCache,
363+ // },
364+ // response: {
365+ // cookies: [],
366+ // headers: [],
367+ // stream: null,
368+ // events: [],
369+ // },
370+ // checked: false,
371+ // minimized: false,
372+ // tab: currentTab,
373+ // };
366374 // add request to history
367375 historyController . addHistoryToIndexedDb ( reqRes ) ;
368376 reqResItemAdded ( reqRes ) ;
369377
370378 //reset for next request
371379 // composerFieldsReset();
380+ // connectionController.openReqRes(reqRes.id);
381+ dispatch ( responseDataSaved ( reqRes ) ) ;
372382 const updatedReqRes = await trpcController . sendRequest ( reqRes ) ;
373383
374384 // const links = [];
0 commit comments