File tree 3 files changed +86
-2
lines changed
3 files changed +86
-2
lines changed Original file line number Diff line number Diff line change
1
+ "use server"
2
+
3
+ export const postMailConfirmationToken = async ( token : string ) : Promise < any > => {
4
+ try {
5
+ const response = await fetch ( `${ process . env . CC_API_URL } /accounts/confirm-account` , {
6
+ method : "POST" ,
7
+ headers : {
8
+ "Content-Type" : "application/json" ,
9
+ } ,
10
+ body : JSON . stringify ( { token } ) ,
11
+ } ) ;
12
+
13
+ if ( ! response . ok ) {
14
+ const errorResponse = await response . json ( ) ;
15
+ if ( errorResponse . error ) {
16
+ if ( typeof errorResponse . error === 'string' ) {
17
+ return { error : errorResponse . error } ;
18
+ } else if ( errorResponse . error . token ) {
19
+ return { error : errorResponse . error . token . join ( ' ' ) } ;
20
+ } else if ( errorResponse . error . non_field_errors ) {
21
+ return { error : errorResponse . error . non_field_errors . join ( ' ' ) } ;
22
+ }
23
+ }
24
+ return { error : "An unexpected error occurred." } ;
25
+ }
26
+
27
+ return { success : true } ;
28
+ } catch ( error ) {
29
+ return { error : "An unexpected error occurred." } ;
30
+ }
31
+ } ;
Original file line number Diff line number Diff line change
1
+ "use client"
2
+ import { usePathname } from "next/navigation" ;
3
+ import { postMailConfirmationToken } from "./actions" ;
4
+ import React , { useEffect , useState } from "react" ;
5
+ import Panel from "../../common/uiLibrary/panel" ;
6
+ import ContactInformation from "../../(home)/contactInformation" ;
7
+
8
+ const MailConfirmationPage = ( ) => {
9
+ const [ response , setResponse ] = useState < { success ?: boolean ; error ?: string } > ( { } ) ;
10
+ const token = usePathname ( ) . split ( '/' ) . filter ( Boolean ) . pop ( ) ;
11
+
12
+ useEffect ( ( ) => {
13
+ const fetchData = async ( ) => {
14
+ if ( token ) {
15
+ return await postMailConfirmationToken ( token ) ;
16
+ }
17
+ } ;
18
+
19
+ fetchData ( ) . then ( r => {
20
+ setResponse ( r ) ;
21
+ } ) ;
22
+ } , [ ] ) ;
23
+
24
+ if ( ! token ) {
25
+ return < main >
26
+ </ main > ;
27
+ }
28
+
29
+ return (
30
+ < main className = "flex flex-col justify-between min-h-screen pt-8 pb-16 lg:pt-16 lg:pb-24" >
31
+ < div >
32
+ < Panel >
33
+ < div
34
+ className = "mb-4 text-4xl text-center font-extrabold leading-tight lg:mb-6 text-white" >
35
+ { response . success ? (
36
+ < h1 > Confirmation successful!</ h1 >
37
+ ) : (
38
+ < h1 > { response . error || 'Waiting for confirmation...' } </ h1 >
39
+ ) }
40
+ </ div >
41
+ </ Panel >
42
+ </ div >
43
+ < ContactInformation />
44
+ </ main >
45
+ ) ;
46
+ } ;
47
+
48
+ export default MailConfirmationPage ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import Clown from "./clown/clown";
4
4
import { Metadata } from "next" ;
5
5
import DefaultNavbar from "./common/defaultNavbar" ;
6
6
import { Analytics } from '@vercel/analytics/react' ;
7
+ import type { Viewport } from 'next'
7
8
8
9
export const metadata : Metadata = {
9
10
title : 'Unitystation - The Space Station 13 Remake Made in Unity' ,
@@ -20,9 +21,7 @@ export const metadata: Metadata = {
20
21
'roleplaying game' ,
21
22
] ,
22
23
description : 'Unitystation is a free and open-source chaotic multiplayer role-playing and simulation game made in Unity. Remake of the cult classic Space Station 13.' ,
23
- colorScheme : 'dark' ,
24
24
authors : { name : 'Unitystation Team' , url : 'https://github.com/unitystation' } ,
25
- viewport : { width : "device-width" , initialScale : 1 } ,
26
25
robots : { follow : true , index : true } ,
27
26
openGraph : {
28
27
type : 'website' ,
@@ -38,6 +37,12 @@ export const metadata: Metadata = {
38
37
}
39
38
}
40
39
40
+ export const viewport : Viewport = {
41
+ themeColor : 'black' ,
42
+ width : 'device-width' ,
43
+ initialScale : 1 ,
44
+ }
45
+
41
46
export default function RootLayout ( { children, } : { children : React . ReactNode ; } ) {
42
47
43
48
return (
You can’t perform that action at this time.
0 commit comments