pineafan | f5dd187 | 2023-02-28 17:33:16 +0000 | [diff] [blame] | 1 | import Axios from 'axios'; |
| 2 | import React from 'react'; |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame^] | 3 | import Message from '../../../Components/Transcripts/Message'; |
pineafan | f5dd187 | 2023-02-28 17:33:16 +0000 | [diff] [blame] | 4 | |
| 5 | function Index(props) { |
TheCodedProf | da197f2 | 2023-03-01 18:15:51 -0500 | [diff] [blame^] | 6 | return <div style={{overflowY: "scroll", overflowX: "hidden"}}> |
| 7 | <div style={{ |
| 8 | width: "100vw", |
| 9 | height: "40px", |
| 10 | backgroundColor: "#F27878", |
| 11 | display: "flex", |
| 12 | justifyContent: "left", |
| 13 | alignItems: "center", |
| 14 | paddingLeft: "25px", |
| 15 | color: "white", |
| 16 | fontSize: "1.5em", |
| 17 | }}>Transcript for: {props.data.for.username}#{props.data.for.discriminator} | In {<a href={`https://discord.com/channels/${props.data.guild}/${props.data.channel}`}>ChannelName</a>} | Type: {props.data.type}</div> |
| 18 | <div style={{ |
| 19 | width: "100vw", |
| 20 | backgroundColor: "var(--theme-ui-colors-background)", //Can we change this to be not black please. it's too contrast heavy |
| 21 | margintop: "-50px", |
| 22 | padding: "25px", |
| 23 | paddingTop: "10px", |
| 24 | transition: "all 0.3s ease-in-out" |
| 25 | }}> |
| 26 | { |
| 27 | props.data.messages.map((message, index) => { |
| 28 | return <Message key={index.toString()} message={message} /> |
| 29 | }) |
| 30 | } |
| 31 | </div> |
pineafan | f5dd187 | 2023-02-28 17:33:16 +0000 | [diff] [blame] | 32 | </div> |
pineafan | f5dd187 | 2023-02-28 17:33:16 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | export default Index; |
| 36 | export async function getServerSideProps(ctx) { |
| 37 | if(!ctx.query.code) { |
| 38 | return { |
| 39 | redirect: { |
| 40 | destination: '/nucleus/transcript/about', |
| 41 | permanent: true |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | let code; |
| 46 | try { |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 47 | code = (await Axios.get(`http://localhost:10000/transcript/${ctx.query.code}`)) |
pineafan | f5dd187 | 2023-02-28 17:33:16 +0000 | [diff] [blame] | 48 | } catch (e) { |
| 49 | return { |
| 50 | redirect: { |
| 51 | destination: '/nucleus/transcript/invalid', |
| 52 | permanent: true |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | return { |
| 57 | props: { |
TheCodedProf | c86e44b | 2023-02-28 17:30:57 -0500 | [diff] [blame] | 58 | data: code.data |
pineafan | f5dd187 | 2023-02-28 17:33:16 +0000 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | } |