/
[redirect].tsx
94 lines (89 loc) · 3.04 KB
/
[redirect].tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import axios from "axios";
import { useRouter } from "next/router";
import { Player } from "@lottiefiles/react-lottie-player";
import Head from "next/head";
import { useState } from "react";
const Post = (props: { data: string }) => {
const router = useRouter();
const [error, setError] = useState(false);
const [errorMsg, setErrorMessage] = useState("");
const redirect = router.query.redirect;
axios
.get(`/api/redirect`, { params: { redirect } })
.then((response) => {
router.push(response.data);
})
.catch((err) => {
setError(true);
setErrorMessage("No such URL found");
});
return (
<>
<Head>
<title>{error ? errorMsg : props.data}</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className="h-screen flex flex-col justify-end items-center backgroundGradient">
<div className="h-[90%] w-[80%] rounded-t-3xl flex flex-col items-center justify-evenly">
{error ? (
<Player
autoplay
loop
src="https://assets10.lottiefiles.com/packages/lf20_qpwbiyxf.json"
style={{ height: "300px", width: "300px" }}
/>
) : (
<Player
autoplay
loop
src="https://assets8.lottiefiles.com/packages/lf20_ISCngv3FyB.json"
style={{ height: "300px", width: "300px" }}
/>
)}
<div
className={`font-semibold mt-5 text-transparent text-lg md:text-xl lg:text-3xl bg-clip-text ${
error
? "bg-red-600"
: "bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500"
} `}
>
{error ? errorMsg : props.data}
</div>
</div>
</main>
</>
);
};
export async function getServerSideProps() {
const message = [
"Swapping time and space...",
"Spinning violently around the y-axis...",
"Tokenizing real life...",
"Bending the spoon...",
"Filtering morale...",
"Don't think of purple hippos...",
"We need a new fuse...",
"Have a good day.",
"Upgrading Windows, your PC will restart several times. Sit back and relax.",
"640K ought to be enough for anybody",
"The architects are still drafting",
"The bits are breeding",
"We're building the buildings as fast as we can",
"Would you prefer chicken, steak, or tofu?",
"(Pay no attention to the man behind the curtain)",
"...and enjoy the elevator music...",
"Please wait while the little elves draw your map",
"Don't worry - a few bits tried to escape, but we caught them",
"Would you like fries with that?",
"Checking the gravitational constant in your locale...",
"Go ahead -- hold your breath!",
];
return {
props: {
data: message[Math.floor(Math.random() * message.length)],
},
};
}
export default Post;