Skip to content

Commit 89f3059

Browse files
add api route for going directly to a transcript (#17)
Co-authored-by: israel.aristide <israel.aristide@plusgrade.com>
1 parent b4d8ade commit 89f3059

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { SIDEBAR_COOKIE_MAX_AGE, SIDEBAR_COOKIE_NAME } from "@/components/unity/team-switcher"
2+
import { BASE_URI, USE_HTTPS } from "@/lib/definitions"
3+
import { NextResponse } from "next/server"
4+
5+
6+
async function GetTranscript( req: Request,
7+
{ params } : { params: Promise<{id: string, guild: string}> }
8+
) {
9+
10+
const { id, guild } = (await params)
11+
12+
const response = NextResponse.redirect(`http${USE_HTTPS? 's': ''}://${BASE_URI}/dashboard/transcripts/${id}`)
13+
14+
response.cookies.set({
15+
name: SIDEBAR_COOKIE_NAME,
16+
value: guild,
17+
maxAge: SIDEBAR_COOKIE_MAX_AGE,
18+
httpOnly: true,
19+
sameSite: "strict",
20+
});
21+
22+
return response
23+
24+
}
25+
26+
27+
export {
28+
GetTranscript as GET
29+
}

components/unity/team-switcher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import { useBackend } from "@/hooks/use-backend"
3131
import { useSelectedGuildState } from "@/hooks/use-selected-guild-state"
3232
import { useSearchParams } from "next/navigation"
3333

34-
const SIDEBAR_COOKIE_NAME = "sidebar-guild"
35-
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7
34+
export const SIDEBAR_COOKIE_NAME = "sidebar-guild"
35+
export const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 30
3636

3737
export function TeamSwitcher({
3838
teams,

0 commit comments

Comments
 (0)