Fix admin page styling and user table

This commit is contained in:
Max Leiter 2022-11-14 17:32:32 -08:00
parent c5e276b51c
commit bc2a4acd29
6 changed files with 6 additions and 9 deletions

View file

@ -1,6 +1,5 @@
import Header from "@components/header"
import NewPost from "app/(posts)/new/components/new" import NewPost from "app/(posts)/new/components/new"
import "@styles/react-datepicker.css" import "./react-datepicker.css"
const New = () => <NewPost /> const New = () => <NewPost />

View file

@ -10,7 +10,6 @@ const UserTable = ({ users: initial }: { users: UserWithPosts[] }) => {
const [users, setUsers] = useState(initial) const [users, setUsers] = useState(initial)
const { setToast } = useToasts() const { setToast } = useToasts()
console.log(initial)
const toggleRole = async (id: string, role: "admin" | "user") => { const toggleRole = async (id: string, role: "admin" | "user") => {
const res = await fetch("/api/admin?action=toggle-role", { const res = await fetch("/api/admin?action=toggle-role", {
method: "POST", method: "POST",
@ -20,8 +19,6 @@ const UserTable = ({ users: initial }: { users: UserWithPosts[] }) => {
}) })
}) })
const json = await res.json()
if (res.status === 200) { if (res.status === 200) {
setToast({ setToast({
text: "Role updated", text: "Role updated",
@ -84,7 +81,7 @@ const UserTable = ({ users: initial }: { users: UserWithPosts[] }) => {
id: user.id, id: user.id,
displayName: user.displayName, displayName: user.displayName,
posts: user.posts?.length || 0, posts: user.posts?.length || 0,
createdAt: `${new Date(user.createdAt)} ${new Date( createdAt: `${new Date(user.createdAt).toLocaleDateString()} ${new Date(
user.createdAt user.createdAt
).toLocaleTimeString()}`, ).toLocaleTimeString()}`,
role: user.role, role: user.role,

View file

@ -26,7 +26,7 @@ const AdminPage = async () => {
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
alignItems: "center", alignItems: "center",
gap: 4 gap: "var(--gap)",
}} }}
> >
<UserTable users={users} /> <UserTable users={users} />

View file

@ -9,7 +9,7 @@ type Props = {
const SettingsGroup = ({ title, children }: Props) => { const SettingsGroup = ({ title, children }: Props) => {
return ( return (
<Fieldset> <Fieldset width={'100%'}>
<Fieldset.Content> <Fieldset.Content>
<Text h4>{title}</Text> <Text h4>{title}</Text>
</Fieldset.Content> </Fieldset.Content>

View file

@ -227,9 +227,10 @@ export const getAllUsers = async () => {
select: { select: {
id: true, id: true,
email: true, email: true,
// displayName: true,
role: true, role: true,
displayName: true,
posts: true, posts: true,
createdAt: true,
}, },
}) })