Skip to content

Commit

Permalink
refactor: fix eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aamirazad committed Jun 19, 2024
1 parent b33c5e4 commit 3bfda85
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/app/paperless/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
QueryClient,
} from "@tanstack/react-query";
import LoadingSpinner from "@/components/loading-spinner";
import { PaperlessDocumentsType } from "@/types";
import type { PaperlessDocumentsType } from "@/types";

const queryClient = new QueryClient();

Expand All @@ -34,7 +34,7 @@ function DocumentsSearch() {
const router = useRouter();
const pathname = usePathname();
const searchParams = useSearchParams();
const givenQuery = searchParams.get("query") || "";
const givenQuery = searchParams.get("query") ?? "";
// 1. Define your form.
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
Expand All @@ -54,9 +54,9 @@ function DocumentsSearch() {
);

function onSubmit(values: z.infer<typeof formSchema>) {
if (values["query"])
if (values.query)
router.replace(
pathname + "?" + createQueryString("query", values["query"]),
pathname + "?" + createQueryString("query", values.query),
);
}

Expand Down Expand Up @@ -91,7 +91,7 @@ function DocumentsPage() {
queryKey: ["key", query],
queryFn: async () => {
const response = await fetch("/api/paperless?query=" + query);
const data = (await response.json()) as PaperlessDocumentsType;
const data = await response.json() as PaperlessDocumentsType;
return data;
},
});
Expand Down
25 changes: 13 additions & 12 deletions src/app/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { Input } from "@/components/ui/input";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
import { useForm } from "react-hook-form";
import { Dispatch, SetStateAction, useState } from "react";
import type { Dispatch, SetStateAction } from "react";
import { useState } from "react";
import { useUser } from "@clerk/nextjs";
import { redirect, usePathname } from "next/navigation";
import LoadingSpinner from "@/components/loading-spinner";
Expand Down Expand Up @@ -56,7 +57,7 @@ function FullName({
async function onSubmit(values: z.infer<typeof formSchema>) {
setActiveTab((prevTab) => prevTab + 1); // Increment activeTab
try {
await setFullUserName(values["FullName"], user!.id);
await setFullUserName(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
Expand Down Expand Up @@ -120,13 +121,13 @@ function PaperlessURL({
}

async function onSubmit(values: z.infer<typeof formSchema>) {
if (values["URL"] == "") {
if (values.URL == "") {
setActiveTab((prevTab) => prevTab + 2); // Skip api key form
} else {
setActiveTab((prevTab) => prevTab + 1); // Increment activeTab
}
try {
await setPaperlessURL(values["URL"], user!.id);
await setPaperlessURL(values.URL);
// Operation succeeded, show success toast
toast("Your paperless URL preferences was saved");
// Optionally, move to a new tab or take another action to indicate success
Expand Down Expand Up @@ -193,7 +194,7 @@ function PaperlessToken({
setActiveTab((prevTab) => prevTab + 1); // Increment activeTab

try {
await setPaperlessToken(values["token"], user!.id);
await setPaperlessToken(values.token);
// Operation succeeded, show success toast
toast("Your paperless token preferences was saved");
} catch {
Expand Down Expand Up @@ -221,9 +222,9 @@ function PaperlessToken({
<Input {...field} />
</FormControl>
<FormDescription>
You can create (or re-create) an API token by opening the "My
Profile" link in the user dropdown found in the web UI and
clicking the circular arrow button.
You can create (or re-create) an API token by opening the
&quot;My Profile&quot; link in the user dropdown found in the
web UI and clicking the circular arrow button.
</FormDescription>
</FormItem>
)}
Expand Down Expand Up @@ -271,10 +272,10 @@ export default function SettingsPage() {
const [activeTab, setActiveTab] = useState(0);

const formElements = [
<FullName setActiveTab={setActiveTab} />,
<PaperlessURL setActiveTab={setActiveTab} />,
<PaperlessToken setActiveTab={setActiveTab} />,
<Done />,
<FullName key="fullName" setActiveTab={setActiveTab} />,
<PaperlessURL key="paperlessURL" setActiveTab={setActiveTab} />,
<PaperlessToken key="paperlessToken" setActiveTab={setActiveTab} />,
<Done key="done" />,
];
return (
<>
Expand Down

0 comments on commit 3bfda85

Please sign in to comment.