From 608e6a33d607163a723b1e312822ffa6ac5d7ca3 Mon Sep 17 00:00:00 2001 From: ymd <74826010+ymd1138@users.noreply.github.com> Date: Mon, 27 Mar 2023 21:54:45 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=AB=E3=82=BF=E6=A9=9F=E8=83=BD=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=EF=BC=88=E9=80=94=E4=B8=AD=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/users.tsx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pages/users.tsx b/pages/users.tsx index d380b0c..5833873 100644 --- a/pages/users.tsx +++ b/pages/users.tsx @@ -1,5 +1,6 @@ import { queryDb } from "@/util/db"; import { GetServerSideProps } from "next"; +import { useState } from "react"; import { Table } from "react-bootstrap"; import { User } from "./api/user"; @@ -7,16 +8,30 @@ type Props = { users: User[]; }; +type TableDataType = "id" | "icon" | "discord"; +const allTableDataTypes: TableDataType[] = ["id", "icon", "discord"]; const UsersPage = ({ users }: Props) => { + const [selectTypes, setSelectTypes] = useState([]); + const onCheckFilter = (checked: boolean, type: TableDataType) => { + if (checked) setSelectTypes([...selectTypes, type]); + else setSelectTypes(selectTypes.filter(t => t !== type)); + } return (
+ {allTableDataTypes.map(t => ( + <> + { onCheckFilter(e.target.checked, t) }} /> + {t} + + ))} { // 幅は調整中。細かい調整は後ほど。 } - + {selectTypes.indexOf("id") !== -1 ? : <>} + @@ -40,7 +55,8 @@ const UsersPage = ({ users }: Props) => { {users.map((user) => ( - + {selectTypes.indexOf("id") !== -1 ? : <>} +
IDID学籍番号 ユーザー名 学年
{user.id}{user.id}{user.studentNumber} {user.username} {user.schoolGrade}