Skip to content

Commit 15c140b

Browse files
committed
RESPONSE now render properly
1 parent 2b82fe3 commit 15c140b

File tree

4 files changed

+89
-93
lines changed

4 files changed

+89
-93
lines changed

src/client/components/main/TRPC-composer/TRPCComposer.tsx

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -257,80 +257,10 @@ export default function TRPCComposer(props) {
257257

258258
const sendRequest = async () => {
259259
const id = uuid();
260-
// const headers = newRequest.newRequestHeaders.headersArr.filter(
261-
// (x) => x.active
262-
// );
263-
// const cookie = cookiesArr.filter((x) => x.active);
264-
// const reqRes = {
265-
// id,
266-
// createdAt: new Date(),
267-
// protocol,
268-
// trpc: true,
269-
// url: 'http://localhost:3000/trpc',
270-
// graphQL,
271-
// gRPC,
272-
// webrtc,
273-
// timeSent: null,
274-
// timeReceived: null,
275-
// connection: 'uninitialized',
276-
// connectionType: null,
277-
// checkSelected: false,
278-
// host: 'http://localhost:3000',
279-
// request: {
280-
// method,
281-
// headers,
282-
// procedures,
283-
// bodyType,
284-
// rawType,
285-
// network,
286-
// restUrl,
287-
// wsUrl,
288-
// gqlUrl,
289-
// cookie,
290-
// },
291-
// response: {
292-
// cookies: [],
293-
// headers: {},
294-
// stream: null,
295-
// events: [],
296-
// },
297-
// checked: false,
298-
// minimized: false,
299-
// tab: currentTab,
300-
// };
301-
302-
const cache = [
303-
{
304-
method: 'MUTATE',
305-
endpoint: 'update',
306-
variable: '{\n "userId": "1",\n "name": "nguyen"\n }',
307-
},
308-
{ method: 'QUERY', endpoint: 'sayHi', variable: '' },
309-
{
310-
method: 'MUTATE',
311-
endpoint: 'log',
312-
variable: '"HELLO WORLD"',
313-
},
314-
{
315-
method: 'QUERY',
316-
endpoint: 'secretData',
317-
variable: '{\n "userId": "1",\n "name": "justin"\n }',
318-
},
319-
{
320-
method: 'QUERY',
321-
endpoint: 'BLAHBLAH.BLAH',
322-
variable: '{\n "userId": "1",\n "name": "justin"\n }',
323-
},
324-
];
325-
326-
const cookiCache = [
327-
{ id: 'cookie0', active: true, key: 'cookie1', value: 'cookie1Val' },
328-
{ id: 'cookie1', active: true, key: 'cookie2', value: 'cookie2Val' },
329-
];
330-
const headerCache = [
331-
{ id: 351217.45631817693, active: true, key: 'auth1', value: 'auth2' },
332-
{ id: 87384.65282544694, active: true, key: 'auth3', value: 'auth4' },
333-
];
260+
const headers = newRequest.newRequestHeaders.headersArr.filter(
261+
(x) => x.active
262+
);
263+
const cookie = cookiesArr.filter((x) => x.active);
334264
const reqRes = {
335265
id,
336266
createdAt: new Date(),
@@ -348,26 +278,96 @@ export default function TRPCComposer(props) {
348278
host: 'http://localhost:3000',
349279
request: {
350280
method,
351-
headers: headerCache,
352-
procedures: cache,
281+
headers,
282+
procedures,
353283
bodyType,
354284
rawType,
355285
network,
356286
restUrl,
357287
wsUrl,
358288
gqlUrl,
359-
cookie: cookiCache,
289+
cookie,
360290
},
361291
response: {
362292
cookies: [],
363-
headers: [],
293+
headers: {},
364294
stream: null,
365295
events: [],
366296
},
367297
checked: false,
368298
minimized: false,
369299
tab: currentTab,
370300
};
301+
302+
// const cache = [
303+
// {
304+
// method: 'MUTATE',
305+
// endpoint: 'update',
306+
// variable: '{\n "userId": "1",\n "name": "nguyen"\n }',
307+
// },
308+
// { method: 'QUERY', endpoint: 'sayHi', variable: '' },
309+
// {
310+
// method: 'MUTATE',
311+
// endpoint: 'log',
312+
// variable: '"HELLO WORLD"',
313+
// },
314+
// {
315+
// method: 'QUERY',
316+
// endpoint: 'secretData',
317+
// variable: '{\n "userId": "1",\n "name": "justin"\n }',
318+
// },
319+
// {
320+
// method: 'QUERY',
321+
// endpoint: 'BLAHBLAH.BLAH',
322+
// variable: '{\n "userId": "1",\n "name": "justin"\n }',
323+
// },
324+
// ];
325+
326+
// const cookiCache = [
327+
// { id: 'cookie0', active: true, key: 'cookie1', value: 'cookie1Val' },
328+
// { id: 'cookie1', active: true, key: 'cookie2', value: 'cookie2Val' },
329+
// ];
330+
// const headerCache = [
331+
// { id: 351217.45631817693, active: true, key: 'auth1', value: 'auth2' },
332+
// { id: 87384.65282544694, active: true, key: 'auth3', value: 'auth4' },
333+
// ];
334+
// const reqRes = {
335+
// id,
336+
// createdAt: new Date(),
337+
// protocol,
338+
// trpc: true,
339+
// url: 'http://localhost:3000/trpc',
340+
// graphQL,
341+
// gRPC,
342+
// webrtc,
343+
// timeSent: null,
344+
// timeReceived: null,
345+
// connection: 'uninitialized',
346+
// connectionType: null,
347+
// checkSelected: false,
348+
// host: 'http://localhost:3000',
349+
// request: {
350+
// method,
351+
// headers: headerCache,
352+
// procedures: cache,
353+
// bodyType,
354+
// rawType,
355+
// network,
356+
// restUrl,
357+
// wsUrl,
358+
// gqlUrl,
359+
// cookie: cookiCache,
360+
// },
361+
// response: {
362+
// cookies: [],
363+
// headers: [],
364+
// stream: null,
365+
// events: [],
366+
// },
367+
// checked: false,
368+
// minimized: false,
369+
// tab: currentTab,
370+
// };
371371
// add request to history
372372
historyController.addHistoryToIndexedDb(reqRes);
373373
reqResItemAdded(reqRes);

src/client/components/main/response-composer/EventsContainer.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,18 @@ function EventsContainer({ currentResponse }: EventsContainerProps) {
3434
}
3535
const { events, headers } = response;
3636
let responseBody = '';
37-
37+
if (currentResponse.trpc) {
38+
events.forEach((event: any, idx: number) => {
39+
if (event) {
40+
const eventStr = JSON.stringify(event, null, 4);
41+
responseBody += `-------------${
42+
idx ? 'Mutate Result' : 'Query result'
43+
}-------------\n${eventStr}\n\n`;
44+
}
45+
});
46+
}
3847
// If it's a stream or graphQL subscription
39-
if (
48+
else if (
4049
(events && events.length > 1) ||
4150
(headers?.['content-type'] && headers['content-type'].includes('stream')) ||
4251
(currentResponse.graphQL && request.method === 'SUBSCRIPTION')

src/client/components/main/response-composer/HeadersContainer.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,8 @@ function HeadersContainer({ currentResponse }: Props) {
2424
return <EmptyState />;
2525
}
2626

27-
console.log('CURRENT RES ', currentResponse);
2827
let responseHeaders;
2928

30-
{
31-
/* <tbody>{Object.entries(req).map(([key, value], index) => {
32-
return (
33-
<tr key={index}>
34-
<td>{key}</td>
35-
<td className="table-value">{value}</td>
36-
</tr>
37-
);
38-
})}</tbody> */
39-
}
4029
if (currentResponse.trpc) {
4130
responseHeaders = currentResponse.response.headers.map((req, reqMethod) => {
4231
const typeHeader = reqMethod === 0 ? 'QUERY HEADER' : 'MUTATE HEADER';

src/client/controllers/reqResController.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ const connectionController = {
5656
/** @todo Find where id should be */
5757
const currentID = Store.getState().reqRes.currentResponse.id;
5858
if (currentID === reqResObj.id) {
59-
console.log('AFTER UPDATED: ', reqResObj);
6059
appDispatch(responseDataSaved(reqResObj));
6160
}
6261
});
@@ -68,7 +67,6 @@ const connectionController = {
6867
}
6968

7069
if (reqResObj.trpc) {
71-
console.log(reqResObj);
7270
api.send('open-trpc', reqResObj);
7371
} else if (reqResObj.request.method === 'SUBSCRIPTION')
7472
graphQLController.openSubscription(reqResObj);

0 commit comments

Comments
 (0)