Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.
TypeScript fintechinvoiceinvoice-generatorinvoice-pdfinvoice-templateinvoicesnextjsopen-sourcequotesreactreact-pdf-rendererself-hostedshadcn-uitailwindcsstypescript
refactor: standardize loading button text and timeout constant (#40)
Vlad Sazonau2716140844b1
diff --git a/src/app/components/invoice-form.tsx b/src/app/components/invoice-form.tsxindex ab4cc8a..ca35497 100644--- a/src/app/components/invoice-form.tsx+++ b/src/app/components/invoice-form.tsx@@ -28,6 +28,7 @@ import { z } from "zod";export const PDF_DATA_LOCAL_STORAGE_KEY = "invoicePdfData";export const PDF_DATA_FORM_ID = "pdfInvoiceForm";export const LOADING_TIMEOUT = 500;+export const LOADING_BUTTON_TEXT = "Generating Document...";const checkIfDateOnInvoiceIsInCurrentMonth = (date: string) => {const today = dayjs();@@ -225,7 +226,7 @@ export function InvoiceForm({}},// delay in ms- 400+ LOADING_TIMEOUT);// subscribe to form changes to regenerate pdf on every input changediff --git a/src/app/components/invoice-pdf-download-link.tsx b/src/app/components/invoice-pdf-download-link.tsxindex 6a0e9dc..66ea2b9 100644--- a/src/app/components/invoice-pdf-download-link.tsx+++ b/src/app/components/invoice-pdf-download-link.tsx@@ -7,7 +7,7 @@ import { InvoicePdfTemplate } from "./invoice-pdf-template";import { loglib } from "@loglib/tracker";import { cn } from "@/lib/utils";import { Loader2 } from "lucide-react";-import { LOADING_TIMEOUT } from "./invoice-form";+import { LOADING_BUTTON_TEXT, LOADING_TIMEOUT } from "./invoice-form";export function InvoicePDFDownloadLink({invoiceData,@@ -47,7 +47,7 @@ export function InvoicePDFDownloadLink({}}}className={cn(- "mb-4 h-[36px] w-full rounded-lg bg-slate-900 px-4 py-2 text-center text-sm font-medium text-slate-50 shadow-sm shadow-black/5 outline-offset-2 hover:bg-slate-900/90 focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 dark:bg-slate-50 dark:text-slate-900 dark:hover:bg-slate-50/90 lg:mb-0 lg:w-[190px]",+ "mb-4 h-[36px] w-full rounded-lg bg-slate-900 px-4 py-2 text-center text-sm font-medium text-slate-50 shadow-sm shadow-black/5 outline-offset-2 hover:bg-slate-900/90 focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 dark:bg-slate-50 dark:text-slate-900 dark:hover:bg-slate-50/90 lg:mb-0 lg:w-[210px]",{"pointer-events-none opacity-70": isLoading,}@@ -56,7 +56,7 @@ export function InvoicePDFDownloadLink({{isLoading ? (<span className="inline-flex items-center"><Loader2 className="mr-2 h-4 w-4 animate-spin" />- <span className="animate-pulse">Loading document...</span>+ <span className="animate-pulse">{LOADING_BUTTON_TEXT}</span></span>) : ("Download PDF"diff --git a/src/app/components/regenerate-invoice-button.tsx b/src/app/components/regenerate-invoice-button.tsxindex f126001..19e7a0d 100644--- a/src/app/components/regenerate-invoice-button.tsx+++ b/src/app/components/regenerate-invoice-button.tsx@@ -2,7 +2,11 @@import { Button } from "@/components/ui/button";import { CustomTooltip } from "@/components/ui/tooltip";-import { LOADING_TIMEOUT, PDF_DATA_FORM_ID } from "./invoice-form";+import {+ LOADING_BUTTON_TEXT,+ LOADING_TIMEOUT,+ PDF_DATA_FORM_ID,+} from "./invoice-form";import { InvoicePdfTemplate } from "./invoice-pdf-template";import { usePDF } from "@react-pdf/renderer";import type { InvoiceData } from "../schema";@@ -51,7 +55,7 @@ export function RegenerateInvoiceButton({{isLoading ? (<span className="inline-flex items-center"><Loader2 className="mr-2 h-4 w-4 animate-spin" />- <span className="animate-pulse">Loading document...</span>+ <span className="animate-pulse">{LOADING_BUTTON_TEXT}</span></span>) : ("Regenerate invoice"