diff --git a/src/pages/Admin.tsx b/src/pages/Admin.tsx index 9adb5ac..7ba8498 100644 --- a/src/pages/Admin.tsx +++ b/src/pages/Admin.tsx @@ -4,10 +4,11 @@ import { LinkButton, ResourceLoader, SubmitField, SubmitStatus } from "../lib/co import { ColumnDef, createSolidTable, flexRender, getCoreRowModel, getPaginationRowModel, Table } from "@tanstack/solid-table" import { api, Role, Room, Spare, SpareInitRequest, UserFulls, UserSetResponse } from "../api" import { WeekSelect } from "../lib/WeekSelect" -import { addDays, addWeeks, format, formatISODuration, intervalToDuration, parse } from "date-fns" +import { addDays, addWeeks, format, formatDate, formatISODuration, intervalToDuration, parse } from "date-fns" import { match } from "ts-pattern" -import { Signal } from "../util" +import { Signal, spare_end_time, spare_start_time } from "../util" import { Calendar, SpareDefaultTd } from "../component/Calendar" +import { zhCN } from "date-fns/locale" const TanstackTableContent = (props: { table: Table }) => <> @@ -372,6 +373,96 @@ const SpareManage: Component = () => { ) } +const SpareListManage = () => { + const week = new Signal(new Date()) + const [data] = createResource(week.get, async (week) => ({ + spares: (await api.spare_list({ + type: "Week", + content: format(week, "RRRR-'W'II"), + })).spares, + users: (await api.users_list({})).users, + })) + + + + const render = ({ spares, users }: { spares: Spare[], users: UserFulls }) => { + const columns: ColumnDef[] = [ + { + header: "琴房号", + cell: ({ row }) => ( + row.original.room + ), + }, + { + header: "日期", + cell: ({ row }) => ( + formatDate(spare_start_time(row.original), "LLLdo EEEE", { locale: zhCN }) + ), + }, + { + header: "开始时间", + cell: ({ row }) => ( + format(spare_start_time(row.original), "H:mm", { locale: zhCN }) + ), + }, + { + header: "结束时间", + cell: ({ row }) => ( + format(spare_end_time(row.original), "H:mm", { locale: zhCN }) + ), + }, + { + header: "预约人", + cell: ({ row }) => ( + + ), + }, + ] + const table = createSolidTable({ + get data() { + return spares + }, + columns, + getCoreRowModel: getCoreRowModel(), + }) + + return ( +
+ + +
+
+ ) + } + + return ( +
+
+ + +
+ +
+ ) +} + export const Admin: Component = () => { return MenuViewer([ { @@ -382,5 +473,9 @@ export const Admin: Component = () => { name: "琴房管理", component: SpareManage, }, + { + name: "琴表管理", + component: SpareListManage, + } ]) -} \ No newline at end of file +}