Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.
TypeScript fintechinvoiceinvoice-generatorinvoice-pdfinvoice-templateinvoicesnextjsopen-sourcequotesreactreact-pdf-rendererself-hostedshadcn-uitailwindcsstypescript
feat: Improve default settings for buyer and seller dialogs (#76)
Vlad Sazonauce8bcca7cb32
diff --git a/src/components/buyer-dialog.tsx b/src/components/buyer-dialog.tsxindex ef5f3cd..261b99d 100644--- a/src/components/buyer-dialog.tsx+++ b/src/components/buyer-dialog.tsx@@ -66,8 +66,9 @@ export function BuyerDialog({},});+ // by default, we want to apply the new buyer to the current invoiceconst [shouldApplyNewBuyerToInvoice, setShouldApplyNewBuyerToInvoice] =- useState(false);+ useState(true);function onSubmit(formValues: BuyerData) {try {@@ -149,7 +150,15 @@ export function BuyerDialog({}return (- <Dialog open={isOpen} onOpenChange={onClose}>+ <Dialog+ open={isOpen}+ onOpenChange={(open) => {+ if (!open) {+ onClose(false);+ form.reset();+ }+ }}+ ><DialogContent className="flex flex-col gap-0 overflow-y-visible p-0 sm:max-w-lg [&>button:last-child]:top-3.5"><DialogHeader className="border-b border-slate-200 px-6 py-4 dark:border-slate-800"><DialogTitle className="text-base">@@ -205,24 +214,6 @@ export function BuyerDialog({)}/>- <FormField- control={form.control}- name="email"- render={({ field }) => (- <FormItem>- <FormLabel>Email</FormLabel>- <FormControl>- <Input- {...field}- type="email"- placeholder="[email protected]"- />- </FormControl>- <FormMessage />- </FormItem>- )}- />-{/* VAT Number */}<div className="space-y-4"><div className="flex items-end justify-between">@@ -269,6 +260,24 @@ export function BuyerDialog({</div></div></div>++ <FormField+ control={form.control}+ name="email"+ render={({ field }) => (+ <FormItem>+ <FormLabel>Email</FormLabel>+ <FormControl>+ <Input+ {...field}+ type="email"+ placeholder="[email protected]"+ />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ /></form></Form>@@ -282,7 +291,7 @@ export function BuyerDialog({id="apply-buyer-to-current-invoice-switch"/><Label htmlFor="apply-buyer-to-current-invoice-switch">- Apply Buyer to current invoice+ Apply New Buyer to Current Invoice</Label></div></div>diff --git a/src/components/seller-dialog.tsx b/src/components/seller-dialog.tsxindex 2e68d7d..3571b34 100644--- a/src/components/seller-dialog.tsx+++ b/src/components/seller-dialog.tsx@@ -73,8 +73,9 @@ export function SellerDialog({},});+ // by default, we want to apply the new seller to the current invoiceconst [shouldApplyNewSellerToInvoice, setShouldApplyNewSellerToInvoice] =- useState(false);+ useState(true);function onSubmit(formValues: SellerData) {try {@@ -158,7 +159,15 @@ export function SellerDialog({}return (- <Dialog open={isOpen} onOpenChange={onClose}>+ <Dialog+ open={isOpen}+ onOpenChange={(open) => {+ if (!open) {+ onClose(false);+ form.reset();+ }+ }}+ ><DialogContent className="flex flex-col gap-0 overflow-y-visible p-0 sm:max-w-lg [&>button:last-child]:top-3.5"><DialogHeader className="border-b border-slate-200 px-6 py-4 dark:border-slate-800"><DialogTitle className="text-base">@@ -214,6 +223,50 @@ export function SellerDialog({)}/>+ <div className="flex items-end justify-between">+ <FormField+ control={form.control}+ name="vatNo"+ render={({ field }) => (+ <FormItem className="flex-1">+ <FormLabel>VAT Number</FormLabel>+ <FormControl>+ <Input {...field} placeholder="Enter VAT number" />+ </FormControl>+ <FormMessage />+ </FormItem>+ )}+ />++ {/* Show/Hide VAT Number Field in PDF */}+ <div className="ml-4 flex items-center gap-2">+ <FormField+ control={form.control}+ name="vatNoFieldIsVisible"+ render={({ field }) => (+ <FormItem>+ <div className="flex items-center gap-2">+ <Switch+ checked={field.value}+ onCheckedChange={field.onChange}+ id="vatNoFieldIsVisible"+ />+ <CustomTooltip+ trigger={+ <Label htmlFor="vatNoFieldIsVisible">+ Show in PDF+ </Label>+ }+ content='Show/Hide the "VAT Number" field in the PDF'+ className="z-[1000]"+ />+ </div>+ </FormItem>+ )}+ />+ </div>+ </div>+<FormFieldcontrol={form.control}name="email"@@ -234,50 +287,6 @@ export function SellerDialog({{/* VAT Number */}<div className="space-y-4">- <div className="flex items-end justify-between">- <FormField- control={form.control}- name="vatNo"- render={({ field }) => (- <FormItem className="flex-1">- <FormLabel>VAT Number</FormLabel>- <FormControl>- <Input {...field} placeholder="Enter VAT number" />- </FormControl>- <FormMessage />- </FormItem>- )}- />-- {/* Show/Hide VAT Number Field in PDF */}- <div className="ml-4 flex items-center gap-2">- <FormField- control={form.control}- name="vatNoFieldIsVisible"- render={({ field }) => (- <FormItem>- <div className="flex items-center gap-2">- <Switch- checked={field.value}- onCheckedChange={field.onChange}- id="vatNoFieldIsVisible"- />- <CustomTooltip- trigger={- <Label htmlFor="vatNoFieldIsVisible">- Show in PDF- </Label>- }- content='Show/Hide the "VAT Number" field in the PDF'- className="z-[1000]"- />- </div>- </FormItem>- )}- />- </div>- </div>-<div className="flex items-end justify-between"><FormFieldcontrol={form.control}@@ -387,7 +396,7 @@ export function SellerDialog({id="apply-seller-to-current-invoice-switch"/><Label htmlFor="apply-seller-to-current-invoice-switch">- Apply Seller to current invoice+ Apply New Seller to Current Invoice</Label></div></div>diff --git a/src/instrumentation.ts b/src/instrumentation.tsindex ecb6528..e2bf0b9 100644--- a/src/instrumentation.ts+++ b/src/instrumentation.ts@@ -1,11 +1,17 @@import * as Sentry from "@sentry/nextjs";export async function register() {- if (process.env.NEXT_RUNTIME === "nodejs") {+ if (+ process.env.NEXT_RUNTIME === "nodejs" &&+ process.env.NODE_ENV === "production"+ ) {await import("../sentry.server.config");}- if (process.env.NEXT_RUNTIME === "edge") {+ if (+ process.env.NEXT_RUNTIME === "edge" &&+ process.env.NODE_ENV === "production"+ ) {await import("../sentry.edge.config");}}