This commit is contained in:
notmd
2023-01-16 12:27:40 +07:00
parent 51bbec0c49
commit b90ac368f7
3 changed files with 48 additions and 1 deletions
+25 -1
View File
@@ -1,9 +1,11 @@
import { Button, Container, FormControl, FormLabel, Input, Select, Stack, useToast } from "@chakra-ui/react";
import { Field, Form, Formik } from "formik";
import { InferGetServerSidePropsType } from "next";
import Head from "next/head";
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
import { useEffect } from "react";
import { useForm } from "react-hook-form";
import { getAdminLayout } from "src/components/Layout";
import { UserMessagesCell } from "src/components/UserMessagesCell";
import { post } from "src/lib/api";
@@ -11,7 +13,16 @@ import { oasstApiClient } from "src/lib/oasst_api_client";
import prisma from "src/lib/prismadb";
import useSWRMutation from "swr/mutation";
const ManageUser = ({ user }) => {
interface UserForm {
user_id: string;
id: string;
auth_method: string;
display_name: string;
role: string;
notes: string;
}
const ManageUser = ({ user }: InferGetServerSidePropsType<typeof getServerSideProps>) => {
const toast = useToast();
const router = useRouter();
const { data: session, status } = useSession();
@@ -51,6 +62,10 @@ const ManageUser = ({ user }) => {
},
});
const { register } = useForm<UserForm>({
defaultValues: user,
});
return (
<>
<Head>
@@ -105,6 +120,15 @@ const ManageUser = ({ user }) => {
</Button>
</Form>
</Formik>
<form>
<input type="hidden" readOnly {...register("user_id")}></input>
<input type="hidden" readOnly {...register("id")}></input>
<input type="hidden" readOnly {...register("auth_method")}></input>
<FormControl>
<FormLabel>Display Name</FormLabel>
<Input {...register("display_name")} isDisabled />
</FormControl>
</form>
</Container>
<UserMessagesCell path={`/api/admin/user_messages?user=${user.user_id}`} />
</Stack>