-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
295 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
apps/dashboard/src/app/[locale]/(app)/preview/invoice/[id]/page.tsx
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
apps/dashboard/src/app/[locale]/(public)/i/[token]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { verify } from "@midday/invoice/token"; | ||
import { getInvoiceQuery } from "@midday/supabase/queries"; | ||
import { createClient } from "@midday/supabase/server"; | ||
import type { Metadata } from "next"; | ||
import { notFound } from "next/navigation"; | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: { params: { token: string } }): Promise<Metadata> { | ||
const supabase = createClient({ admin: true }); | ||
|
||
try { | ||
const { id } = await verify(params.token); | ||
const { data: invoice } = await getInvoiceQuery(supabase, id); | ||
|
||
if (!invoice) { | ||
return { | ||
title: "Invoice Not Found", | ||
robots: { | ||
index: false, | ||
follow: false, | ||
}, | ||
}; | ||
} | ||
|
||
return { | ||
title: `Invoice ${invoice.invoice_number} | ${invoice.team?.name}`, | ||
description: `Invoice for ${invoice.customer?.name || "Customer"}`, | ||
robots: { | ||
index: false, | ||
follow: false, | ||
}, | ||
}; | ||
} catch (error) { | ||
return { | ||
title: "Invalid Invoice", | ||
robots: { | ||
index: false, | ||
follow: false, | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
export default async function Page({ params }: { params: { token: string } }) { | ||
const supabase = createClient({ admin: true }); | ||
|
||
try { | ||
const { id } = await verify(params.token); | ||
console.log("katt", id); | ||
const { data: invoice } = await getInvoiceQuery(supabase, id); | ||
|
||
if (!invoice) { | ||
notFound(); | ||
} | ||
|
||
return <div>Invoice: {invoice.invoice_number}</div>; | ||
} catch (error) { | ||
notFound(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
import appIcon from "public/appicon.png"; | ||
|
||
export default function NotFound() { | ||
return ( | ||
<div className="h-screen flex flex-col items-center justify-center text-center text-sm text-[#606060]"> | ||
<Image | ||
src={appIcon} | ||
width={80} | ||
height={80} | ||
alt="Midday" | ||
quality={100} | ||
className="mb-10" | ||
/> | ||
<h2 className="text-xl font-semibold mb-2">Not Found</h2> | ||
<p className="mb-4">Could not find requested resource</p> | ||
<Link href="/" className="underline"> | ||
Return Home | ||
</Link> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.