-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/aliabb01/invoify
- Loading branch information
Showing
4 changed files
with
65 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ReactNode } from "react"; | ||
|
||
import { InvoiceType } from "@/app/types/types"; | ||
|
||
type InvoiceLayoutProps = { | ||
data: InvoiceType; | ||
children: ReactNode; | ||
}; | ||
|
||
export default function InvoiceLayout({ data, children }: InvoiceLayoutProps) { | ||
const { sender, receiver, details } = data; | ||
|
||
// Instead of fetching all fonts, get the specific one user selected | ||
const fontHref = details.signature?.fontFamily | ||
? `https://fonts.googleapis.com/css2?family=${details?.signature?.fontFamily}&display=swap` | ||
: ""; | ||
|
||
const head = ( | ||
<> | ||
{/* //! NOTE: This causes performance issues in production. (Estimated saving 1.38s) */} | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" | ||
rel="stylesheet" | ||
/> | ||
|
||
{details.signature?.fontFamily && ( | ||
<> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.googleapis.com" | ||
/> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.gstatic.com" | ||
crossOrigin="anonymous" | ||
/> | ||
<link href={fontHref} rel="stylesheet" /> | ||
</> | ||
)} | ||
</> | ||
); | ||
|
||
return ( | ||
<> | ||
{head} | ||
{children} | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import React from "react"; | ||
|
||
// Components | ||
import { InvoiceLayout } from "@/app/components"; | ||
|
||
// Helpers | ||
import { formatNumberWithCommas, isDataUrl } from "@/lib/helpers"; | ||
|
||
|
@@ -12,38 +15,8 @@ import { DATE_OPTIONS } from "@/lib/variables"; | |
const InvoiceTemplate = (data: InvoiceType) => { | ||
const { sender, receiver, details } = data; | ||
|
||
// Instead of fetching all fonts, get the specific one user selected | ||
const fontHref = details.signature?.fontFamily | ||
? `https://fonts.googleapis.com/css2?family=${details?.signature?.fontFamily}&display=swap` | ||
: ""; | ||
|
||
const heading = ( | ||
<> | ||
{/* //! NOTE: This causes performance issues in production. (Estimated saving 1.38s) */} | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" | ||
rel="stylesheet" | ||
/> | ||
|
||
{details.signature?.fontFamily && ( | ||
<> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.googleapis.com" | ||
/> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.gstatic.com" | ||
crossOrigin="anonymous" | ||
/> | ||
<link href={fontHref} rel="stylesheet" /> | ||
</> | ||
)} | ||
</> | ||
); | ||
const content = ( | ||
<> | ||
{heading} | ||
return ( | ||
<InvoiceLayout data={data}> | ||
<div | ||
style={{ | ||
position: "relative", | ||
|
@@ -348,10 +321,8 @@ const InvoiceTemplate = (data: InvoiceType) => { | |
) : null} | ||
</div> | ||
</div> | ||
</> | ||
</InvoiceLayout> | ||
); | ||
|
||
return <>{content}</>; | ||
}; | ||
|
||
export default InvoiceTemplate; |
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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import React from "react"; | ||
|
||
// Components | ||
import { InvoiceLayout } from "@/app/components"; | ||
|
||
// Helpers | ||
import { formatNumberWithCommas, isDataUrl } from "@/lib/helpers"; | ||
|
||
|
@@ -9,40 +12,10 @@ import { InvoiceType } from "@/app/types/types"; | |
// Variables | ||
import { DATE_OPTIONS } from "@/lib/variables"; | ||
|
||
const InvoiceTemplate2 = ({ sender, receiver, details }: InvoiceType) => { | ||
// const ReactDOMServer = (await import("react-dom/server")).default; | ||
|
||
// Instead of fetching all fonts, get the specific one user selected | ||
const fontHref = details.signature?.fontFamily | ||
? `https://fonts.googleapis.com/css2?family=${details?.signature?.fontFamily}&display=swap` | ||
: ""; | ||
|
||
const heading = ( | ||
<> | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" | ||
rel="stylesheet" | ||
/> | ||
|
||
{details.signature?.fontFamily && ( | ||
<> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.googleapis.com" | ||
/> | ||
<link | ||
rel="preconnect" | ||
href="https://fonts.gstatic.com" | ||
crossOrigin="anonymous" | ||
/> | ||
<link href={fontHref} rel="stylesheet" /> | ||
</> | ||
)} | ||
</> | ||
); | ||
const content = ( | ||
<> | ||
{heading} | ||
const InvoiceTemplate2 = (data: InvoiceType) => { | ||
const { sender, receiver, details } = data; | ||
return ( | ||
<InvoiceLayout data={data}> | ||
<div | ||
style={{ | ||
position: "relative", | ||
|
@@ -349,10 +322,8 @@ const InvoiceTemplate2 = ({ sender, receiver, details }: InvoiceType) => { | |
) : null} | ||
</div> | ||
</div> | ||
</> | ||
</InvoiceLayout> | ||
); | ||
|
||
return <>{content}</>; | ||
}; | ||
|
||
export default InvoiceTemplate2; |