From e2ec866fe1e066df7150d0d2abdb368e93d31ac5 Mon Sep 17 00:00:00 2001 From: mrevanzak Date: Sun, 30 Jun 2024 13:16:59 +0700 Subject: [PATCH] chore: fix lint --- .../web/src/app/(app)/@admin/documents/table.tsx | 16 +++++++--------- apps/web/src/app/api/documents/[fileId]/route.ts | 2 +- apps/web/src/components/sidebar/sidebar-user.tsx | 2 +- apps/web/src/components/theme-toggle.tsx | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/web/src/app/(app)/@admin/documents/table.tsx b/apps/web/src/app/(app)/@admin/documents/table.tsx index b2a0c48..37413d1 100644 --- a/apps/web/src/app/(app)/@admin/documents/table.tsx +++ b/apps/web/src/app/(app)/@admin/documents/table.tsx @@ -1,6 +1,7 @@ "use client"; import type { Document } from "@/server/api/routers/documents/documents.schema"; +import type { SortDescriptor } from "@nextui-org/react"; import React, { useMemo } from "react"; import Link from "next/link"; import { useSearchParams } from "next/navigation"; @@ -13,7 +14,6 @@ import { ModalFooter, ModalHeader, Pagination, - SortDescriptor, Spinner, Table, TableBody, @@ -71,9 +71,10 @@ export function DocumentsTable() { }); const filteredData = useMemo(() => { - if (sort) { - const { column, direction } = sort; - data?.sort((a, b) => { + const { column, direction } = sort; + + return data + ?.sort((a, b) => { switch (column) { case "name": return direction === "ascending" @@ -86,11 +87,8 @@ export function DocumentsTable() { default: return 0; } - }); - } - - return data - ?.filter( + }) + .filter( (file) => file.name.toLowerCase().includes(search.toLowerCase()) || file.filename.toLowerCase().includes(search.toLowerCase()), diff --git a/apps/web/src/app/api/documents/[fileId]/route.ts b/apps/web/src/app/api/documents/[fileId]/route.ts index 04935a1..4287cea 100644 --- a/apps/web/src/app/api/documents/[fileId]/route.ts +++ b/apps/web/src/app/api/documents/[fileId]/route.ts @@ -15,7 +15,7 @@ export async function GET(_: Request, context: { params: { fileId: string } }) { ); if (!res.ok) { - return await res.json(); + return res; } return new Response(await res.arrayBuffer(), { diff --git a/apps/web/src/components/sidebar/sidebar-user.tsx b/apps/web/src/components/sidebar/sidebar-user.tsx index 47e371b..af304a3 100644 --- a/apps/web/src/components/sidebar/sidebar-user.tsx +++ b/apps/web/src/components/sidebar/sidebar-user.tsx @@ -1,7 +1,7 @@ "use client"; import { useState } from "react"; -import { usePathname, useRouter, useSearchParams } from "next/navigation"; +import { useRouter, useSearchParams } from "next/navigation"; import { Drawer, DrawerContent, DrawerTrigger } from "@/components/drawer"; import { HistoryList } from "@/components/history-list"; import { api } from "@/trpc/react"; diff --git a/apps/web/src/components/theme-toggle.tsx b/apps/web/src/components/theme-toggle.tsx index 0f76df7..13a7ac0 100644 --- a/apps/web/src/components/theme-toggle.tsx +++ b/apps/web/src/components/theme-toggle.tsx @@ -37,7 +37,7 @@ export function ThemeToggle() { disallowEmptySelection selectionMode="single" selectedKeys={[theme ?? "system"]} - onSelectionChange={async (keys) => { + onSelectionChange={(keys) => { setTheme(Array.from(keys).at(0)?.toString() ?? "system"); }} >