-
Notifications
You must be signed in to change notification settings - Fork 21
/
page.tsx
44 lines (36 loc) · 1.08 KB
/
page.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
import * as React from "react";
// components
import { ChangeUsernameForm } from "~/app/(components)/change-username-form";
// utils
import {
getAuthedUser,
getSession,
redirectIfNotAuthed,
} from "~/app/(actions)/auth";
// types
import type { Metadata } from "next";
export const metadata: Metadata = {
title: "Account settings",
};
export default async function Page() {
await redirectIfNotAuthed("/settings/account");
const user = (await getAuthedUser())!;
const formData = await getSession().then((s) => s.getFormData());
return (
<div className="flex flex-col gap-4">
<section className="flex flex-col gap-4 md:gap-8">
<h2 className="text-3xl font-medium border-b border-neutral py-2.5">
Change username
</h2>
<p>
Changing your username means that all the mentions (
<strong>@{user.username}</strong>) would be lost
</p>
<ChangeUsernameForm
errors={formData?.errors}
defaultValue={formData?.data?.username?.toString() ?? user.username}
/>
</section>
</div>
);
}