pineafan | f5dd187 | 2023-02-28 17:33:16 +0000 | [diff] [blame^] | 1 | import Axios from 'axios'; |
| 2 | import React from 'react'; |
| 3 | |
| 4 | function Index(props) { |
| 5 | return <> |
| 6 | <div style={{ |
| 7 | width: "100vw", |
| 8 | height: "40px", |
| 9 | backgroundColor: "#F27878", |
| 10 | display: "flex", |
| 11 | justifyContent: "left", |
| 12 | alignItems: "center", |
| 13 | paddingLeft: "25px", |
| 14 | color: "white", |
| 15 | fontSize: "1.5em", |
| 16 | }}>Nucleus Transcripts</div> |
| 17 | <div style={{ |
| 18 | height: "100vw", |
| 19 | width: "100vw", |
| 20 | backgroundColor: "var(--theme-ui-colors-background)", |
| 21 | margintop: "-50px", |
| 22 | padding: "25px", |
| 23 | paddingTop: "10px", |
| 24 | transition: "all 0.3s ease-in-out" |
| 25 | }}> |
| 26 | <p>{props.humanReadable}</p> |
| 27 | </div> |
| 28 | </> |
| 29 | } |
| 30 | |
| 31 | export default Index; |
| 32 | export async function getServerSideProps(ctx) { |
| 33 | if(!ctx.query.code) { |
| 34 | return { |
| 35 | redirect: { |
| 36 | destination: '/nucleus/transcript/about', |
| 37 | permanent: true |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | let code; |
| 42 | try { |
| 43 | code = await Axios.get(`http://localhost:10000/transcript/${ctx.query.code}/human`); |
| 44 | } catch (e) { |
| 45 | return { |
| 46 | redirect: { |
| 47 | destination: '/nucleus/transcript/invalid', |
| 48 | permanent: true |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | return { |
| 53 | props: { |
| 54 | humanReadable: code.data |
| 55 | } |
| 56 | } |
| 57 | } |