blob: 4b2389f28ee5b3b2c65253d0a42c716327acad35 [file] [log] [blame]
pineafanf5dd1872023-02-28 17:33:16 +00001import Axios from 'axios';
2import React from 'react';
TheCodedProf2a69bd92023-03-02 16:36:32 -05003import Message from '../../../../Components/Transcripts/Message';
pineafanf5dd1872023-02-28 17:33:16 +00004
5function Index(props) {
TheCodedProfda197f22023-03-01 18:15:51 -05006 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>
pineafanf5dd1872023-02-28 17:33:16 +000032 </div>
pineafanf5dd1872023-02-28 17:33:16 +000033}
34
35export default Index;
36export async function getServerSideProps(ctx) {
TheCodedProf2a69bd92023-03-02 16:36:32 -050037 if(!ctx.params.code) {
pineafanf5dd1872023-02-28 17:33:16 +000038 return {
39 redirect: {
40 destination: '/nucleus/transcript/about',
41 permanent: true
42 }
43 }
44 }
45 let code;
46 try {
TheCodedProf2a69bd92023-03-02 16:36:32 -050047 code = (await Axios.get(`http://localhost:10000/transcript/${ctx.params.code}`))
pineafanf5dd1872023-02-28 17:33:16 +000048 } catch (e) {
49 return {
50 redirect: {
51 destination: '/nucleus/transcript/invalid',
52 permanent: true
53 }
54 }
55 }
56 return {
57 props: {
TheCodedProfc86e44b2023-02-28 17:30:57 -050058 data: code.data
pineafanf5dd1872023-02-28 17:33:16 +000059 }
60 }
61}