mirror of
https://github.com/wassname/Open-Assistant.git
synced 2026-08-12 11:40:44 +08:00
wip
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user