Skip to content

Commit

Permalink
Merge pull request #296 from midday-ai/feature/invoice-initial-data
Browse files Browse the repository at this point in the history
Feature/invoice initial data
  • Loading branch information
pontusab authored Nov 7, 2024
2 parents f3988ec + e693642 commit 43d4fb5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
5 changes: 4 additions & 1 deletion apps/dashboard/src/components/invoice/note-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Controller, useFormContext } from "react-hook-form";
import { LabelInput } from "./label-input";

export function NoteDetails() {
const { control } = useFormContext();
const { control, watch } = useFormContext();
const id = watch("id");

const updateInvoiceTemplate = useAction(updateInvoiceTemplateAction);

Expand All @@ -29,6 +30,8 @@ export function NoteDetails() {
render={({ field }) => {
return (
<Editor
// NOTE: This is a workaround to get the new content to render
key={id}
initialContent={field.value}
onChange={field.onChange}
className="h-[78px]"
Expand Down
5 changes: 4 additions & 1 deletion apps/dashboard/src/components/invoice/payment-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Controller, useFormContext } from "react-hook-form";
import { LabelInput } from "./label-input";

export function PaymentDetails() {
const { control } = useFormContext();
const { control, watch } = useFormContext();
const id = watch("id");

const updateInvoiceTemplate = useAction(updateInvoiceTemplateAction);

Expand All @@ -28,6 +29,8 @@ export function PaymentDetails() {
name="payment_details"
render={({ field }) => (
<Editor
// NOTE: This is a workaround to get the new content to render
key={id}
initialContent={field.value}
onChange={field.onChange}
onBlur={(content) => {
Expand Down
16 changes: 0 additions & 16 deletions packages/invoice/src/templates/pdf/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import { getCdnUrl } from "@midday/utils/envs";
import { Document, Image, Page, Text, View } from "@react-pdf/renderer";
import QRCodeUtil from "qrcode";
import type { TemplateProps } from "../types";
Expand All @@ -10,20 +9,6 @@ import { PaymentDetails } from "./components/payment-details";
import { QRCode } from "./components/qr-code";
import { Summary } from "./components/summary";

// Font.register({
// family: "GeistMono",
// fonts: [
// {
// src: `${getCdnUrl()}/fonts/GeistMono/ttf/GeistMono-Regular.ttf`,
// fontWeight: 400,
// },
// {
// src: `${getCdnUrl()}/fonts/GeistMono/ttf/GeistMono-Medium.ttf`,
// fontWeight: 500,
// },
// ],
// });

export async function PdfTemplate({
invoice_number,
issue_date,
Expand Down Expand Up @@ -59,7 +44,6 @@ export async function PdfTemplate({
style={{
padding: 20,
backgroundColor: "#fff",
// fontFamily: "GeistMono",
color: "#000",
}}
>
Expand Down
6 changes: 0 additions & 6 deletions packages/ui/src/components/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ export function Editor({
},
});

useEffect(() => {
if (initialContent) {
editor?.commands.setContent(initialContent);
}
}, []);

if (!editor) return null;

return (
Expand Down

0 comments on commit 43d4fb5

Please sign in to comment.