From d88d0a1174dd562c08c1826f157bdd1640efad11 Mon Sep 17 00:00:00 2001 From: Vasily Zubarev Date: Thu, 10 Apr 2025 11:58:28 +0200 Subject: [PATCH] chore: more linter errors --- app/(app)/transactions/page.tsx | 2 +- app/(auth)/signup/page.tsx | 3 +- app/landing/actions.ts | 2 +- app/landing/newsletter.tsx | 4 +- components/dashboard/welcome-widget.tsx | 11 +-- components/emails/email-layout.tsx | 5 +- .../emails/newsletter-welcome-email.tsx | 2 +- components/emails/otp-email.tsx | 2 +- components/files/screen-drop-area.tsx | 83 ++++++++++--------- components/forms/convert-currency.tsx | 8 +- components/forms/simple.tsx | 2 +- components/import/csv.tsx | 2 +- components/settings/crud.tsx | 1 - components/transactions/list.tsx | 2 +- 14 files changed, 67 insertions(+), 62 deletions(-) diff --git a/app/(app)/transactions/page.tsx b/app/(app)/transactions/page.tsx index 3a688f8..e1f7730 100644 --- a/app/(app)/transactions/page.tsx +++ b/app/(app)/transactions/page.tsx @@ -70,7 +70,7 @@ export default async function TransactionsPage({ searchParams }: { searchParams: {transactions.length === 0 && (

- You don't seem to have any transactions yet. Let's start and create the first one! + You don't seem to have any transactions yet. Let's start and create the first one!

diff --git a/app/(auth)/signup/page.tsx b/app/(auth)/signup/page.tsx index b1d0e6b..f11efd5 100644 --- a/app/(auth)/signup/page.tsx +++ b/app/(auth)/signup/page.tsx @@ -2,6 +2,7 @@ import SignupForm from "@/components/auth/signup-form" import { Card, CardContent, CardTitle } from "@/components/ui/card" import { ColoredText } from "@/components/ui/colored-text" import config from "@/lib/config" +import Image from "next/image" import { redirect } from "next/navigation" export default async function LoginPage() { @@ -11,7 +12,7 @@ export default async function LoginPage() { return ( - Logo + Logo TaxHacker: Cloud Edition diff --git a/app/landing/actions.ts b/app/landing/actions.ts index 2be5d7a..2b9243a 100644 --- a/app/landing/actions.ts +++ b/app/landing/actions.ts @@ -14,7 +14,7 @@ export async function subscribeToNewsletterAction(email: string) { }) if (existingContacts.data) { - const existingContact = existingContacts.data.data.find((contact: any) => contact.email === email) + const existingContact = existingContacts.data.data.find((contact: { email: string }) => contact.email === email) if (existingContact) { return { success: false, error: "You are already subscribed to the newsletter" } diff --git a/app/landing/newsletter.tsx b/app/landing/newsletter.tsx index 01347d9..1523ed6 100644 --- a/app/landing/newsletter.tsx +++ b/app/landing/newsletter.tsx @@ -34,8 +34,8 @@ export function NewsletterForm() {

Stay Tuned

- We're working hard on making TaxHacker useful for everyone. Subscribe to our emails to get notified about our - plans and new features. No marketing, ads or spam. + We're working hard on making TaxHacker useful for everyone. Subscribe to our emails to get notified about + our plans and new features. No marketing, ads or spam.

diff --git a/components/dashboard/welcome-widget.tsx b/components/dashboard/welcome-widget.tsx index 25e43f5..b351f09 100644 --- a/components/dashboard/welcome-widget.tsx +++ b/components/dashboard/welcome-widget.tsx @@ -5,6 +5,7 @@ import { getCurrentUser } from "@/lib/auth" import { getSettings, updateSettings } from "@/models/settings" import { Banknote, ChartBarStacked, FolderOpenDot, Key, TextCursorInput, X } from "lucide-react" import { revalidatePath } from "next/cache" +import Image from "next/image" import Link from "next/link" export async function WelcomeWidget() { @@ -13,11 +14,11 @@ export async function WelcomeWidget() { return ( - Logo + Logo
- Hey, I'm TaxHacker 👋 + Hey, I'm TaxHacker 👋

This code will expire in 10 minutes.

- If you didn't request this code, please ignore this email. + If you didn't request this code, please ignore this email.

) diff --git a/components/files/screen-drop-area.tsx b/components/files/screen-drop-area.tsx index 9dc49d1..972f2e7 100644 --- a/components/files/screen-drop-area.tsx +++ b/components/files/screen-drop-area.tsx @@ -5,7 +5,7 @@ import { uploadFilesAction } from "@/app/(app)/files/actions" import { uploadTransactionFilesAction } from "@/app/(app)/transactions/actions" import { AlertCircle, CloudUpload, Loader2 } from "lucide-react" import { useParams, useRouter } from "next/navigation" -import { startTransition, useEffect, useRef, useState } from "react" +import { startTransition, useCallback, useEffect, useRef, useState } from "react" export default function ScreenDropArea({ children }: { children: React.ReactNode }) { const router = useRouter() @@ -54,51 +54,54 @@ export default function ScreenDropArea({ children }: { children: React.ReactNode } } - const handleDrop = async (e: React.DragEvent) => { - e.preventDefault() - e.stopPropagation() + const handleDrop = useCallback( + async (e: React.DragEvent) => { + e.preventDefault() + e.stopPropagation() - // Reset counter and dragging state - dragCounter.current = 0 - setIsDragging(false) + // Reset counter and dragging state + dragCounter.current = 0 + setIsDragging(false) - const files = e.dataTransfer.files - if (files && files.length > 0) { - setIsUploading(true) - setUploadError("") + const files = e.dataTransfer.files + if (files && files.length > 0) { + setIsUploading(true) + setUploadError("") - try { - const formData = new FormData() - if (transactionId) { - formData.append("transactionId", transactionId as string) - } - for (let i = 0; i < files.length; i++) { - formData.append("files", files[i]) - } - - startTransition(async () => { - const result = transactionId - ? await uploadTransactionFilesAction(formData) - : await uploadFilesAction(formData) - - if (result.success) { - showNotification({ code: "sidebar.unsorted", message: "new" }) - setTimeout(() => showNotification({ code: "sidebar.unsorted", message: "" }), 3000) - if (!transactionId) { - router.push("/unsorted") - } - } else { - setUploadError(result.error ? result.error : "Something went wrong...") + try { + const formData = new FormData() + if (transactionId) { + formData.append("transactionId", transactionId as string) } + for (let i = 0; i < files.length; i++) { + formData.append("files", files[i]) + } + + startTransition(async () => { + const result = transactionId + ? await uploadTransactionFilesAction(formData) + : await uploadFilesAction(formData) + + if (result.success) { + showNotification({ code: "sidebar.unsorted", message: "new" }) + setTimeout(() => showNotification({ code: "sidebar.unsorted", message: "" }), 3000) + if (!transactionId) { + router.push("/unsorted") + } + } else { + setUploadError(result.error ? result.error : "Something went wrong...") + } + setIsUploading(false) + }) + } catch (error) { + console.error("Upload error:", error) setIsUploading(false) - }) - } catch (error) { - console.error("Upload error:", error) - setIsUploading(false) - setUploadError(error instanceof Error ? error.message : "Something went wrong...") + setUploadError(error instanceof Error ? error.message : "Something went wrong...") + } } - } - } + }, + [transactionId, router, showNotification] + ) // Add event listeners to document body useEffect(() => { diff --git a/components/forms/convert-currency.tsx b/components/forms/convert-currency.tsx index 2e3f4d5..4736486 100644 --- a/components/forms/convert-currency.tsx +++ b/components/forms/convert-currency.tsx @@ -16,10 +16,6 @@ export const FormConvertCurrency = ({ date?: Date | undefined onChange?: (value: number) => void }) => { - if (!originalTotal || !originalCurrencyCode || !targetCurrencyCode || originalCurrencyCode === targetCurrencyCode) { - return <> - } - const normalizedDate = startOfDay(date || new Date(Date.now() - 24 * 60 * 60 * 1000)) const normalizedDateString = format(normalizedDate, "yyyy-MM-dd") const [exchangeRate, setExchangeRate] = useState(0) @@ -54,6 +50,10 @@ export const FormConvertCurrency = ({ onChange?.(convertedTotal) }, [convertedTotal]) + if (!originalTotal || !originalCurrencyCode || !targetCurrencyCode || originalCurrencyCode === targetCurrencyCode) { + return <> + } + return (
{isLoading ? ( diff --git a/components/forms/simple.tsx b/components/forms/simple.tsx index 6386985..0a9d7e3 100644 --- a/components/forms/simple.tsx +++ b/components/forms/simple.tsx @@ -117,7 +117,7 @@ export const FormDate = ({ if (!isNaN(newDate.getTime())) { setDate(newDate) } - } catch (_) {} + } catch {} } return ( diff --git a/components/import/csv.tsx b/components/import/csv.tsx index 586e50d..907d381 100644 --- a/components/import/csv.tsx +++ b/components/import/csv.tsx @@ -36,7 +36,7 @@ export function ImportCSVTable({ fields }: { fields: Field[] }) { setColumnMappings([]) } } - }, [parseState]) + }, [parseState, fields]) useEffect(() => { if (saveState?.success) { diff --git a/components/settings/crud.tsx b/components/settings/crud.tsx index 0d9cd94..f85011d 100644 --- a/components/settings/crud.tsx +++ b/components/settings/crud.tsx @@ -270,7 +270,6 @@ export function CrudTable({ items, columns, on
) } - function itemDefaults(columns: CrudColumn[]) { return columns.reduce((acc, column) => { acc[column.key] = column.defaultValue as T[keyof T] diff --git a/components/transactions/list.tsx b/components/transactions/list.tsx index e41993c..a89fdd4 100644 --- a/components/transactions/list.tsx +++ b/components/transactions/list.tsx @@ -254,7 +254,7 @@ export function TransactionList({ transactions, fields = [] }: { transactions: T - {transactions.map((transaction: any) => ( + {transactions.map((transaction) => (