refactor: consolidate admin/users management under /people
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import { notFound } from "next/navigation"
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { getI18n } from "@/i18n/server"
|
||||
import { getUserProfileById } from "@/services/user.service"
|
||||
|
||||
import EditUserForm from "../../_components/edit.user.form"
|
||||
import ResetUserPasswordForm from "../../_components/reset.user.password.form"
|
||||
import prisma from "@/lib/prisma"
|
||||
|
||||
export default async function EditUserPage({
|
||||
params,
|
||||
@@ -12,35 +8,15 @@ export default async function EditUserPage({
|
||||
params: Promise<{ userId: string }>
|
||||
}) {
|
||||
const { userId } = await params
|
||||
const user = await getUserProfileById(userId)
|
||||
const { dictionary } = await getI18n()
|
||||
const copy = dictionary.admin.users
|
||||
|
||||
if (!user) {
|
||||
notFound()
|
||||
const person = await prisma.person.findFirst({
|
||||
where: { userId },
|
||||
select: { id: true },
|
||||
})
|
||||
|
||||
if (!person) {
|
||||
redirect("/people")
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-8">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
<h1 className="text-2xl font-bold">{copy.edit.title}</h1>
|
||||
</div>
|
||||
<EditUserForm
|
||||
formCopy={copy.form}
|
||||
schemaCopy={copy.schema}
|
||||
roleLabels={copy.roles}
|
||||
submitButtonCopy={dictionary.common.submitButton}
|
||||
user={user}
|
||||
/>
|
||||
<section className="flex flex-col gap-4 border-t pt-6">
|
||||
<h2 className="text-xl font-semibold">{copy.resetPassword.title}</h2>
|
||||
<ResetUserPasswordForm
|
||||
formCopy={copy.resetPassword}
|
||||
schemaCopy={copy.schema}
|
||||
submitButtonCopy={dictionary.common.submitButton}
|
||||
userId={user.id}
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
redirect(`/people/${person.id}/edit`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user