Fix more types
This commit is contained in:
parent
82aadd94f2
commit
0631ae3897
6 changed files with 12 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
import { Popover } from "@components/popover"
|
||||
import { codeFileExtensions } from "@lib/constants"
|
||||
import clsx from "clsx"
|
||||
import type { File } from "lib/server/prisma"
|
||||
import type { File, PostWithFiles } from "lib/server/prisma"
|
||||
import styles from "./dropdown.module.css"
|
||||
import buttonStyles from "@components/button/button.module.css"
|
||||
import { ChevronDown, Code, File as FileIcon } from "react-feather"
|
||||
|
@ -15,7 +15,7 @@ const FileDropdown = ({
|
|||
files,
|
||||
loading
|
||||
}: {
|
||||
files: File[]
|
||||
files: Pick<PostWithFiles, "files">["files"]
|
||||
loading?: boolean
|
||||
}) => {
|
||||
if (loading) {
|
||||
|
|
|
@ -5,8 +5,8 @@ import ButtonGroup from "@components/button-group"
|
|||
import FileDropdown from "app/(posts)/components/file-dropdown"
|
||||
import { Edit, ArrowUpCircle, Archive } from "react-feather"
|
||||
import styles from "./post-buttons.module.css"
|
||||
import { File } from "@prisma/client"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { PostWithFiles } from "@lib/server/prisma"
|
||||
|
||||
export const PostButtons = ({
|
||||
title,
|
||||
|
@ -16,7 +16,7 @@ export const PostButtons = ({
|
|||
parentId
|
||||
}: {
|
||||
title: string
|
||||
files?: File[]
|
||||
files?: Pick<PostWithFiles, "files">["files"]
|
||||
loading?: boolean
|
||||
postId?: string
|
||||
parentId?: string
|
||||
|
|
|
@ -7,3 +7,7 @@
|
|||
.table thead th {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.table .id {
|
||||
width: 10ch;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ export function UserTable({
|
|||
<tbody>
|
||||
{users?.map((user) => (
|
||||
<tr key={user.id}>
|
||||
<td>{user.name ? user.name : "no name"}</td>
|
||||
<td>{user.displayName ? user.displayName : "no name"}</td>
|
||||
<td>{user.email}</td>
|
||||
<td>{user.role}</td>
|
||||
<td className={styles.id}>{user.id}</td>
|
||||
|
@ -62,7 +62,7 @@ export function PostTable({
|
|||
{post.title}
|
||||
</a>
|
||||
</td>
|
||||
<td>{"author" in post ? post.author.name : "no author"}</td>
|
||||
<td>{"author" in post ? post.author?.name : "no author"}</td>
|
||||
<td>{post.createdAt.toLocaleDateString()}</td>
|
||||
<td>{post.visibility}</td>
|
||||
<td>{post.id}</td>
|
||||
|
@ -89,7 +89,7 @@ export default async function AdminPage() {
|
|||
const [users, posts] = await Promise.all([usersPromise, postsPromise])
|
||||
|
||||
return (
|
||||
<div className={styles.wrapper}>
|
||||
<div>
|
||||
<h1>Admin</h1>
|
||||
<h2>Users</h2>
|
||||
<UserTable users={users} />
|
||||
|
|
|
@ -6,7 +6,6 @@ import { useRouter } from "next/navigation"
|
|||
import styles from "./list-item.module.css"
|
||||
import Link from "@components/link"
|
||||
import type { PostWithFiles } from "@lib/server/prisma"
|
||||
import type { File } from "@lib/server/prisma"
|
||||
import Tooltip from "@components/tooltip"
|
||||
import Badge from "@components/badges/badge"
|
||||
import Card from "@components/card"
|
||||
|
@ -94,7 +93,7 @@ const ListItem = ({
|
|||
</>
|
||||
<hr />
|
||||
<>
|
||||
{post?.files?.map((file: File) => {
|
||||
{post?.files?.map((file: Pick<PostWithFiles, "files">["files"][0]) => {
|
||||
return (
|
||||
<div key={file.id}>
|
||||
<Link colored href={`/post/${post.id}#${file.title}`}>
|
||||
|
|
|
@ -189,8 +189,6 @@ export const getPostById = async (
|
|||
|
||||
if (post) {
|
||||
if ("files" in post) {
|
||||
// @ts-expect-error TODO: fix types so files can exist
|
||||
console.log(post.files)
|
||||
// @ts-expect-error TODO: fix types so files can exist
|
||||
post.files = post.files.map((file) => ({
|
||||
...file,
|
||||
|
|
Loading…
Reference in a new issue