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
feat: add error handling page and update README resources (#43)
Vlad Sazonau6e3fffbecbe1
diff --git a/README.md b/README.mdindex 1a4c124..13a37fa 100644--- a/README.md+++ b/README.md@@ -2,3 +2,4 @@- https://www.loglib.io/s/pdf-invoice-editor for analytics- Generate beautiful OG images: https://og.new/+- UI components: https://originui.com/diff --git a/src/app/error.tsx b/src/app/error.tsxnew file mode 100644index 0000000..487fb66--- /dev/null+++ b/src/app/error.tsx@@ -0,0 +1,66 @@+"use client"; // Error boundaries must be Client Components++import { Button } from "@/components/ui/button";+import { CircleAlert } from "lucide-react";+import { useEffect } from "react";+import { toast } from "sonner";++export default function Error({+ error,+ reset,+}: {+ error: Error & { digest?: string };+ reset: () => void;+}) {+ useEffect(() => {+ // Log the error to an error reporting service+ console.error(error);++ toast.error(+ "Something went wrong! Please try to refresh the page or contact support.",+ {+ closeButton: true,+ richColors: true,+ }+ );+ }, [error]);++ return (+ <div className="flex h-dvh flex-col items-center justify-center gap-4">+ <div className="flex flex-col items-center justify-center gap-4">+ <ErrorMessage>+ Something went wrong. Please try to refresh the page or contact+ support via this{" "}+ <a href="mailto:[email protected]" className="underline">+ link+ </a>+ </ErrorMessage>+ <Button+ onClick={+ // Attempt to recover by trying to re-render the segment+ () => reset()+ }+ _variant="outline"+ >+ Try again+ </Button>+ </div>+ </div>+ );+}++function ErrorMessage({ children }: { children: React.ReactNode }) {+ return (+ <div className="rounded-lg border border-red-500/50 px-4 py-3 text-red-600">+ <p className="text-sm">+ <CircleAlert+ className="-mt-0.5 me-3 inline-flex opacity-60"+ size={16}+ strokeWidth={2}+ aria-hidden="true"+ />+ {children}+ </p>+ </div>+ );+}diff --git a/src/app/layout.tsx b/src/app/layout.tsxindex 750abec..2b5e687 100644--- a/src/app/layout.tsx+++ b/src/app/layout.tsx@@ -57,7 +57,8 @@ export default function RootLayout({webVitals: true,}}/>- <Toaster />+ {/* https://sonner.emilkowal.ski/ */}+ <Toaster visibleToasts={1} /></body></html>);