From 80c0f9740fdd9f0194311587e75828d8dd9efb20 Mon Sep 17 00:00:00 2001 From: Aamir Azad <82281117+aamirazad@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:30:26 +0530 Subject: [PATCH] refactor: use database types instead of manually typed types (#34) --- src/app/actions.ts | 8 +------- src/types/index.ts | 16 ++++++++-------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/app/actions.ts b/src/app/actions.ts index 0de7e09..8cc6c2b 100644 --- a/src/app/actions.ts +++ b/src/app/actions.ts @@ -5,14 +5,8 @@ import type { UsersTableType } from "@/server/db/schema"; import { users } from "@/server/db/schema"; import type { PaperlessDocumentsType } from "@/types"; import { auth } from "@clerk/nextjs/server"; -interface User { - userId: string; - fullName?: string; - paperlessURL?: string; - paperlessToken?: string; -} -export async function setUserProperty( +export async function setUserProperty( propertyName: K, value: UsersTableType[K], ) { diff --git a/src/types/index.ts b/src/types/index.ts index 63c4d7c..6966b0f 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -41,24 +41,24 @@ export type PaperlessDocumentsType = { all: number[]; results: { id: number; - correspondent: number; // Change type as per actual data or use a specific type/interface + correspondent: number; document_type: number; storage_path: number; title: string; content: string; tags: number[]; - created: string; // ISO 8601 date string - created_date: string; // Date string - modified: string; // ISO 8601 date string - added: string; // ISO 8601 date string - archive_serial_number: number; // Change type as per actual data or use a specific type/interface + created: string; + created_date: string; + modified: string; + added: string; + archive_serial_number: number; original_file_name: string; archived_file_name: string; owner: number; user_can_change: boolean; is_shared_by_requester: boolean; - notes: string[]; // Change type as per actual data or use a specific type/interface - custom_fields: string[]; // Change type as per actual data or use a specific type/interface + notes: string[]; + custom_fields: string[]; __search_hit__: { score: number; highlights: string;