The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
wip
Kiran Kc965fcf62173
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsxindex f973625624..feb2c07e9d 100644--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/[invoiceId]/route.tsx@@ -1,16 +1,43 @@import { DubApiError } from "@/lib/api/errors";import { withWorkspace } from "@/lib/auth";import { prisma } from "@dub/prisma";+import { currencyFormatter } from "@dub/utils";import {Document,+ Font,+ Image,Page,Text,View,renderToBuffer,} from "@react-pdf/renderer";+import { createTw } from "react-pdf-tailwind";++Font.register({+ family: "Open Sans",+ src: "https://fonts.gstatic.com/s/opensans/v18/mem8YaGs126MiZpBA-U1Ug.ttf", // URL to the font file+});export const dynamic = "force-dynamic";+const tw = createTw(+ {+ theme: {+ extend: {+ colors: {+ primary: "#000",+ },+ // fontFamily: {+ // sans: "Open Sans",+ // },+ },+ },+ },+ {+ ptPerRem: 12,+ },+);+export const GET = withWorkspace(async ({ workspace, params }) => {const { invoiceId } = params;@@ -30,20 +57,87 @@ export const GET = withWorkspace(async ({ workspace, params }) => {});}- if (invoice.status !== "completed") {- throw new DubApiError({- code: "unprocessable_entity",- message: "You can download the invoice once it is completed.",- });- }+ // if (invoice.status !== "completed") {+ // throw new DubApiError({+ // code: "unprocessable_entity",+ // message: "You can download the invoice once it is completed.",+ // });+ // }const pdf = await renderToBuffer(<Document>- <Page size="A4">- <View>- <Text>Invoice #{invoice.id}</Text>- <Text>Date: {invoice.createdAt.toLocaleDateString()}</Text>+ <Page size="A4" style={tw("p-20")}>+ <View style={tw("flex-row justify-between items-center")}>+ <Image+ src="https://dubassets.com/logos/clrei1gld0002vs9mzn93p8ik_384uSfo"+ style={tw("w-12 h-12")}+ />+ <View style={tw("text-right w-1/2")}>+ <Text style={tw("text-sm font-medium text-neutral-800")}>+ Dub Technologies Inc.+ </Text>+ <Text style={tw("text-sm text-neutral-500 ")}>[email protected]</Text>+ </View></View>++ <View style={tw("flex-col gap-2 text-sm mt-10 font-medium")}>+ <View style={tw("flex-row")}>+ <Text style={tw("text-neutral-500 w-1/5")}>Date</Text>+ <Text style={tw("text-neutral-800 w-4/5")}>+ {invoice.createdAt.toLocaleString("en-US", {+ month: "short",+ day: "2-digit",+ year: "numeric",+ hour: "2-digit",+ minute: "2-digit",+ second: "2-digit",+ hour12: true,+ })}+ </Text>+ </View>++ <View style={tw("flex-row")}>+ <Text style={tw("text-neutral-500 w-1/5")}>Receipt #</Text>+ <Text style={tw("text-neutral-800 w-4/5")}>3149-0001</Text>+ </View>++ <View style={tw("flex-row")}>+ <Text style={tw("text-neutral-500 w-1/5")}>Invoice #</Text>+ <Text style={tw("text-neutral-800 w-4/5")}>1354-2341-123</Text>+ </View>+ </View>++ <View+ style={tw(+ "flex-row justify-between mt-10 border border-neutral-200 rounded-xl",+ )}+ >+ <View style={tw("flex-col gap-2 w-1/2 p-4")}>+ <Text style={tw("text-neutral-500 font-normal text-sm")}>+ Payouts+ </Text>+ <Text style={tw("text-neutral-800 font-medium text-[16px]")}>+ {invoice.payouts.length}+ </Text>+ </View>++ <View+ style={tw(+ "flex-col items-start gap-2 border-l border-neutral-200 w-1/2 p-4",+ )}+ >+ <Text style={tw("text-neutral-500 font-normal text-sm")}>+ Total+ </Text>+ <Text style={tw("text-neutral-800 font-medium text-[16px]")}>+ {currencyFormatter(invoice.total / 100, {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })}+ </Text>+ </View>+ </View>+<View>{invoice.payouts.map((payout, index) => (<View@@ -52,7 +146,7 @@ export const GET = withWorkspace(async ({ workspace, params }) => {><Text>Description: {payout.description}</Text><Text>Quantity: {payout.quantity}</Text>- <Text>Price: {payout.total}</Text>+ <Text>Price: {payout.amount}</Text></View>))}</View>diff --git a/apps/web/package.json b/apps/web/package.jsonindex af771fe513..5f060f1018 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -3,7 +3,7 @@"private": true,"license": "AGPL-3.0-or-later","scripts": {- "dev": "concurrently --kill-others \"pnpm prisma:generate && next dev --turbo --port 8888\" \"pnpm prisma:generate && pnpm prisma:studio --browser none\" \"email dev --port 3333\"",+ "dev": "concurrently --kill-others \"pnpm prisma:generate && next dev --port 8888\" \"pnpm prisma:generate && pnpm prisma:studio --browser none\" \"email dev --port 3333\"","build": "pnpm prisma:generate && next build","lint": "next lint","start": "next start",@@ -97,6 +97,7 @@"react-hook-form": "^7.52.1","react-markdown": "^9.0.1","react-parallax-tilt": "^1.7.70",+ "react-pdf-tailwind": "^2.3.0","react-spring": "^9.5.5","react-textarea-autosize": "^8.4.0","react-tweet": "^3.1.1",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 10eaa82769..a20536e44c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -282,6 +282,9 @@ importers:react-parallax-tilt:specifier: ^1.7.70version: 1.7.70([email protected])([email protected])+ react-pdf-tailwind:+ specifier: ^2.3.0+ version: 2.3.0([email protected])react-spring:specifier: ^9.5.5version: 9.5.5(@react-three/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected])@@ -8256,12 +8259,30 @@ packages:dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-s78aDg0vDYaijU5lLOCsUD+qinQbfOvcNeaoX9AiE7+kZzzCo6B/nX+l48cmt9OosJmvZvE9DWR9cLhrhOi2pA==}+ dependencies:+ '@babel/runtime': 7.23.9+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-ICbIWR93PE6+xf2Xd/fXYO1dAuiOAJaszEuGGv3wp5lLSeeelDXlEYLh6R05okxh28YqMzc0Qd85x6n6MtaLUQ==}dependencies:'@babel/runtime': 7.23.9dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-Ud0EfZ2FwrbvwAWx8nz+KKLmiqACCH9a/N/xNDOja0e/YgSnqTpuyHegFBgIMKjuBtO5dNvkb4dXkxAhGe/ayw==}+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/types': 2.7.0+ cross-fetch: 3.2.0+ fontkit: 2.0.4+ is-url: 1.2.4+ transitivePeerDependencies:+ - encoding+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-s+0xrQabGoYDDZwVpz8PXp1ylwabqiMhzfyetvxBqjDuQ15PuoSkmUkKUOkfDzauuAqs0MLMvt+Pcv+NioLfzw==}dependencies:@@ -8271,6 +8292,17 @@ packages:is-url: 1.2.4dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-7iZDYZrZlJqNzS6huNl2XdMcLFUo68e6mOdzQeJ63d5eApdthhSHBnkGzHfLhH5t8DCpZNtClmklzuLL63ADfw==}+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/png-js': 2.3.1+ cross-fetch: 3.2.0+ jay-peg: 1.1.1+ transitivePeerDependencies:+ - encoding+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-Hd5F1LzjuzG4bL/ytaOYxwN/5ip8oFBYDHdpccOfYY87J/Ca7AL31SsuneLk9DtnwNM1BSAKXtBo/WDFY3r57A==}dependencies:@@ -8279,6 +8311,25 @@ packages:jay-peg: 1.1.1dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-lpPj/EJYHFOc0ALiJwLP09H28B4ADyvTjxOf67xTF+qkWd+dq1vg7dw3wnYESPnWk5T9NN+HlUenJqdYEY9AvA==}+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/fns': 2.2.1+ '@react-pdf/image': 2.3.6+ '@react-pdf/pdfkit': 3.2.0+ '@react-pdf/primitives': 3.1.1+ '@react-pdf/stylesheet': 4.3.0+ '@react-pdf/textkit': 4.4.1+ '@react-pdf/types': 2.7.0+ cross-fetch: 3.2.0+ emoji-regex: 10.4.0+ queue: 6.0.2+ yoga-layout: 2.0.1+ transitivePeerDependencies:+ - encoding+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-EvIRg/QGACGyDB/+N6OCpaxBg4r3dTF1sXEQev9yrunq+f5HpoGsYEGt+wC7I63Gbza+k2/+NqJitlsDRrt9nA==}dependencies:@@ -8295,6 +8346,18 @@ packages:yoga-layout: 3.2.1dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-OBfCcnTC6RpD9uv9L2woF60Zj1uQxhLFzTBXTdcYE9URzPE/zqXIyzpXEA4Vf3TFbvBCgFE2RzJ2ZUS0asq7yA==}+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/png-js': 2.3.1+ browserify-zlib: 0.2.0+ crypto-js: 4.2.0+ fontkit: 2.0.4+ jay-peg: 1.1.1+ vite-compatible-readable-stream: 3.6.1+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-HaaAoBpoRGJ6c1ZOANNQZ3q6Ehmagqa8n40x+OZ5s9HcmUviZ34SCm+QBa42s1o4299M+Lgw3UoqpW7sHv3/Hg==}dependencies:@@ -8307,12 +8370,22 @@ packages:vite-compatible-readable-stream: 3.6.1dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-pEZ18I4t1vAUS4lmhvXPmXYP4PHeblpWP/pAlMMRkEyP7tdAeHUN7taQl9sf9OPq7YITMY3lWpYpJU6t4CZgZg==}+ dependencies:+ browserify-zlib: 0.2.0+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-eSJnEItZ37WPt6Qv5pncQDxLJRK15eaRwPT+gZoujP548CodenOVp49GST8XJvKMFt9YqIBzGBV/j9AgrOQzVA==}dependencies:browserify-zlib: 0.2.0dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-miwjxLwTnO3IjoqkTVeTI+9CdyDggwekmSLhVCw+a/7FoQc+gF3J2dSKwsHvAcVFM0gvU8mzCeTofgw0zPDq0w==}+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-yp4E0rDL03NaUp/CnDBz3HQNfH2Mzdlgku57yhTMGNzetwB0NJusXcjYg5XsTGIXnR7Tv80JKI4O4ajj+oaLeQ==}dev: false@@ -8327,6 +8400,21 @@ packages:scheduler: 0.25.0-rc-603e6108-20241029dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-gFOpnyqCgJ6l7VzfJz6rG1i2S7iVSD8bUHDjPW9Mze8TmyksHzN2zBH3y7NbsQOw1wU6hN4NhRmslrsn+BRDPA==}+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/fns': 2.2.1+ '@react-pdf/primitives': 3.1.1+ '@react-pdf/textkit': 4.4.1+ '@react-pdf/types': 2.7.0+ abs-svg-path: 0.1.1+ color-string: 1.9.1+ normalize-svg-path: 1.1.0+ parse-svg-path: 0.1.2+ svg-arc-to-cubic-bezier: 3.2.0+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-5QJB9sS0uU5ALTLxrtT073VT1imZhrzuOun+7kvo0nykeAr9I4lv0Shmy8rS4QhpmXn8ASmhd17WjCVm4DcJlw==}dependencies:@@ -8342,6 +8430,28 @@ packages:svg-arc-to-cubic-bezier: 3.2.0dev: false+ /@react-pdf/[email protected]([email protected]):+ resolution: {integrity: sha512-O1N8q45bTs7YuC+x9afJSKQWDYQy2RjoCxlxEGdbCwP+WD5G6dWRUWXlc8F0TtzU3uFglYMmDab2YhXTmnVN9g==}+ peerDependencies:+ react: ^16.8.0 || ^17.0.0 || ^18.0.0+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/font': 2.5.2+ '@react-pdf/layout': 3.13.0+ '@react-pdf/pdfkit': 3.2.0+ '@react-pdf/primitives': 3.1.1+ '@react-pdf/render': 3.5.0+ '@react-pdf/types': 2.7.0+ events: 3.3.0+ object-assign: 4.1.1+ prop-types: 15.8.1+ queue: 6.0.2+ react: 18.2.0+ scheduler: 0.17.0+ transitivePeerDependencies:+ - encoding+ dev: false+/@react-pdf/[email protected]([email protected]):resolution: {integrity: sha512-SGaaVloGtBNCsgu7TrS9C8QrcMegqEzgaw2Y/DnpZJtru13WgBs+auM9ana58ytQ7PIMB1RYJtFVvYhM1hf/+w==}peerDependencies:@@ -8362,6 +8472,18 @@ packages:react: 18.2.0dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-x7IVZOqRrUum9quuDeFXBveXwBht+z/6B0M+z4a4XjfSg1vZVvzoTl07Oa1yvQ/4yIC5yIkG2TSMWeKnDB+hrw==}+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/fns': 2.2.1+ '@react-pdf/types': 2.7.0+ color-string: 1.9.1+ hsl-to-hex: 1.0.0+ media-engine: 1.0.3+ postcss-value-parser: 4.2.0+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-QOPCGzlTz+irGLXbsQtKkEqkf78n9l3hRU0Omkvpk/gwLf/IchBBt358dV6FEtc+ujMFEpN+a+fWSS6v2tB0AQ==}dependencies:@@ -8374,6 +8496,16 @@ packages:postcss-value-parser: 4.2.0dev: false+ /@react-pdf/[email protected]:+ resolution: {integrity: sha512-Jl9wdTqIvJ5pX+vAGz0EOhP7ut5Two9H6CzTKo/YYPeD79cM2yTXF3JzTERBC28y7LR0Waq9D2LHQjI+b/EYUQ==}+ dependencies:+ '@babel/runtime': 7.23.9+ '@react-pdf/fns': 2.2.1+ bidi-js: 1.0.3+ hyphen: 1.10.6+ unicode-properties: 1.4.1+ dev: false+/@react-pdf/[email protected]:resolution: {integrity: sha512-4GdDiPA9l+If203hkh48slvRQmcmM3ecPLFTpXNMPrep/3retgvxUEXKMxI+xKclpw8tMzK/W6Z4hN9DgnxWMg==}dependencies:@@ -12112,6 +12244,14 @@ packages:resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}dev: true+ resolution: {integrity: sha512-Q+xVJLoGOeIMXZmbUK4HYk+69cQH6LudR0Vu/pRm2YlU/hDV9CiS0gKUMaWY5f2NeUH9C1nV3bsTlCo0FsTV1Q==}+ dependencies:+ node-fetch: 2.7.0([email protected])+ transitivePeerDependencies:+ - encoding+ dev: false+resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}engines: {node: '>= 8'}@@ -19242,6 +19382,17 @@ packages:react-dom: 18.2.0([email protected])dev: false+ resolution: {integrity: sha512-RREimnynuF0WAsATdYWhJATY5oNAUp9Ib07JE3Pl5oQW07R5T002xjfXk06e9BPh50DvMm9qZkDglZ7u4xzySQ==}+ dependencies:+ '@react-pdf/renderer': 3.4.5([email protected])+ tailwindcss: 3.4.4+ transitivePeerDependencies:+ - encoding+ - react+ - ts-node+ dev: false+resolution: {integrity: sha512-I42jl7L3Ze6kZaq+7zXWSunBa3b1on5yfvUW6Eo/3fFOj6dZ5Bqmcd264nJbTK/gn1HjjILAjSwnZbV4RpSaNQ==}dependencies:@@ -20040,6 +20191,13 @@ packages:object-assign: 4.1.1dev: false+ resolution: {integrity: sha512-7rro8Io3tnCPuY4la/NuI5F2yfESpnfZyT6TtkXnSWVkcu0BCDJ+8gk5ozUaFaxpIyNuWAPXrH0yFcSi28fnDA==}+ dependencies:+ loose-envify: 1.4.0+ object-assign: 4.1.1+ dev: false+resolution: {integrity: sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==}dependencies:@@ -22846,6 +23004,10 @@ packages:engines: {node: '>=12.20'}dev: true+ resolution: {integrity: sha512-tT/oChyDXelLo2A+UVnlW9GU7CsvFMaEnd9kVFsaiCQonFAXd3xrHhkLYu+suwwosrAEQ746xBU+HvYtm1Zs2Q==}+ dev: false+resolution: {integrity: sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ==}dev: false