diff --git a/packages/invoice/src/templates/html/components/editor-content.tsx b/packages/invoice/src/templates/html/components/editor-content.tsx index 7ed6d0dc5..e7f0c66a1 100644 --- a/packages/invoice/src/templates/html/components/editor-content.tsx +++ b/packages/invoice/src/templates/html/components/editor-content.tsx @@ -6,8 +6,6 @@ export function EditorContent({ content }: { content?: JSON }) { } return ( -
- {formatEditorToHtml(content)} -
+
{formatEditorToHtml(content)}
); } diff --git a/packages/invoice/src/templates/html/components/line-items.tsx b/packages/invoice/src/templates/html/components/line-items.tsx new file mode 100644 index 000000000..e0c390724 --- /dev/null +++ b/packages/invoice/src/templates/html/components/line-items.tsx @@ -0,0 +1,44 @@ +import { formatAmount } from "../../../utils/format"; +import type { LineItem } from "../../types"; +type Props = { + lineItems: LineItem[]; + currency: string; + descriptionLabel: string; + quantityLabel: string; + priceLabel: string; + totalLabel: string; +}; + +export function LineItems({ + lineItems, + currency, + descriptionLabel, + quantityLabel, + priceLabel, + totalLabel, +}: Props) { + return ( +
+
+
{descriptionLabel}
+
{priceLabel}
+
{quantityLabel}
+
+ {totalLabel} +
+
+ {lineItems.map((item, index) => ( +
+
{item.name}
+
+ {formatAmount({ currency, amount: item.price })} +
+
{item.quantity}
+
+ {formatAmount({ currency, amount: item.quantity * item.price })} +
+
+ ))} +
+ ); +} diff --git a/packages/invoice/src/templates/html/components/meta.tsx b/packages/invoice/src/templates/html/components/meta.tsx index 9821318ca..2174dd01e 100644 --- a/packages/invoice/src/templates/html/components/meta.tsx +++ b/packages/invoice/src/templates/html/components/meta.tsx @@ -1,5 +1,5 @@ -import type { Template } from "@midday/invoice/types"; import { format } from "date-fns"; +import type { Template } from "../../types"; type Props = { template: Template; diff --git a/packages/invoice/src/templates/html/index.tsx b/packages/invoice/src/templates/html/index.tsx index 35fe53154..7546a9da1 100644 --- a/packages/invoice/src/templates/html/index.tsx +++ b/packages/invoice/src/templates/html/index.tsx @@ -3,6 +3,7 @@ import type { TemplateProps } from "../types"; import { CustomerDetails } from "./components/customer-details"; import { EditorContent } from "./components/editor-content"; import { FromDetails } from "./components/from-details"; +import { LineItems } from "./components/line-items"; import { Logo } from "./components/logo"; import { Meta } from "./components/meta"; @@ -62,6 +63,14 @@ export function HtmlTemplate({ + +
+ +
); diff --git a/packages/invoice/src/templates/pdf/components/line-items.tsx b/packages/invoice/src/templates/pdf/components/line-items.tsx index 9a0b81e78..41acc36b3 100644 --- a/packages/invoice/src/templates/pdf/components/line-items.tsx +++ b/packages/invoice/src/templates/pdf/components/line-items.tsx @@ -1,6 +1,6 @@ import { Text, View } from "@react-pdf/renderer"; -import type { LineItem } from "../template/invoice"; -import { formatAmount } from "../utils/format"; +import { formatAmount } from "../../../utils/format"; +import type { LineItem } from "../../types"; type Props = { lineItems: LineItem[]; diff --git a/packages/invoice/src/utils/format.tsx b/packages/invoice/src/utils/format.tsx index 4d2f47e77..0e2d6b7ff 100644 --- a/packages/invoice/src/utils/format.tsx +++ b/packages/invoice/src/utils/format.tsx @@ -122,7 +122,10 @@ export function formatEditorToHtml(doc?: EditorDoc): JSX.Element | null { {doc.content.map((node, nodeIndex) => { if (node.type === "paragraph") { return ( -

+

{node.content?.map((inlineContent, inlineIndex) => { if (inlineContent.type === "text") { let style = "text-xs";