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 "@styles/react-datepicker.css"
import "./react-datepicker.css"
const New = () => <NewPost />

View file

@ -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,

View file

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

View file

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

View file

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