Skip to content

Commit b246862

Browse files
committed
Using Database Schema Types
1 parent 1eb8e02 commit b246862

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/app/drive-contents.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { ChevronRight, Upload } from "lucide-react";
44
import Link from "next/link";
55

66
import { Button } from "~/components/ui/button";
7-
import type { files_table, folders_table } from "~/server/db/schema";
7+
import type { File, Folder } from "~/server/db/schema";
88

99
import { FileRow, FolderRow } from "./file-row";
1010

1111
export default function DriveContents(props: {
12-
files: (typeof files_table.$inferSelect)[];
13-
folders: (typeof folders_table.$inferSelect)[];
14-
parents: (typeof folders_table.$inferSelect)[];
12+
files: File[];
13+
folders: Folder[];
14+
parents: Folder[];
1515
}) {
1616
const handleUpload = () => {
1717
alert("Upload functionality would be implemented here");

src/app/file-row.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { FileIcon, Folder as FolderIcon } from "lucide-react";
22
import Link from "next/link";
33

4-
import type { files_table, folders_table } from "~/server/db/schema";
4+
import type { File, Folder } from "~/server/db/schema";
55

6-
export function FileRow(props: { file: typeof files_table.$inferSelect }) {
6+
export function FileRow(props: { file: File }) {
77
const { file } = props;
88

99
return (
@@ -29,9 +29,7 @@ export function FileRow(props: { file: typeof files_table.$inferSelect }) {
2929
);
3030
}
3131

32-
export function FolderRow(props: {
33-
folder: typeof folders_table.$inferSelect;
34-
}) {
32+
export function FolderRow(props: { folder: Folder }) {
3533
const { folder } = props;
3634

3735
return (

src/server/db/schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ export const folders_table = createTable(
3333
},
3434
(table) => [index("parent_index").on(table.parent)],
3535
);
36+
37+
export type File = typeof files_table.$inferSelect;
38+
export type Folder = typeof folders_table.$inferSelect;

0 commit comments

Comments
 (0)