From bc2a4acd29f04f8fba4d39a6f24c8f219f9eeea7 Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Mon, 14 Nov 2022 17:32:32 -0800 Subject: [PATCH] Fix admin page styling and user table --- client/app/(posts)/new/page.tsx | 3 +-- client/app/{styles => (posts)/new}/react-datepicker.css | 0 client/app/admin/components/user-table.tsx | 5 +---- client/app/admin/page.tsx | 2 +- client/app/components/settings-group/index.tsx | 2 +- client/lib/server/prisma.ts | 3 ++- 6 files changed, 6 insertions(+), 9 deletions(-) rename client/app/{styles => (posts)/new}/react-datepicker.css (100%) diff --git a/client/app/(posts)/new/page.tsx b/client/app/(posts)/new/page.tsx index 8e17ea00..647ca2dd 100644 --- a/client/app/(posts)/new/page.tsx +++ b/client/app/(posts)/new/page.tsx @@ -1,6 +1,5 @@ -import Header from "@components/header" import NewPost from "app/(posts)/new/components/new" -import "@styles/react-datepicker.css" +import "./react-datepicker.css" const New = () => diff --git a/client/app/styles/react-datepicker.css b/client/app/(posts)/new/react-datepicker.css similarity index 100% rename from client/app/styles/react-datepicker.css rename to client/app/(posts)/new/react-datepicker.css diff --git a/client/app/admin/components/user-table.tsx b/client/app/admin/components/user-table.tsx index 2eff11cf..a4246f54 100644 --- a/client/app/admin/components/user-table.tsx +++ b/client/app/admin/components/user-table.tsx @@ -10,7 +10,6 @@ const UserTable = ({ users: initial }: { users: UserWithPosts[] }) => { const [users, setUsers] = useState(initial) const { setToast } = useToasts() - console.log(initial) const toggleRole = async (id: string, role: "admin" | "user") => { const res = await fetch("/api/admin?action=toggle-role", { method: "POST", @@ -20,8 +19,6 @@ const UserTable = ({ users: initial }: { users: UserWithPosts[] }) => { }) }) - const json = await res.json() - if (res.status === 200) { setToast({ text: "Role updated", @@ -84,7 +81,7 @@ const UserTable = ({ users: initial }: { users: UserWithPosts[] }) => { id: user.id, displayName: user.displayName, posts: user.posts?.length || 0, - createdAt: `${new Date(user.createdAt)} ${new Date( + createdAt: `${new Date(user.createdAt).toLocaleDateString()} ${new Date( user.createdAt ).toLocaleTimeString()}`, role: user.role, diff --git a/client/app/admin/page.tsx b/client/app/admin/page.tsx index 26803b8d..0b1e2969 100644 --- a/client/app/admin/page.tsx +++ b/client/app/admin/page.tsx @@ -26,7 +26,7 @@ const AdminPage = async () => { display: "flex", flexDirection: "column", alignItems: "center", - gap: 4 + gap: "var(--gap)", }} > diff --git a/client/app/components/settings-group/index.tsx b/client/app/components/settings-group/index.tsx index 58269b3e..9872ad77 100644 --- a/client/app/components/settings-group/index.tsx +++ b/client/app/components/settings-group/index.tsx @@ -9,7 +9,7 @@ type Props = { const SettingsGroup = ({ title, children }: Props) => { return ( -
+
{title} diff --git a/client/lib/server/prisma.ts b/client/lib/server/prisma.ts index bdca7f06..f5227c90 100644 --- a/client/lib/server/prisma.ts +++ b/client/lib/server/prisma.ts @@ -227,9 +227,10 @@ export const getAllUsers = async () => { select: { id: true, email: true, - // displayName: true, role: true, + displayName: true, posts: true, + createdAt: true, }, })