summaryrefslogtreecommitdiffstats
path: root/src/components/Content/Content.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/Content/Content.tsx')
-rw-r--r--src/components/Content/Content.tsx50
1 files changed, 13 insertions, 37 deletions
diff --git a/src/components/Content/Content.tsx b/src/components/Content/Content.tsx
index cb5e6bc..0e63f30 100644
--- a/src/components/Content/Content.tsx
+++ b/src/components/Content/Content.tsx
@@ -1,19 +1,9 @@
1import styles from "~components/Details/Details.module.scss";
2import * as React from "react"; 1import * as React from "react";
3import classNames from "classnames"; 2import {Dispatch, SetStateAction, useMemo} from "react";
4import {RequestPayload, ResponsePayload} from "~hooks/useRequests"; 3import {RequestPayload, ResponsePayload} from "~hooks/useRequests";
5import {
6 Dispatch,
7 forwardRef, SetStateAction,
8 useEffect,
9 useImperativeHandle,
10 useMemo,
11 useRef,
12 useState
13} from "react";
14import ReactJson from 'react-json-view'; 4import ReactJson from 'react-json-view';
15import styles from './Content.module.scss'; 5import styles from './Content.module.scss';
16import {Col, Container, Row} from "react-bootstrap"; 6import {Button, Col, Container, Row} from "react-bootstrap";
17 7
18function getHeader(headers: { [key: string]: string }, key: string, unit?: string): string | null { 8function getHeader(headers: { [key: string]: string }, key: string, unit?: string): string | null {
19 console.log(headers, key) 9 console.log(headers, key)
@@ -37,7 +27,7 @@ interface ContentProps {
37 27
38export default function Content({ raw, setRaw, data }: ContentProps): JSX.Element { 28export default function Content({ raw, setRaw, data }: ContentProps): JSX.Element {
39 return ( 29 return (
40 <> 30 <div className={styles.content}>
41 <Container fluid className="border-bottom"> 31 <Container fluid className="border-bottom">
42 <Row className="py-3"> 32 <Row className="py-3">
43 <Col> 33 <Col>
@@ -54,7 +44,7 @@ export default function Content({ raw, setRaw, data }: ContentProps): JSX.Elemen
54 </Col> 44 </Col>
55 </Row> 45 </Row>
56 </Container> 46 </Container>
57 <Row> 47 <Row className={styles.body}>
58 {(() => { 48 {(() => {
59 try { 49 try {
60 return ContentBody({ data, raw }) 50 return ContentBody({ data, raw })
@@ -62,33 +52,13 @@ export default function Content({ raw, setRaw, data }: ContentProps): JSX.Elemen
62 return ( 52 return (
63 <div className={styles.renderError}> 53 <div className={styles.renderError}>
64 <p>Body could not be rendered</p> 54 <p>Body could not be rendered</p>
65 <a onClick={() => setRaw(true)}>View raw</a> 55 <Button variant="link" onClick={() => setRaw(true)}>View raw</Button>
66 </div> 56 </div>
67 ) 57 )
68 } 58 }
69 })()} 59 })()}
70 </Row> 60 </Row>
71 </> 61 </div >
72 // <div className={styles.content}>
73 // <div className={styles.header}>
74 // <input id='raw' type='checkbox' checked={raw} onChange={() => setRaw(!raw)}/>
75 // <label htmlFor='raw'>Raw</label>
76 // </div>
77 // <div className={styles.body}>
78 // {(() => {
79 // try {
80 // return ContentBody({ ...props, raw })
81 // } catch {
82 // return (
83 // <div className={styles.renderError}>
84 // <p>Body could not be rendered</p>
85 // <a onClick={() => setRaw(true)}>View raw</a>
86 // </div>
87 // )
88 // }
89 // })()}
90 // </div>
91 // </div>
92 ) 62 )
93}; 63};
94 64
@@ -103,7 +73,13 @@ function ContentBody({ data, raw = false }: Omit<ContentProps, 'setRaw'>) {
103 }, [data, raw]); 73 }, [data, raw]);
104 74
105 if (raw) { 75 if (raw) {
106 return <pre>{atob(data.body)}</pre> 76 return (
77 <pre className="mb-0">
78 <code>
79 {atob(data.body)}
80 </code>
81 </pre>
82 )
107 } 83 }
108 84
109 if (['application/pdf', 'text/html'].includes(contentType)) { 85 if (['application/pdf', 'text/html'].includes(contentType)) {