diff options
| author | 2022-01-23 19:25:56 +0100 | |
|---|---|---|
| committer | 2022-01-25 22:06:58 +0100 | |
| commit | 2f27e222add9bf10b55971ab915ac411e81d24f0 (patch) | |
| tree | 6ed9ea87932809d57d5db9d3c638a88a954ab8e2 /src/components/Content/Content.tsx | |
| parent | 51a2ac628822e96459b3d570eada953ac8927d43 (diff) | |
| download | client-2f27e222add9bf10b55971ab915ac411e81d24f0.tar.gz client-2f27e222add9bf10b55971ab915ac411e81d24f0.tar.bz2 client-2f27e222add9bf10b55971ab915ac411e81d24f0.zip | |
Rewritten ui to use boostrap
Diffstat (limited to 'src/components/Content/Content.tsx')
| -rw-r--r-- | src/components/Content/Content.tsx | 50 |
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 @@ | |||
| 1 | import styles from "~components/Details/Details.module.scss"; | ||
| 2 | import * as React from "react"; | 1 | import * as React from "react"; |
| 3 | import classNames from "classnames"; | 2 | import {Dispatch, SetStateAction, useMemo} from "react"; |
| 4 | import {RequestPayload, ResponsePayload} from "~hooks/useRequests"; | 3 | import {RequestPayload, ResponsePayload} from "~hooks/useRequests"; |
| 5 | import { | ||
| 6 | Dispatch, | ||
| 7 | forwardRef, SetStateAction, | ||
| 8 | useEffect, | ||
| 9 | useImperativeHandle, | ||
| 10 | useMemo, | ||
| 11 | useRef, | ||
| 12 | useState | ||
| 13 | } from "react"; | ||
| 14 | import ReactJson from 'react-json-view'; | 4 | import ReactJson from 'react-json-view'; |
| 15 | import styles from './Content.module.scss'; | 5 | import styles from './Content.module.scss'; |
| 16 | import {Col, Container, Row} from "react-bootstrap"; | 6 | import {Button, Col, Container, Row} from "react-bootstrap"; |
| 17 | 7 | ||
| 18 | function getHeader(headers: { [key: string]: string }, key: string, unit?: string): string | null { | 8 | function 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 | ||
| 38 | export default function Content({ raw, setRaw, data }: ContentProps): JSX.Element { | 28 | export 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)) { |
