From a8696f3ff9f09b7d5ea32adb7c37be9cf4c632cd Mon Sep 17 00:00:00 2001 From: Bassgeta Date: Fri, 8 Aug 2025 11:26:46 +0200 Subject: [PATCH 1/3] feat: make the 404 page nicer and implement 404 handling for invoice me and invoices --- src/app/i/[id]/helpers.ts | 13 ++++++ src/app/i/[id]/page.tsx | 6 +-- src/app/invoices/[ID]/helpers.ts | 13 ++++++ src/app/invoices/[ID]/page.tsx | 3 +- src/app/not-found.tsx | 79 +++++++++++++++++++++++++++----- 5 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 src/app/i/[id]/helpers.ts create mode 100644 src/app/invoices/[ID]/helpers.ts diff --git a/src/app/i/[id]/helpers.ts b/src/app/i/[id]/helpers.ts new file mode 100644 index 0000000..8e972ec --- /dev/null +++ b/src/app/i/[id]/helpers.ts @@ -0,0 +1,13 @@ +import { isNotFoundError } from "@/lib/utils"; +import { api } from "@/trpc/server"; + +export async function getInvoiceMeLink(id: string) { + try { + return await api.invoiceMe.getById.query(id); + } catch (error) { + if (isNotFoundError(error)) { + return null; + } + throw error; + } +} diff --git a/src/app/i/[id]/page.tsx b/src/app/i/[id]/page.tsx index ea37a11..abd5531 100644 --- a/src/app/i/[id]/page.tsx +++ b/src/app/i/[id]/page.tsx @@ -3,11 +3,11 @@ import { Footer } from "@/components/footer"; import { Header } from "@/components/header"; import { InvoiceCreator } from "@/components/invoice-creator"; import { getInvoiceCount } from "@/lib/helpers/invoice"; -import { api } from "@/trpc/server"; import { ArrowLeft } from "lucide-react"; import type { Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; +import { getInvoiceMeLink } from "./helpers"; export const metadata: Metadata = { title: "Invoice Me | EasyInvoice", @@ -19,9 +19,7 @@ export default async function InvoiceMePage({ }: { params: { id: string }; }) { - // TODO solve unauthenticated access - // TODO solve not found error like the subscription plan page - const invoiceMeLink = await api.invoiceMe.getById.query(params.id); + const invoiceMeLink = await getInvoiceMeLink(params.id); if (!invoiceMeLink) { notFound(); diff --git a/src/app/invoices/[ID]/helpers.ts b/src/app/invoices/[ID]/helpers.ts new file mode 100644 index 0000000..4d28d97 --- /dev/null +++ b/src/app/invoices/[ID]/helpers.ts @@ -0,0 +1,13 @@ +import { isNotFoundError } from "@/lib/utils"; +import { api } from "@/trpc/server"; + +export async function getInvoice(id: string) { + try { + return await api.invoice.getById.query(id); + } catch (error) { + if (isNotFoundError(error)) { + return null; + } + throw error; + } +} diff --git a/src/app/invoices/[ID]/page.tsx b/src/app/invoices/[ID]/page.tsx index 107080b..57132ec 100644 --- a/src/app/invoices/[ID]/page.tsx +++ b/src/app/invoices/[ID]/page.tsx @@ -9,6 +9,7 @@ import { formatDate } from "@/lib/date-utils"; import { api } from "@/trpc/server"; import type { Metadata } from "next"; import { notFound } from "next/navigation"; +import { getInvoice } from "./helpers"; export const metadata: Metadata = { title: "Invoice Payment | EasyInvoice", description: "Process payment for your invoice", @@ -25,7 +26,7 @@ export default async function PaymentPage({ }: { params: { ID: string }; }) { - const invoice = await api.invoice.getById.query(params.ID); + const invoice = await getInvoice(params.ID); if (!invoice) { notFound(); diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index aa8187f..cf8db3a 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,25 +1,82 @@ +import { DollarSign, FileText, Home, Wallet, Zap } from "lucide-react"; import Link from "next/link"; export default function NotFound() { return ( -
-
+
+
-

404

-

- Not Found -

-

- Sorry, we couldn't find the page you're looking for. +

+ EI +
+
+ +
+

404

+
+ + + Transaction Not Found + +
+

+ Looks like this page got lost in the blockchain. Don't

+

worry, your funds are safe!

+
+ +
+ +
+ +
+

Payouts

+

+ Find your invoices and payments +

+ + + +
+ +
+

Create Invoice

+

Start a new payment request

+ + + +
+ +
+

+ Subscription Plans +

+

+ Manage your subscription plans +

+
- Go Home + + Back to Dashboard + +
+ Error Code: 0x404 • Block not found in this chain +
); From 6f99300fdabb688e944ff2ffc7e0562ac55511bb Mon Sep 17 00:00:00 2001 From: Bassgeta Date: Fri, 8 Aug 2025 11:53:36 +0200 Subject: [PATCH 2/3] fix: adapt 404 comments to make a bit more sense, remove the 0x404 nonsense --- src/app/not-found.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index cf8db3a..4967844 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -16,13 +16,15 @@ export default function NotFound() {
- Transaction Not Found + Page Not Found

- Looks like this page got lost in the blockchain. Don't + This page seems to have been sent to a non-existent wallet address. +

+

+ Don't worry, your invoices are safe and sound!{" "}

-

worry, your funds are safe!

@@ -35,7 +37,7 @@ export default function NotFound() {

Payouts

- Find your invoices and payments + Single, batch or recurring payouts

@@ -73,10 +75,6 @@ export default function NotFound() { Back to Dashboard - -
- Error Code: 0x404 • Block not found in this chain -
); From e801d8c0460d05b6cc39742d5295fd4394dbf8bd Mon Sep 17 00:00:00 2001 From: Bassgeta Date: Thu, 28 Aug 2025 09:38:51 +0200 Subject: [PATCH 3/3] feat: reword 404 page, add a11y, disable private links if user not logged in --- src/app/not-found.tsx | 91 ++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 28 deletions(-) diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 4967844..6ef2568 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,7 +1,10 @@ -import { DollarSign, FileText, Home, Wallet, Zap } from "lucide-react"; +import { getCurrentSession } from "@/server/auth"; +import { DollarSign, FileText, Home, Lock, Wallet, Zap } from "lucide-react"; import Link from "next/link"; -export default function NotFound() { +export default async function NotFound() { + const { user } = await getCurrentSession(); + return (
@@ -20,17 +23,17 @@ export default function NotFound() {

- This page seems to have been sent to a non-existent wallet address. + The page you're looking for doesn't exist or may have been moved.

- Don't worry, your invoices are safe and sound!{" "} + Your account and invoices remain secure.

@@ -41,36 +44,68 @@ export default function NotFound() {

- -
- + {user ? ( + +
+ +
+

+ Create Invoice +

+

+ Start a new payment request +

+ + ) : ( +
+
+ +
+

+ Sign in to create invoices +

+

+ Start a new payment request +

-

Create Invoice

-

Start a new payment request

- + )} - -
- + {user ? ( + +
+ +
+

+ Subscription Plans +

+

+ Manage your subscription plans +

+ + ) : ( +
+
+ +
+

+ Sign in to manage subscription plans +

+

+ View and manage your subscription options +

-

- Subscription Plans -

-

- Manage your subscription plans -

- + )}
Back to Dashboard