From 4d656c19160f49c80becf75e82f247fedb713c0e Mon Sep 17 00:00:00 2001 From: Aamir Azad <82281117+aamirazad@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:17:28 +0530 Subject: [PATCH] refactor: fix eslint issues (#28) --- src/app/paperless/page.tsx | 5 +-- src/app/settings/page.tsx | 69 +------------------------------------ src/components/ui/form.tsx | 8 ++--- src/components/ui/input.tsx | 3 +- 4 files changed, 9 insertions(+), 76 deletions(-) diff --git a/src/app/paperless/page.tsx b/src/app/paperless/page.tsx index 4223dbe..2466303 100644 --- a/src/app/paperless/page.tsx +++ b/src/app/paperless/page.tsx @@ -11,6 +11,7 @@ import { FormField, FormItem, FormLabel, + FormMessage, } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -61,7 +62,7 @@ function DocumentsSearch() { return (
- + + )} /> @@ -90,7 +92,6 @@ function DocumentsPage() { queryKey: ["key", query], queryFn: async () => { if (!query) { - // Immediately resolve to null or an appropriate default value if there's no query return Promise.resolve(null); } const response = await getPaperlessDocuments(query); diff --git a/src/app/settings/page.tsx b/src/app/settings/page.tsx index b07545a..ef9feff 100644 --- a/src/app/settings/page.tsx +++ b/src/app/settings/page.tsx @@ -23,74 +23,6 @@ import { setUserProperty } from "../actions"; import { Toaster } from "@/components/ui/sonner"; import { toast } from "sonner"; -function FullName({ - setActiveTab, -}: { - setActiveTab: Dispatch>; -}) { - const { user, isLoaded } = useUser(); - const pathname = usePathname(); - const formSchema = z.object({ - FullName: z.string().min(1, { - message: "Required.", - }), - }); - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - FullName: "", - }, - }); - - if (!isLoaded) { - return Loading...; - } - - if (!user) { - return redirect("/sign-in?redirect=" + pathname); - } - - async function onSubmit(values: z.infer) { - setActiveTab((prevTab) => prevTab + 1); // Increment activeTab - try { - await setUserProperty("fullName", values.FullName); - // Operation succeeded, show success toast - toast("Your name preferences was saved"); - // Optionally, move to a new tab or take another action to indicate success - } catch { - // Operation failed, show error toast - toast("Uh oh! Something went wrong.", { - description: "Your name preferences were not saved.", - action: { - label: "Go back", - onClick: () => setActiveTab(0), // Go back to try again - }, - }); - } - } - - return ( - - - ( - - Full Name - - - - - - )} - /> - - - - ); -} - function PaperlessURL({ setActiveTab, }: { @@ -152,6 +84,7 @@ function PaperlessURL({ Leave empty to disable + )} /> diff --git a/src/components/ui/form.tsx b/src/components/ui/form.tsx index 0481e02..bcc3aed 100644 --- a/src/components/ui/form.tsx +++ b/src/components/ui/form.tsx @@ -1,11 +1,11 @@ import * as React from "react" -import * as LabelPrimitive from "@radix-ui/react-label" +import type * as LabelPrimitive from "@radix-ui/react-label" import { Slot } from "@radix-ui/react-slot" import { Controller, - ControllerProps, - FieldPath, - FieldValues, + type ControllerProps, + type FieldPath, + type FieldValues, FormProvider, useFormContext, } from "react-hook-form" diff --git a/src/components/ui/input.tsx b/src/components/ui/input.tsx index 3792d8b..071ee94 100644 --- a/src/components/ui/input.tsx +++ b/src/components/ui/input.tsx @@ -2,8 +2,7 @@ import * as React from "react" import { cn } from "@/lib/utils" -export interface InputProps - extends React.InputHTMLAttributes {} +export type InputProps = React.InputHTMLAttributes const Input = React.forwardRef( ({ className, type, ...props }, ref) => {