Skip to content

Commit 1fbe029

Browse files
committed
Move Reminders to Tools
1 parent 2e45055 commit 1fbe029

5 files changed

Lines changed: 63 additions & 8 deletions

File tree

components/NavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState } from "react"
22
import FormattedLink from "./FormattedLink"
33

4-
const pages = ["Guides", "Characters", "Weapons", "Materials", "Artifacts", "Reminders"]
4+
const pages = ["Guides", "Characters", "Weapons", "Materials", "Artifacts", "Tools"]
55

66
export default function NavBar({ location }: {location: string}) {
77
const [menuOpen, setMenuOpen] = useState(false)

pages/api/oauth.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fetch from "node-fetch"
2-
import { serialize } from "cookie"
2+
import { parse, serialize } from "cookie"
33
import { config } from "../../utils/config"
44
import { sign } from "jsonwebtoken"
55
import { DiscordUser } from "../../utils/types"
@@ -66,5 +66,14 @@ export default async function api(req: NextApiRequest, res: NextApiResponse) {
6666
})
6767
)
6868

69-
res.redirect("/reminders")
69+
const cookie = req.headers.cookie
70+
if (cookie) {
71+
const parsed = parse(cookie)
72+
const path = parsed["oauth-redirect"]
73+
74+
if (path && path.startsWith("/"))
75+
return res.redirect(path)
76+
}
77+
78+
res.redirect("/tools")
7079
}

pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export default function Home({ location }: { location: string }) {
6868
<div className="grid items-center justify-around max-w-4xl mt-1">
6969
<div className="md:flex md:flex-row items-center max-w-4xl">
7070
<Card href="/guides" title="Guides &rarr;" desc="Find where those Specters are hiding" location={location} src={book} alsoSite />
71-
<Card href="/reminders" title="Reminders &rarr;" desc="Remind yourself of that Parametric Transformer you forgot for the 5th time" location={location} src={alarm} alsoSite="Can be managed on site as well" />
71+
<Card href="/tools/reminders" title="Reminders &rarr;" desc="Remind yourself of that Parametric Transformer you forgot for the 3rd time this month" location={location} src={alarm} alsoSite="Can be managed on site as well" />
7272
</div>
7373

7474
<div className="md:flex md:flex-row items-center max-w-4xl">

pages/tools/index.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Head from "next/head"
2+
import FormattedLink from "../../components/FormattedLink"
3+
import Main from "../../components/Main"
4+
5+
export default function Tools({ location }: {location: string}) {
6+
return (
7+
<Main>
8+
<Head>
9+
<title>Guides | Hu Tao</title>
10+
<meta name="twitter:card" content="summary" />
11+
<meta property="og:title" content="Guides | Hu Tao" />
12+
<meta property="og:description" content="View currently available guides and routes" />
13+
</Head>
14+
15+
<h1 className="text-5xl font-bold pb-2">
16+
Guides
17+
</h1>
18+
19+
<ul>
20+
<li>
21+
-{" "}
22+
<FormattedLink className="font-semibold text-xl" location={location} href="/tools/reminders" >
23+
Reminders
24+
</FormattedLink>
25+
<div className="ml-6">
26+
Reminders are send to your Discord DM&apos;s via the Discord bot. Please make sure you share at least one server with the Discord bot
27+
and have DM&apos;s enabled in that server. You can invite the bot to your own Discord server or join the support server via the links on
28+
the <FormattedLink location={location} href="/" >homepage</FormattedLink>.
29+
30+
</div>
31+
</li>
32+
</ul>
33+
</Main>
34+
)
35+
}
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { serialize } from "cookie"
12
import { GetServerSideProps } from "next"
23
import Head from "next/head"
34
import { Component } from "react"
4-
import Main from "../components/Main"
5-
import { config } from "../utils/config"
6-
import { parseUser } from "../utils/parse-user"
7-
import { DiscordUser, Reminder } from "../utils/types"
5+
import Main from "../../components/Main"
6+
import { config } from "../../utils/config"
7+
import { parseUser } from "../../utils/parse-user"
8+
import { DiscordUser, Reminder } from "../../utils/types"
89

910
interface Props {
1011
user: DiscordUser
@@ -77,6 +78,16 @@ export const getServerSideProps: GetServerSideProps<Props> = async function (ctx
7778
const user = parseUser(ctx.req.headers.cookie)
7879

7980
if (!user) {
81+
ctx.res.setHeader(
82+
"Set-Cookie",
83+
serialize("oauth-redirect", ctx.resolvedUrl, {
84+
httpOnly: true,
85+
secure: process.env.NODE_ENV !== "development",
86+
maxAge: 3600,
87+
sameSite: "lax",
88+
path: "/",
89+
}))
90+
8091
return {
8192
redirect: {
8293
destination: "/api/oauth",

0 commit comments

Comments
 (0)