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
wip
VladSez04437e829e68
diff --git a/.eslintrc.json b/.eslintrc.jsonindex 3722418..be86b00 100644--- a/.eslintrc.json+++ b/.eslintrc.json@@ -1,3 +1,6 @@{- "extends": ["next/core-web-vitals", "next/typescript"]+ "extends": ["next/core-web-vitals", "next/typescript"],+ "rules": {+ "no-console": ["warn", { "allow": ["error"] }]+ }}diff --git a/.npmrc b/.npmrcnew file mode 100644index 0000000..449691b--- /dev/null+++ b/.npmrc@@ -0,0 +1 @@+save-exact=true\ No newline at end of filediff --git a/.vscode/settings.json b/.vscode/settings.jsonnew file mode 100644index 0000000..25fa621--- /dev/null+++ b/.vscode/settings.json@@ -0,0 +1,3 @@+{+ "typescript.tsdk": "node_modules/typescript/lib"+}diff --git a/LICENSE b/LICENSEnew file mode 100644index 0000000..6b0531e--- /dev/null+++ b/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2024 Vlad Sazonau++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.\ No newline at end of filediff --git a/README.md b/README.mdindex e215bc4..3da5dbd 100644--- a/README.md+++ b/README.md@@ -1,36 +1,45 @@-This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).+## TODO-## Getting Started+- [] Add multiple items in invoice table and calculate total price and vat correctly, display pdf correctly+- [] BUG: type '15NP' or any Invalid input 'lol' in VAT input -> see error and can't clear input+- [] try to use 'update' from useFieldArray?-First, run the development server:+- [] Test with big values/numbers on the invoice, e.g. 1 000 000 (check if pdf is displayed correctly)+- [] Add error handling and error pages/messages+- [] Add link to github repo and make it open source+- [] Create a name for the project+- [] Add link to our prod website in the footer of pdf+- [] TEST EVERYTHING on chrome, safari, firefox and maybe on mobile?? + introduce beta testers (colleagues, friends, family)+- [] Deploy to Vercel+- [] Add email to contact us+- [] Update to next 15???+- Check https://x.com/levelsio/status/1860015822472905091-```bash-npm run dev-# or-yarn dev-# or-pnpm dev-# or-bun dev-```+(Payments)-Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.+- [] Introduce payments via stripe? https://chatgpt.com/c/673db98b-a860-8007-8b53-1d7e0a9f40c1 or https://polar.sh/+- [] Force to log in to download invoice? (for log in we can use https://github.com/vvo/iron-session)-You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.+(BUGS and improvements, double check everything also if we need this)-This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.+- [] BindingError issue https://github.com/diegomura/react-pdf/issues/2892+- [] smth is wrong with bold styles after downgrading deps+- [] Add a button to create a shareable link to invoice. Fix current logic, because now we always put all invoice data in url.+- [] do not save those things (in page.tsx) in local storage, because they are not needed to be saved, we need them to be recalculated every time for better UX:-## Learn More+ const today = dayjs().format("YYYY-MM-DD");+ const lastDayOfMonth = dayjs().endOf("month").format("YYYY-MM-DD");+ const invoiceCurrentMonthAndYear = dayjs().format("MM-YYYY");+ const paymentDue = dayjs(today).add(14, "days").format("YYYY-MM-DD");-To learn more about Next.js, take a look at the following resources:+(FONTS, check fonts here https://fontsource.org/)-- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.-- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.+- [] use https://next-international.vercel.app/docs for translations (i18n)?+- [] Add PL language and font that supports it, use https://www.npmjs.com/package/n2words or similar for numbers into words+- [] add new font to match afaktury.pl or at least supports polish language https://github.com/diegomura/react-pdf/issues/2675#issuecomment-2388723178 (FreeSans, FreeSansBold, Helvetica or just use Roboto https://fonts.google.com/?lang=pl_Latn&categoryFilters=Sans+Serif:%2FSans%2F*;Feeling:%2FExpressive%2FBusiness)-You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!+(OTHER)-## Deploy on Vercel--The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.--Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.+- [] cleanup code+- [] Move to SPA? vite or smth, because we have pure SPA+- [] Add more languages?diff --git a/next.config.mjs b/next.config.mjsindex 4678774..8eda3ae 100644--- a/next.config.mjs+++ b/next.config.mjs@@ -1,4 +1,8 @@/** @type {import('next').NextConfig} */-const nextConfig = {};+const nextConfig = {+ typescript: {+ ignoreBuildErrors: true,+ },+};export default nextConfig;diff --git a/package.json b/package.jsonindex ad4dea8..65dbf6a 100644--- a/package.json+++ b/package.json@@ -9,18 +9,29 @@"lint": "next lint"},"dependencies": {- "react": "^18",- "react-dom": "^18",- "next": "14.2.15"+ "@hookform/resolvers": "3.9.0",+ "@react-pdf/layout": "4.0.1",+ "@react-pdf/renderer": "4.0.1",+ "dayjs": "1.11.13",+ "lucide-react": "0.460.0",+ "lz-string": "1.5.0",+ "n2words": "1.21.0",+ "next": "14.2.15",+ "nuqs": "2.1.0",+ "react": "18.3.1",+ "react-dom": "18.3.1",+ "react-hook-form": "7.53.1",+ "use-debounce": "10.0.4",+ "zod": "3.23.8"},"devDependencies": {- "typescript": "^5",- "@types/node": "^20",- "@types/react": "^18",- "@types/react-dom": "^18",- "postcss": "^8",- "tailwindcss": "^3.4.1",+ "@types/node": "22.8.1",+ "@types/react": "18.3.12",+ "@types/react-dom": "18.3.1","eslint": "^8",- "eslint-config-next": "14.2.15"+ "eslint-config-next": "14.2.15",+ "postcss": "^8",+ "tailwindcss": "3.4.14",+ "typescript": "5.6.3"}}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex fdeb107..10ae8c4 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -8,24 +8,57 @@ importers:.:dependencies:+ '@hookform/resolvers':+ specifier: 3.9.0+ version: 3.9.0([email protected]([email protected]))+ '@react-pdf/layout':+ specifier: 4.0.1+ version: 4.0.1+ '@react-pdf/renderer':+ specifier: 4.0.1+ version: 4.0.1([email protected])+ dayjs:+ specifier: 1.11.13+ version: 1.11.13+ lucide-react:+ specifier: 0.460.0+ version: 0.460.0([email protected])+ lz-string:+ specifier: 1.5.0+ version: 1.5.0+ n2words:+ specifier: 1.21.0+ version: 1.21.0next:specifier: 14.2.15+ nuqs:+ specifier: 2.1.0+ version: 2.1.0([email protected]([email protected]([email protected]))([email protected]))([email protected])react:- specifier: ^18+ specifier: 18.3.1version: 18.3.1react-dom:- specifier: ^18+ specifier: 18.3.1version: 18.3.1([email protected])+ react-hook-form:+ specifier: 7.53.1+ version: 7.53.1([email protected])+ use-debounce:+ specifier: 10.0.4+ version: 10.0.4([email protected])+ zod:+ specifier: 3.23.8+ version: 3.23.8devDependencies:'@types/node':- specifier: ^20- version: 20.16.13+ specifier: 22.8.1+ version: 22.8.1'@types/react':- specifier: ^18- version: 18.3.11+ specifier: 18.3.12+ version: 18.3.12'@types/react-dom':- specifier: ^18+ specifier: 18.3.1version: 18.3.1eslint:specifier: ^8@@ -37,10 +70,10 @@ importers:specifier: ^8version: 8.4.47tailwindcss:- specifier: ^3.4.1+ specifier: 3.4.14version: 3.4.14typescript:- specifier: ^5+ specifier: 5.6.3version: 5.6.3packages:@@ -49,6 +82,10 @@ packages:resolution: {integrity: sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==}engines: {node: '>=10'}+ '@babel/[email protected]':+ resolution: {integrity: sha512-FDSOghenHTiToteC/QRlv2q3DhPZ/oOXTBoirfWNx1Cx3TMVcGWQtMMmQcSvb/JjpNeGzx8Pq/b4fKEJuWm1sw==}+ engines: {node: '>=6.9.0'}+'@eslint-community/[email protected]':resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==}engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}@@ -67,6 +104,11 @@ packages:resolution: {integrity: sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==}engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}+ '@hookform/[email protected]':+ resolution: {integrity: sha512-bU0Gr4EepJ/EQsH/IwEzYLsT/PEj5C0ynLQ4m+GSHS+xKH4TfSelhluTgOaoc4kA5s7eCsQbM4wvZLzELmWzUg==}+ peerDependencies:+ react-hook-form: ^7.0.0+'@humanwhocodes/[email protected]':resolution: {integrity: sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==}engines: {node: '>=10.10.0'}@@ -182,6 +224,44 @@ packages:resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}engines: {node: '>=14'}+ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-ICbIWR93PE6+xf2Xd/fXYO1dAuiOAJaszEuGGv3wp5lLSeeelDXlEYLh6R05okxh28YqMzc0Qd85x6n6MtaLUQ==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-/SYEud06maGQiAD0H6J5xnqigKm/FpLKqFYH6+2OjQ2tb32nnKqwqL3pS7glDTFYBJ11B6fVgSNex6tc1V8UDA==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-l4HV5NutPw52Wbuvxol0BiFc6TkKXK/kJNwVIElphw47nwfueLEjIfBxRTuOeHmpdibvEh3a5STwYmMTQjXSxg==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-3jNGBOvSD7THx+bePOGK/3LfuxKVHiVIhoE800mZZUJHstPLgRkh/elWdxr5MQgwGAi2GBCInnW6cso1wK0W2A==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-HaaAoBpoRGJ6c1ZOANNQZ3q6Ehmagqa8n40x+OZ5s9HcmUviZ34SCm+QBa42s1o4299M+Lgw3UoqpW7sHv3/Hg==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-eSJnEItZ37WPt6Qv5pncQDxLJRK15eaRwPT+gZoujP548CodenOVp49GST8XJvKMFt9YqIBzGBV/j9AgrOQzVA==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-yp4E0rDL03NaUp/CnDBz3HQNfH2Mzdlgku57yhTMGNzetwB0NJusXcjYg5XsTGIXnR7Tv80JKI4O4ajj+oaLeQ==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-gvrw4HM9RocuDLd+19cvP2xaSs3h4OgYn2N6VDXzj6LYQnoHBAazRV9qMpGi8FuNlQ3Va+s82R1ynXYMr0FXIg==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-c2jq72wCtYpwzQFAw5GMe2GZ9Pqdl2a9Sxf/8pw2YEWGzR8H/0YG3Pm+4ral3jmZtRq4KWyf9amCr94gotAbYA==}+ peerDependencies:+ react: ^16.8.0 || ^17.0.0 || ^18.0.0++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-FrJXUMsvSGee13gpL82HOhhk16y3IKxLmYvmJU1ZUo9Jm9pLydnHDPlSUDK+rKmxdSD2X+twUR7sv6FlrA5i+A==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-+K6zkF6lDXHIZZ9nNzplJ48IrjXNGQqVfO5v73AsutHbvx44E62t46EeoGLHsmjGeMG70TooSI1Mwq/7f/5tLw==}++ '@react-pdf/[email protected]':+ resolution: {integrity: sha512-7KrPPCpgRPKR+g+T127PE4bpw9Q84ZiY07EYRwXKVtTEVW9wJ5BZiF9smT9IvH19s+MQaDLmYRgjESsnqlyH0Q==}+'@rtsao/[email protected]':resolution: {integrity: sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==}@@ -191,14 +271,17 @@ packages:'@swc/[email protected]':resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==}+ '@swc/[email protected]':+ resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==}+'@swc/[email protected]':resolution: {integrity: sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==}'@types/[email protected]':resolution: {integrity: sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==}- '@types/[email protected]':- resolution: {integrity: sha512-GjQ7im10B0labo8ZGXDGROUl9k0BNyDgzfGpb4g/cl+4yYDWVKcozANF4FGr4/p0O/rAkQClM6Wiwkije++1Tg==}+ '@types/[email protected]':+ resolution: {integrity: sha512-k6Gi8Yyo8EtrNtkHXutUu2corfDf9su95VYVP10aGYMMROM6SAItZi0w1XszA6RtWTHSVp5OeFof37w0IEqCQg==}'@types/[email protected]':resolution: {integrity: sha512-hCZTSvwbzWGvhqxp/RqVqwU999pBf2vp7hzIjiYOsl8wqOmUxkQ6ddw1cV3l8811+kdUFus/q4d1Y3E3SyEifA==}@@ -206,8 +289,8 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-qW1Mfv8taImTthu4KoXgDfLuk4bydU6Q/TkADnDWWHwi4NX4BR+LWfTp2sVmTqRrsHvyDDTelgelxJ+SsejKKQ==}- '@types/[email protected]':- resolution: {integrity: sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ==}+ '@types/[email protected]':+ resolution: {integrity: sha512-D2wOSq/d6Agt28q7rSI3jhU7G6aiuzljDGZ2hTZHIkrTLUI+AF3WMeKkEZ9nN2fkBAlcktT6vcZjDFiIhMYEQw==}'@typescript-eslint/[email protected]':resolution: {integrity: sha512-phuB3hoP7FFKbRXxjl+DRlQDuJqhpOnm5MmtROXyWi3uS/Xg2ZXqiQfcG2BJHiN4QKyzdOJi3NEn/qTnjUlkmQ==}@@ -269,6 +352,9 @@ packages:'@ungap/[email protected]':resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}+ resolution: {integrity: sha512-d8XPSGjfyzlXC3Xx891DJRyZfqk5JU0BJrDQcsWomFIV1/BIzPW5HDH5iDdWpqWaav0YVIEzT1RHTwWr0FFshA==}+resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==}peerDependencies:@@ -364,6 +450,12 @@ packages:resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}+ resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}++ resolution: {integrity: sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==}+resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}engines: {node: '>=8'}@@ -378,6 +470,12 @@ packages:resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}engines: {node: '>=8'}+ resolution: {integrity: sha512-oTKjJdShmDuGW94SyyaoQvAjf30dZaHnjJ8uAF+u2/vGJkJbJPJAT1gDiOJP5v1Zb6f9KEyW/1HpuaWIXtGHPg==}++ resolution: {integrity: sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==}+resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==}engines: {node: '>=10.16.0'}@@ -408,6 +506,10 @@ packages:resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==}+ resolution: {integrity: sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w==}+ engines: {node: '>=0.8'}+resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}engines: {node: '>=7.0.0'}@@ -415,6 +517,9 @@ packages:resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==}+ resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==}+resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==}engines: {node: '>= 6'}@@ -422,10 +527,16 @@ packages:resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}+ resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==}+resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}engines: {node: '>= 8'}+ resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}+resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==}engines: {node: '>=4'}@@ -449,6 +560,9 @@ packages:resolution: {integrity: sha512-t/Ygsytq+R995EJ5PZlD4Cu56sWa8InXySaViRzw9apusqsOO2bQP+SbYzAhR0pFKoB+43lYy8rWban9JSuXnA==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==}+resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}peerDependencies:@@ -481,6 +595,9 @@ packages:resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q==}+resolution: {integrity: sha512-gxtyfqMg7GKyhQmb056K7M3xszy/myH8w+B4RT+QXBQsvAOdc3XymqDDPHx1BgPgsdAA5SIifona89YtRATDzw==}@@ -498,6 +615,9 @@ packages:resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}+ resolution: {integrity: sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==}+resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==}@@ -654,6 +774,10 @@ packages:resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}engines: {node: '>=0.10.0'}+ resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}+ engines: {node: '>=0.8.x'}+resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==}@@ -689,6 +813,9 @@ packages:resolution: {integrity: sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==}+ resolution: {integrity: sha512-syetQadaUEDNdxdugga9CpEYVaQIxOwk7GlwZWWZ19//qW4zE5bknOKeMBDYAASwnpaSHKJITRLMF9m1fp3s6g==}+resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}@@ -789,6 +916,15 @@ packages:resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-K6GVpucS5wFf44X0h2bLVRDsycgJmf9FF2elg+CrqD8GcFU8c6vYhgXn8NjUkFCwj+xDFb70qgLbTUm6sxwPmA==}++ resolution: {integrity: sha512-LgOWAkrN0rFaQpfdWBQlv/VhkOxb5AsBjk6NQVx4yEzWS923T07X0M1Y0VNko2H52HeSpZrZNNMJ0aFqsdVzQg==}++ resolution: {integrity: sha512-fXHXcGFTXOvZTSkPJuGOQf5Lv5T/R2itiiCVPg9LxAje5D00O0pP83yJShFq5V89Ly//Gt6acj7z8pbBr34stw==}+resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}engines: {node: '>= 4'}@@ -820,6 +956,9 @@ packages:resolution: {integrity: sha512-wcjaerHw0ydZwfhiKbXJWLDY8A7yV7KhjQOpb83hGgGfId/aQa4TOvwyzn2PuswW2gPCYEL/nEAiSVpdOj1lXw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==}+resolution: {integrity: sha512-Y1JXKrfykRJGdlDwdKlLpLyMIiWqWvuSd17TvZk68PLAOGOoF4Xyav1z0Xhoi+gCYjZVeC5SI+hYFOfvXmGRCA==}engines: {node: '>= 0.4'}@@ -917,6 +1056,9 @@ packages:resolution: {integrity: sha512-uZ25/bUAlUY5fR4OKT4rZQEBrzQWYV9ZJYGGsUmEJ6thodVJ1HX64ePQ6Z0qPWP+m+Uq6e9UugrE38jeYsDSMw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==}+resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==}engines: {node: '>= 0.4'}@@ -945,6 +1087,9 @@ packages:resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==}+ resolution: {integrity: sha512-WhyKySfx5CEFoKDnpmHyJUrpX5fUrr/X3kqVHISmiO9jrJC73RQBOAZJB8bDrWT4PHEkl0QgNZLlWJfAWAIFew==}+resolution: {integrity: sha512-2yTgeWTWzMWkHu6Jp9NKgePDaYHbntiwvYuuJLbbN9vl7DC9DvXKOB2BC3ZZ92D3cvV/aflH0osDfwpHepQ53w==}hasBin: true@@ -1012,6 +1157,18 @@ packages:resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}+ resolution: {integrity: sha512-BVtq/DykVeIvRTJvRAgCsOwaGL8Un3Bxh8MbDxMhEWlZay3T4IpEKDEpwt5KZ0KJMHzgm6jrltxlT5eXOWXDHg==}+ peerDependencies:+ react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0-rc++ resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}+ hasBin: true++ resolution: {integrity: sha512-aa5tG6sDoK+k70B9iEX1NeyfT8ObCKhNDs6lJVpwF6r8vhUfuKMslIcirq6HIUYuuUYLefcEQOn9bSBOvawtwg==}+resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==}engines: {node: '>= 8'}@@ -1034,12 +1191,19 @@ packages:resolution: {integrity: sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==}engines: {node: '>=16 || 14 >=14.17'}+ resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==}+resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==}+ resolution: {integrity: sha512-R+HAae+qVpgDsV2XFnELNmBk8fILv/epGVoCjvnF1+QfOlzX92Pe/zN4B1tOA17uOuR6A8ARSUbUpjUtTyiiNg==}+ engines: {node: ^18 || >=20}+resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==}engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}@@ -1066,10 +1230,37 @@ packages:sass:optional: true+ resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==}+ engines: {node: 4.x || >=6.0.0}+ peerDependencies:+ encoding: ^0.1.0+ peerDependenciesMeta:+ encoding:+ optional: true+resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}engines: {node: '>=0.10.0'}+ resolution: {integrity: sha512-r9KHKG2UUeB5LoTouwDzBy2VxXlHsiM6fyLQvnJa0S5hrhzqElH/CH7TUGhT1fVvIYBIKf3OpY4YJ4CK+iaqHg==}++ resolution: {integrity: sha512-bJvw3g7PlXkJTmVNRFL0RIcHi9etF5/rIkMv7li3mqLwRz6iVUIVoRwJzqY5XCNe18qS3wRxfeYzOJ/sYrh6Rg==}+ peerDependencies:+ '@remix-run/react': '>= 2'+ next: '>= 14.2.0'+ react: '>= 18.2.0'+ react-router-dom: '>= 6'+ peerDependenciesMeta:+ '@remix-run/react':+ optional: true+ next:+ optional: true+ react-router-dom:+ optional: true+resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}engines: {node: '>=0.10.0'}@@ -1128,10 +1319,19 @@ packages:resolution: {integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==}+ resolution: {integrity: sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==}++ resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}+resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}engines: {node: '>=6'}+ resolution: {integrity: sha512-JyPSBnkTJ0AI8GGJLfMXvKq42cj5c006fnLz6fXy6zfoVjJizi8BNTpu8on8ziI1cKy9d9DGNuY17Ce7wuejpQ==}+resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}engines: {node: '>=8'}@@ -1229,11 +1429,20 @@ packages:resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}+ resolution: {integrity: sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA==}+resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==}peerDependencies:react: ^18.3.1+ resolution: {integrity: sha512-6aiQeBda4zjcuaugWvim9WsGqisoUk+etmFEsSUMm451/Ic8L/UAb7sRtMj3V+Hdzm6mMjU1VhiSzYUZeBm0Vg==}+ engines: {node: '>=18.0.0'}+ peerDependencies:+ react: ^16.8.0 || ^17 || ^18 || ^19+resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}@@ -1252,10 +1461,17 @@ packages:resolution: {integrity: sha512-fmfw4XgoDke3kdI6h4xcUz1dG8uaiv5q9gcEwLS4Pnth2kxT+GZ7YehS1JTMGBQmtV7Y4GFGbs2re2NqhdozUg==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==}+resolution: {integrity: sha512-vqlC04+RQoFalODCbCumG2xIOvapzVMHwsyIGM/SIE8fRhFFsXeH8/QQ+s0T0kDAhKc4k30s73/0ydkHQz6HlQ==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==}+ engines: {node: '>=0.10.0'}+resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==}engines: {node: '>=4'}@@ -1271,6 +1487,9 @@ packages:resolution: {integrity: sha512-U7WjGVG9sH8tvjW5SmGbQuui75FiyjAX72HX15DwBBwF9dNiQZRQAg9nnPhYy+TUnE0+VcrttuvNI8oSxZcocA==}hasBin: true+ resolution: {integrity: sha512-gSfoiOEA0VPE6Tukkrr7I0RBdE0s7H1eFCDBk05l1KIQT1UIKNc5JZy6jdyW6eYH3aR3g5b3PuL77rq0hvwtAw==}+resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==}engines: {iojs: '>=1.0.0', node: '>=0.10.0'}@@ -1287,10 +1506,16 @@ packages:resolution: {integrity: sha512-vj6RsCsWBCf19jIeHEfkRMw8DPiBb+DMXklQ/1SGDHOMlHdPUkZXFQ2YdplS23zESTijAcurb1aSgJA3AgMu1Q==}engines: {node: '>=0.4'}+ resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}+resolution: {integrity: sha512-CdASjNJPvRa7roO6Ra/gLYBTzYzzPyyBXxIMdGW3USQLyjWEls2RgW5UBTXaQVp+OrpeCK3bLem8smtmheoRuw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-7rro8Io3tnCPuY4la/NuI5F2yfESpnfZyT6TtkXnSWVkcu0BCDJ+8gk5ozUaFaxpIyNuWAPXrH0yFcSi28fnDA==}+resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==}@@ -1327,6 +1552,9 @@ packages:resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==}engines: {node: '>=14'}+ resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==}+resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}engines: {node: '>=0.10.0'}@@ -1369,6 +1597,9 @@ packages:resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}+resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}engines: {node: '>=8'}@@ -1411,6 +1642,9 @@ packages:resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-djbJ/vZKZO+gPoSDThGNpKDO+o+bAeA4XQKovvkNCqnIS2t+S4qnLAGQhyyrulhCFRl1WWzAp0wUDV8PpTVU3g==}+resolution: {integrity: sha512-IcSvOcTRcUtQQ7ILQL5quRDg7Xs93PdJEk1ZLbhhvJc7uj/OAhYOnruEiwnGgBvUtaUAJ8/mhSw1o8L2jCiENA==}engines: {node: '>=14.0.0'}@@ -1430,10 +1664,16 @@ packages:resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==}+ resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==}+resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}engines: {node: '>=8.0'}+ resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}+resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==}engines: {node: '>=16'}@@ -1449,6 +1689,9 @@ packages:resolution: {integrity: sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==}+ resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}+resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==}engines: {node: '>= 0.8.0'}@@ -1484,12 +1727,34 @@ packages:resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}+ resolution: {integrity: sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg==}++ resolution: {integrity: sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==}+resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}+ resolution: {integrity: sha512-6Cf7Yr7Wk7Kdv77nnJMf6de4HuDE4dTxKij+RqE9rufDsI6zsbjyAxcH5y2ueJCQAnfgKbzXbZHYlkFwmBlWkw==}+ engines: {node: '>= 16.0.0'}+ peerDependencies:+ react: '*'+resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}+ resolution: {integrity: sha512-t20zYkrSf868+j/p31cRIGN28Phrjm3nRSLR2fyc2tiWi4cZGVdv68yNlwnIINTkMTmPoMiSlc0OadaO7DXZaQ==}+ engines: {node: '>= 6'}++ resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==}++ resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==}+resolution: {integrity: sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==}@@ -1534,10 +1799,20 @@ packages:resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}engines: {node: '>=10'}+ resolution: {integrity: sha512-auzJ8lEovThZIpR8wLGWNo/JEj4VTO79q9/gOJ0dWb3shAYPFdX3t9VN0fC0v+jeQF77STUdCzebLwRMqzn5gQ==}++ resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==}+snapshots:'@alloc/[email protected]': {}+ '@babel/[email protected]':+ dependencies:+ regenerator-runtime: 0.14.1+'@eslint-community/[email protected]([email protected])':dependencies:eslint: 8.57.1@@ -1561,6 +1836,10 @@ snapshots:'@eslint/[email protected]': {}+ dependencies:+ react-hook-form: 7.53.1([email protected])+'@humanwhocodes/[email protected]':dependencies:'@humanwhocodes/object-schema': 2.0.3@@ -1649,12 +1928,123 @@ snapshots:'@pkgjs/[email protected]':optional: true+ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0++ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/types': 2.7.0+ cross-fetch: 3.1.8+ fontkit: 2.0.4+ is-url: 1.2.4+ transitivePeerDependencies:+ - encoding++ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/png-js': 3.0.0+ cross-fetch: 3.1.8+ jay-peg: 1.1.0+ transitivePeerDependencies:+ - encoding++ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/fns': 3.0.0+ '@react-pdf/image': 3.0.0+ '@react-pdf/pdfkit': 4.0.0+ '@react-pdf/primitives': 4.0.0+ '@react-pdf/stylesheet': 5.0.0+ '@react-pdf/textkit': 5.0.0+ '@react-pdf/types': 2.7.0+ cross-fetch: 3.1.8+ emoji-regex: 10.4.0+ queue: 6.0.2+ yoga-layout: 3.1.0+ transitivePeerDependencies:+ - encoding++ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/png-js': 3.0.0+ browserify-zlib: 0.2.0+ crypto-js: 4.2.0+ fontkit: 2.0.4+ jay-peg: 1.1.0+ vite-compatible-readable-stream: 3.6.1++ '@react-pdf/[email protected]':+ dependencies:+ browserify-zlib: 0.2.0++ '@react-pdf/[email protected]': {}++ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/fns': 3.0.0+ '@react-pdf/primitives': 4.0.0+ '@react-pdf/textkit': 5.0.0+ '@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++ '@react-pdf/[email protected]([email protected])':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/font': 3.0.0+ '@react-pdf/layout': 4.0.1+ '@react-pdf/pdfkit': 4.0.0+ '@react-pdf/primitives': 4.0.0+ '@react-pdf/render': 4.0.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.3.1+ scheduler: 0.17.0+ transitivePeerDependencies:+ - encoding++ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/fns': 3.0.0+ '@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++ '@react-pdf/[email protected]':+ dependencies:+ '@babel/runtime': 7.26.0+ '@react-pdf/fns': 3.0.0+ bidi-js: 1.0.3+ hyphen: 1.10.6+ unicode-properties: 1.4.1++ '@react-pdf/[email protected]': {}+'@rtsao/[email protected]': {}'@rushstack/[email protected]': {}'@swc/[email protected]': {}+ '@swc/[email protected]':+ dependencies:+ tslib: 2.8.1+'@swc/[email protected]':dependencies:'@swc/counter': 0.1.3@@ -1662,7 +2052,7 @@ snapshots:'@types/[email protected]': {}- '@types/[email protected]':+ '@types/[email protected]':dependencies:undici-types: 6.19.8@@ -1670,9 +2060,9 @@ snapshots:'@types/[email protected]':dependencies:- '@types/react': 18.3.11+ '@types/react': 18.3.12- '@types/[email protected]':+ '@types/[email protected]':dependencies:'@types/prop-types': 15.7.13csstype: 3.1.3@@ -1760,6 +2150,8 @@ snapshots:'@ungap/[email protected]': {}+ [email protected]: {}+dependencies:acorn: 8.13.0@@ -1875,6 +2267,12 @@ snapshots:+ [email protected]: {}++ dependencies:+ require-from-string: 2.0.2+@@ -1890,6 +2288,14 @@ snapshots:dependencies:fill-range: 7.1.1+ dependencies:+ base64-js: 1.5.1++ dependencies:+ pako: 1.0.11+dependencies:streamsearch: 1.1.0@@ -1927,22 +2333,37 @@ snapshots:+ [email protected]: {}+dependencies:color-name: 1.1.4+ dependencies:+ color-name: 1.1.4+ simple-swizzle: 0.2.2++ dependencies:+ node-fetch: 2.7.0+ transitivePeerDependencies:+ - encoding+dependencies:path-key: 3.1.1shebang-command: 2.0.0which: 2.0.2+ [email protected]: {}+@@ -1967,6 +2388,8 @@ snapshots:es-errors: 1.3.0is-data-view: 1.0.1+ [email protected]: {}+dependencies:ms: 2.1.3@@ -2010,6 +2433,8 @@ snapshots:has-property-descriptors: 1.0.2object-keys: 1.1.1+ [email protected]: {}+@@ -2024,6 +2449,8 @@ snapshots:+ [email protected]: {}+@@ -2340,6 +2767,8 @@ snapshots:+ [email protected]: {}+@@ -2379,6 +2808,18 @@ snapshots:+ dependencies:+ '@swc/helpers': 0.5.15+ brotli: 1.3.3+ clone: 2.1.2+ dfa: 1.2.0+ fast-deep-equal: 3.1.3+ restructure: 3.0.2+ tiny-inflate: 1.0.3+ unicode-properties: 1.4.1+ unicode-trie: 2.0.0+dependencies:is-callable: 1.2.7@@ -2493,6 +2934,14 @@ snapshots:dependencies:function-bind: 1.1.2+ dependencies:+ hsl-to-rgb-for-reals: 1.1.1++ [email protected]: {}++ [email protected]: {}+@@ -2525,6 +2974,8 @@ snapshots:call-bind: 1.0.7get-intrinsic: 1.2.4+ [email protected]: {}+dependencies:has-tostringtag: 1.0.2@@ -2611,6 +3062,8 @@ snapshots:dependencies:which-typed-array: 1.1.15+ [email protected]: {}+@@ -2646,6 +3099,10 @@ snapshots:optionalDependencies:'@pkgjs/parseargs': 0.11.0+ dependencies:+ restructure: 3.0.2+@@ -2704,6 +3161,14 @@ snapshots:+ dependencies:+ react: 18.3.1++ [email protected]: {}++ [email protected]: {}+@@ -2723,6 +3188,8 @@ snapshots:+ [email protected]: {}+@@ -2731,6 +3198,8 @@ snapshots:object-assign: 4.1.1thenify-all: 1.6.0+ [email protected]: {}+@@ -2760,8 +3229,23 @@ snapshots:- '@babel/core'- babel-plugin-macros+ dependencies:+ whatwg-url: 5.0.0++ dependencies:+ svg-arc-to-cubic-bezier: 3.2.0++ [email protected]([email protected]([email protected]([email protected]))([email protected]))([email protected]):+ dependencies:+ mitt: 3.0.1+ react: 18.3.1+ optionalDependencies:+@@ -2830,10 +3314,16 @@ snapshots:+ [email protected]: {}++ [email protected]: {}+dependencies:callsites: 3.1.0+ [email protected]: {}+@@ -2912,12 +3402,20 @@ snapshots:+ dependencies:+ inherits: 2.0.4+dependencies:loose-envify: 1.4.0react: 18.3.1scheduler: 0.23.2+ dependencies:+ react: 18.3.1+@@ -2942,6 +3440,8 @@ snapshots:globalthis: 1.0.4which-builtin-type: 1.1.4+ [email protected]: {}+dependencies:call-bind: 1.0.7@@ -2949,6 +3449,8 @@ snapshots:es-errors: 1.3.0set-function-name: 2.0.2+ [email protected]: {}+@@ -2965,6 +3467,8 @@ snapshots:path-parse: 1.0.7supports-preserve-symlinks-flag: 1.0.0+ [email protected]: {}+@@ -2982,12 +3486,19 @@ snapshots:has-symbols: 1.0.3isarray: 2.0.5+ [email protected]: {}+dependencies:call-bind: 1.0.7es-errors: 1.3.0is-regex: 1.1.4+ dependencies:+ loose-envify: 1.4.0+ object-assign: 4.1.1+dependencies:loose-envify: 1.4.0@@ -3027,6 +3538,10 @@ snapshots:+ dependencies:+ is-arrayish: 0.3.2+@@ -3092,6 +3607,10 @@ snapshots:define-properties: 1.2.1es-object-atoms: 1.0.0+ dependencies:+ safe-buffer: 5.2.1+dependencies:ansi-regex: 5.0.1@@ -3125,6 +3644,8 @@ snapshots:+ [email protected]: {}+dependencies:'@alloc/quick-lru': 5.2.0@@ -3164,10 +3685,14 @@ snapshots:dependencies:any-promise: 1.3.0+ [email protected]: {}+dependencies:is-number: 7.0.0+ [email protected]: {}+dependencies:typescript: 5.6.3@@ -3183,6 +3708,8 @@ snapshots:+ [email protected]: {}+dependencies:prelude-ls: 1.2.1@@ -3232,12 +3759,39 @@ snapshots:+ dependencies:+ base64-js: 1.5.1+ unicode-trie: 2.0.0++ dependencies:+ pako: 0.2.9+ tiny-inflate: 1.0.3+dependencies:punycode: 2.3.1+ dependencies:+ react: 18.3.1++ dependencies:+ inherits: 2.0.4+ string_decoder: 1.3.0+ util-deprecate: 1.0.2++ [email protected]: {}++ dependencies:+ tr46: 0.0.3+ webidl-conversions: 3.0.1+dependencies:is-bigint: 1.0.4@@ -3299,3 +3853,7 @@ snapshots:++ [email protected]: {}++ [email protected]: {}diff --git a/public/cat.webp b/public/cat.webpnew file mode 100644index 0000000..c841d75Binary files /dev/null and b/public/cat.webp differdiff --git a/src/app/components/invoice-form.tsx b/src/app/components/invoice-form.tsxnew file mode 100644index 0000000..73bb3bc--- /dev/null+++ b/src/app/components/invoice-form.tsx@@ -0,0 +1,1028 @@+import React, { useCallback, useEffect } from "react";+import { useForm, Controller, useWatch, useFieldArray } from "react-hook-form";+import { zodResolver } from "@hookform/resolvers/zod";+import {+ invoiceSchema,+ type InvoiceData,+ SUPPORTED_CURRENCIES,+ SUPPORTED_LANGUAGES,+ type InvoiceItemData,+ invoiceItemSchema,+} from "@/app/schema";+import { useDebouncedCallback } from "use-debounce";+import { Plus, Trash2 } from "lucide-react";+import { z } from "zod";++export const PDF_DATA_LOCAL_STORAGE_KEY = "invoicePdfData";++const calculateItemTotals = (item: InvoiceItemData | null) => {+ if (!item) return null;++ const amount = Number(item.amount) || 0;+ const netPrice = Number(item.netPrice) || 0;+ const calculatedNetAmount = amount * netPrice;+ const formattedNetAmount = Number(calculatedNetAmount.toFixed(2));++ let vatAmount = 0;+ if (item.vat && item.vat !== "NP" && item.vat !== "OO") {+ vatAmount = (formattedNetAmount * Number(item.vat)) / 100;+ }++ const formattedVatAmount = Number(vatAmount.toFixed(2));+ const formattedPreTaxAmount = Number(+ (formattedNetAmount + formattedVatAmount).toFixed(2)+ );++ return {+ ...item,+ netAmount: formattedNetAmount,+ vatAmount: formattedVatAmount,+ preTaxAmount: formattedPreTaxAmount,+ };+};++interface InvoiceFormProps {+ invoiceData: InvoiceData;+ onInvoiceDataChange: (updatedData: InvoiceData) => void;+}++export function InvoiceForm({+ invoiceData,+ onInvoiceDataChange,+}: InvoiceFormProps) {+ const {+ control,+ handleSubmit,+ setValue,+ formState: { errors },+ watch,+ } = useForm<InvoiceData>({+ resolver: zodResolver(invoiceSchema),+ defaultValues: invoiceData,+ mode: "onChange",+ });++ const currency = useWatch({ control, name: "currency" });+ const invoiceItems = useWatch({ control, name: "items" });++ const { fields, append, remove } = useFieldArray({+ control,+ name: "items",+ });++ // calculate totals and other values when invoice items change+ useEffect(() => {+ // run validations before calculations because user can input invalid data+ const validatedItems = z.array(invoiceItemSchema).safeParse(invoiceItems);++ if (!validatedItems.success) {+ console.error("Invalid items:", validatedItems.error);+ return;+ }++ // Always calculate total, even when no items+ const total = invoiceItems?.length+ ? Number(+ invoiceItems+ .reduce((sum, item) => sum + (item?.preTaxAmount || 0), 0)+ .toFixed(2)+ )+ : 0;++ // Update total first+ setValue("total", total, { shouldValidate: true });++ // Skip rest of calculations if no items+ if (!invoiceItems?.length) return;++ // Check if any relevant values have changed+ const hasChanges = invoiceItems.some((item) => {+ const calculated = calculateItemTotals(item);+ return (+ calculated?.netAmount !== item.netAmount ||+ calculated?.vatAmount !== item.vatAmount ||+ calculated?.preTaxAmount !== item.preTaxAmount+ );+ });+ if (!hasChanges) return;++ // Only update if there are actual changes+ const updatedItems = invoiceItems+ .map(calculateItemTotals)+ .filter(Boolean) as InvoiceItemData[];++ // Batch updates+ updatedItems.forEach((item, index) => {+ setValue(`items.${index}`, item, {+ shouldValidate: false, // Prevent validation during intermediate updates+ });+ });+ }, [invoiceItems, setValue]);++ // regenerate pdf on every input change with debounce+ const debouncedRegeneratePdfOnFormChange = useDebouncedCallback(+ (data) => {+ // regenerate pdf and run validations+ handleSubmit(onSubmit)(data);++ // validate with zod and save to local storage+ const result = invoiceSchema.safeParse(data);++ if (!result.success) {+ console.error("Invalid data:", result.error);+ } else {+ // success validation+ const stringifiedData = JSON.stringify(result.data);++ try {+ localStorage.setItem(PDF_DATA_LOCAL_STORAGE_KEY, stringifiedData);+ } catch (error) {+ console.error("Error saving to local storage:", error);+ }+ }+ },+ // delay in ms+ 400+ );++ // subscribe to form changes to regenerate pdf on every input change+ useEffect(() => {+ const subscription = watch((value) => {+ debouncedRegeneratePdfOnFormChange(value);+ });++ return () => subscription.unsubscribe();+ }, [debouncedRegeneratePdfOnFormChange, watch]);++ // Add a wrapper function for remove that triggers the form update+ const handleRemoveItem = useCallback(+ (index: number) => {+ remove(index);+ // Manually trigger form submission after removal+ const currentFormData = watch();+ debouncedRegeneratePdfOnFormChange(currentFormData);+ },+ [remove, watch, debouncedRegeneratePdfOnFormChange]+ );++ const onSubmit = (data: InvoiceData) => {+ onInvoiceDataChange(data);+ };++ return (+ <form+ onSubmit={handleSubmit(onSubmit)}+ className="space-y-6 mb-4"+ id="invoiceForm"+ >+ {/* Language Select - Add this after Currency Select */}+ <div>+ <label+ htmlFor="language"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Invoice PDF Language+ </label>+ <Controller+ name="language"+ control={control}+ render={({ field }) => (+ <select+ {...field}+ id="language"+ className="mt-1 block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ >+ {SUPPORTED_LANGUAGES.map((lang) => (+ <option key={lang} value={lang}>+ {lang === "en" ? "English" : "Polish"}+ </option>+ ))}+ </select>+ )}+ />+ {errors.language && (+ <p className="mt-1 text-sm text-red-600">{errors.language.message}</p>+ )}+ </div>++ {/* Invoice Number */}+ <div>+ <label+ htmlFor="invoiceNumber"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Invoice Number+ </label>+ <Controller+ name="invoiceNumber"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ type="text"+ id="invoiceNumber"+ className="mt-1 block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.invoiceNumber && (+ <p className="mt-1 text-sm text-red-600">+ {errors.invoiceNumber.message}+ </p>+ )}+ </div>++ {/* Date of Issue */}+ <div>+ <label+ htmlFor="dateOfIssue"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Date of Issue+ </label>+ <Controller+ name="dateOfIssue"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ type="date"+ id="dateOfIssue"+ className="mt-1 block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.dateOfIssue && (+ <p className="mt-1 text-sm text-red-600">+ {errors.dateOfIssue.message}+ </p>+ )}+ </div>++ {/* Date of Service */}+ <div>+ <label+ htmlFor="dateOfService"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Date of Service+ </label>+ <Controller+ name="dateOfService"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ type="date"+ id="dateOfService"+ className="mt-1 block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.dateOfService && (+ <p className="mt-1 text-sm text-red-600">+ {errors.dateOfService.message}+ </p>+ )}+ </div>++ {/* Invoice Type */}+ <div>+ <label+ htmlFor="invoiceType"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Invoice Type+ </label>+ <Controller+ name="invoiceType"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="invoiceType"+ rows={2}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ placeholder="Enter invoice type"+ />+ )}+ />+ {errors.invoiceType && (+ <p className="mt-1 text-sm text-red-600">+ {errors.invoiceType.message}+ </p>+ )}+ </div>++ {/* Currency Select */}+ <div>+ <label+ htmlFor="currency"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Currency+ </label>+ <Controller+ name="currency"+ control={control}+ render={({ field }) => (+ <select+ {...field}+ id="currency"+ className="mt-1 block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ >+ {SUPPORTED_CURRENCIES.map((currency) => (+ <option+ key={currency}+ value={currency}+ defaultValue={SUPPORTED_CURRENCIES[0]}+ >+ {currency}+ </option>+ ))}+ </select>+ )}+ />+ {errors.currency && (+ <p className="mt-1 text-sm text-red-600">{errors.currency.message}</p>+ )}+ </div>++ {/* Seller Information */}+ <fieldset className="border p-4 rounded-lg shadow">+ <legend className="text-lg font-medium text-gray-900 mb-2">+ Seller Information+ </legend>+ <div className="space-y-4">+ <div>+ <label+ htmlFor="sellerName"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Name+ </label>+ <Controller+ name="seller.name"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="sellerName"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.seller?.name && (+ <p className="mt-1 text-sm text-red-600">+ {errors.seller.name.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="sellerAddress"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Address+ </label>+ <Controller+ name="seller.address"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="sellerAddress"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.seller?.address && (+ <p className="mt-1 text-sm text-red-600">+ {errors.seller.address.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="sellerVatNo"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ VAT Number+ </label>+ <Controller+ name="seller.vatNo"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id="sellerVatNo"+ type="text"+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.seller?.vatNo && (+ <p className="mt-1 text-sm text-red-600">+ {errors.seller.vatNo.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="sellerEmail"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ </label>+ <Controller+ name="seller.email"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id="sellerEmail"+ type="email"+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.seller?.email && (+ <p className="mt-1 text-sm text-red-600">+ {errors.seller.email.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="sellerAccountNumber"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Account Number+ </label>+ <Controller+ name="seller.accountNumber"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="sellerAccountNumber"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.seller?.accountNumber && (+ <p className="mt-1 text-sm text-red-600">+ {errors.seller.accountNumber.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="sellerSwiftBic"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ SWIFT/BIC+ </label>+ <Controller+ name="seller.swiftBic"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="sellerSwiftBic"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.seller?.swiftBic && (+ <p className="mt-1 text-sm text-red-600">+ {errors.seller.swiftBic.message}+ </p>+ )}+ </div>+ </div>+ </fieldset>++ {/* Buyer Information */}+ <fieldset className="border p-4 rounded-lg shadow">+ <legend className="text-lg font-medium text-gray-900 mb-2">+ Buyer Information+ </legend>+ <div className="space-y-4">+ <div>+ <label+ htmlFor="buyerName"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Name+ </label>+ <Controller+ name="buyer.name"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="buyerName"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.buyer?.name && (+ <p className="mt-1 text-sm text-red-600">+ {errors.buyer.name.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="buyerAddress"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Address+ </label>+ <Controller+ name="buyer.address"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="buyerAddress"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.buyer?.address && (+ <p className="mt-1 text-sm text-red-600">+ {errors.buyer.address.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="buyerVatNo"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ VAT Number+ </label>+ <Controller+ name="buyer.vatNo"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="buyerVatNo"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.buyer?.vatNo && (+ <p className="mt-1 text-sm text-red-600">+ {errors.buyer.vatNo.message}+ </p>+ )}+ </div>++ <div>+ <label+ htmlFor="buyerEmail"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ </label>+ <Controller+ name="buyer.email"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id="buyerEmail"+ type="email"+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.buyer?.email && (+ <p className="mt-1 text-sm text-red-600">+ {errors.buyer.email.message}+ </p>+ )}+ </div>+ </div>+ </fieldset>++ {/* Invoice Items */}+ <fieldset className="border p-4 rounded-lg shadow">+ <legend className="text-lg font-medium text-gray-900 mb-2">+ Invoice Items+ </legend>++ {fields.map((field, index) => {+ return (+ <fieldset+ key={field.id}+ className="border p-4 rounded-lg shadow mb-4 relative"+ >+ {/* Delete invoice item button */}+ {index > 0 ? (+ <div className="absolute -right-3 -top-10">+ <button+ type="button"+ onClick={() => handleRemoveItem(index)}+ className="flex items-center justify-center rounded-full bg-red-600 hover:bg-red-700 p-2 transition-colors"+ title="Delete invoice item"+ >+ <Trash2 className="h-4 w-4 text-white" />+ </button>+ </div>+ ) : null}+ <legend className="text-lg font-medium text-gray-900 mb-2 relative">+ Item {index + 1}+ </legend>+ <div className="space-y-4 mb-8 relative">+ {/* Item Name */}+ <div>+ <label+ htmlFor={`itemName${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Item Name+ </label>+ <Controller+ name={`items.${index}.name`}+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ rows={4}+ id={`itemName${index}`}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.items?.[index]?.name && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index]?.name?.message}+ </p>+ )}+ </div>++ {/* Item Amount */}+ <div>+ <label+ htmlFor={`itemAmount${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Amount+ </label>+ <Controller+ name={`items.${index}.amount`}+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id={`itemAmount${index}`}+ type="number"+ step="0.01"+ min="0"+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.items?.[index]?.amount && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index].amount.message}+ </p>+ )}+ </div>++ {/* Item Unit */}+ <div>+ <label+ htmlFor={`itemUnit${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Unit+ </label>+ <Controller+ name={`items.${index}.unit`}+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id={`itemUnit${index}`}+ type="text"+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.items?.[index]?.unit && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index].unit.message}+ </p>+ )}+ </div>++ {/* New Net Price field */}+ <div>+ <label+ htmlFor={`itemNetPrice${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Net Price+ </label>+ <Controller+ name={`items.${index}.netPrice`}+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id={`itemNetPrice${index}`}+ type="number"+ step="0.01"+ min="0"+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.items?.[index]?.netPrice && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index].netPrice.message}+ </p>+ )}+ </div>++ {/* New VAT field */}+ <div>+ <label+ htmlFor={`itemVat${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ VAT (enter NP, OO or percentage value)+ </label>+ <Controller+ name={`items.${index}.vat`}+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id={`itemVat${index}`}+ type="text"+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.items?.[index]?.vat && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index].vat.message}+ </p>+ )}+ </div>++ {/* New Net Amount field */}+ <div>+ <label+ htmlFor={`itemNetAmount${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Net Amount (calculated automatically based on Amount and Net+ Price)+ </label>+ <Controller+ name={`items.${index}.netAmount`}+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id={`itemNetAmount${index}`}+ type="number"+ step="0.01"+ readOnly+ className="cursor-not-allowed block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2 bg-gray-100"+ />+ )}+ />+ {errors.items?.[index]?.netAmount && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index].netAmount.message}+ </p>+ )}+ </div>++ {/* This should probably be readonly field and calculated automatically based on VAT in % and Net Amount */}+ <div>+ <label+ htmlFor={`itemVatAmount${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ VAT Amount+ </label>+ <Controller+ name={`items.${index}.vatAmount`}+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id={`itemVatAmount${index}`}+ type="number"+ step="1"+ max="100"+ min="0"+ readOnly+ className="cursor-not-allowed block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2 bg-gray-100"+ />+ )}+ />+ {errors.items?.[index]?.vatAmount && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index].vatAmount.message}+ </p>+ )}+ </div>++ {/* Pre-tax Amount field */}+ <div>+ <label+ htmlFor={`itemPreTaxAmount${index}`}+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Pre-tax Amount (calculated automatically based on Net Amount+ and VAT Amount)+ </label>+ <Controller+ name={`items.${index}.preTaxAmount`}+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id={`itemPreTaxAmount${index}`}+ type="number"+ step="0.01"+ readOnly+ className="cursor-not-allowedblock w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2 bg-gray-100"+ />+ )}+ />+ {errors.items?.[index]?.preTaxAmount && (+ <p className="mt-1 text-sm text-red-600">+ {errors.items[index].preTaxAmount.message}+ </p>+ )}+ </div>+ </div>+ </fieldset>+ );+ })}++ <button+ type="button"+ onClick={() => {+ append({+ name: "",+ amount: 1,+ unit: "",+ netPrice: 0,+ vat: "NP",+ netAmount: 0,+ vatAmount: 0,+ preTaxAmount: 0,+ });+ }}+ className="flex items-center text-sm font-medium text-gray-700 mb-1"+ >+ <Plus className="h-4 w-4 mr-2" />+ Add Item+ </button>+ </fieldset>++ {/* Total field (now with currency) */}+ <div>+ <label+ htmlFor="total"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Total in {currency} (this is calculated automatically based on Amount+ and Net Price)+ </label>+ <div className="relative mt-1 rounded-md shadow-sm">+ <div className="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">+ <span className="text-gray-500 sm:text-sm">{currency}</span>+ </div>+ <Controller+ name="total"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ readOnly+ id="total"+ type="text"+ value={field.value+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(/,/g, " ")}+ className="cursor-not-allowed block w-full rounded-md border-gray-300 pl-12 focus-visible:border-indigo-500 focus-visible:ring-indigo-500 sm:text-sm bg-gray-100"+ />+ )}+ />+ </div>+ {errors.total && (+ <p className="mt-1 text-sm text-red-600">{errors.total.message}</p>+ )}+ </div>++ {/* Payment Method */}+ <div>+ <label+ htmlFor="paymentMethod"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Payment Method+ </label>+ <Controller+ name="paymentMethod"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id="paymentMethod"+ type="text"+ className="mt-1 block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.paymentMethod && (+ <p className="mt-1 text-sm text-red-600">+ {errors.paymentMethod.message}+ </p>+ )}+ </div>++ {/* Payment Due */}+ <div>+ <label+ htmlFor="paymentDue"+ className="block text-sm font-medium text-gray-700 mb-1"+ >+ Payment Due+ </label>+ <Controller+ name="paymentDue"+ control={control}+ render={({ field }) => (+ <input+ {...field}+ id="paymentDue"+ type="date"+ className="mt-1 block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors.paymentDue && (+ <p className="mt-1 text-sm text-red-600">+ {errors.paymentDue.message}+ </p>+ )}+ </div>++ <div className="mb-4">+ <label+ htmlFor="notes"+ className="block text-sm font-medium text-gray-700"+ >+ Notes+ </label>+ <Controller+ name="notes"+ control={control}+ render={({ field }) => (+ <textarea+ {...field}+ id="notes"+ rows={3}+ className="block w-full rounded-md border-gray-300 border shadow-sm focus-visible:border-indigo-500 focus-visible:ring focus-visible:ring-indigo-200 focus-visible:ring-opacity-50 px-3 py-2"+ />+ )}+ />+ {errors?.notes && (+ <p className="mt-1 text-sm text-red-600">{errors?.notes?.message}</p>+ )}+ </div>+ </form>+ );+}diff --git a/src/app/components/invoice-pdf-download-link.tsx b/src/app/components/invoice-pdf-download-link.tsxnew file mode 100644index 0000000..868dc7a--- /dev/null+++ b/src/app/components/invoice-pdf-download-link.tsx@@ -0,0 +1,23 @@+import { PDFDownloadLink } from "@react-pdf/renderer";+import type { InvoiceData } from "@/app/schema";+import dayjs from "dayjs";+import { InvoicePdfTemplate } from "./invoice-pdf-template";++export function InvoicePDFDownloadLink({+ invoiceData,+}: {+ invoiceData: InvoiceData;+}) {+ const invoiceDate = dayjs().format("DD-MM-YYYY");++ return (+ <PDFDownloadLink+ document={<InvoicePdfTemplate invoiceData={invoiceData} />}+ fileName={`invoice-${invoiceDate}.pdf`}+ className="mb-4 lg:mb-0 w-full lg:w-[180px] text-center px-4 py-2 text-white bg-blue-500 rounded hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50"+ >+ {/* @ts-expect-error PR with fix: https://github.com/diegomura/react-pdf/pull/2888 */}+ {({ loading }) => (loading ? "Loading document..." : "Download PDF")}+ </PDFDownloadLink>+ );+}diff --git a/src/app/components/invoice-pdf-template/index.tsx b/src/app/components/invoice-pdf-template/index.tsxnew file mode 100644index 0000000..1934916--- /dev/null+++ b/src/app/components/invoice-pdf-template/index.tsx@@ -0,0 +1,255 @@+"use client";++import { type InvoiceData } from "@/app/schema";+import {+ Document,+ Font,+ Page,+ StyleSheet,+ Text,+ View,+} from "@react-pdf/renderer";+import { InvoiceHeader } from "./invoice-header";+import { InvoiceSellerBuyerInfo } from "./invoice-seller-buyer-info";+import { InvoiceItemsTable } from "./invoice-items-table";+import { InvoicePaymentInfo } from "./invoice-payment-info";+import { InvoiceVATSummaryTable } from "./invoice-vat-summary-table";+import { InvoicePaymentTotals } from "./invoice-payment-totals";+import { translations } from "./translations";++// Open sans seems to be working fine with EN and PL+const fontFamily = "Open Sans";+const fontFamilyBold = "Open Sans";++Font.register({+ family: fontFamily,+ fonts: [+ {+ src: "https://cdn.jsdelivr.net/npm/[email protected]/fonts/open-sans-regular.ttf",+ },+ {+ src: "https://cdn.jsdelivr.net/npm/[email protected]/fonts/open-sans-700.ttf",+ fontWeight: 700,+ },+ ],+});++// Styles for the PDF+export const styles = StyleSheet.create({+ wFull: {+ width: "100%",+ },+ page: {+ flexDirection: "column",+ backgroundColor: "#FFFFFF",+ padding: 30,+ fontFamily: fontFamily,+ fontWeight: 400,+ },+ header: {+ fontSize: 16,+ marginBottom: 0,+ fontFamily: fontFamilyBold,+ fontWeight: 600,+ },+ subheader: {+ fontSize: 12,+ marginBottom: 3,+ borderBottom: "1px solid gray",+ fontFamily: fontFamilyBold,+ fontWeight: 600,+ },+ fontSize7: {+ fontSize: 7,+ },+ fontSize8: {+ fontSize: 8,+ },+ fontSize9: {+ fontSize: 9,+ },+ fontSize10: {+ fontSize: 10,+ },+ fontSize11: {+ fontSize: 11,+ },+ fontBold: {+ fontFamily: fontFamilyBold,+ fontWeight: 600,+ },+ boldText: {+ fontFamily: fontFamilyBold,+ fontWeight: 600,+ fontSize: 7,+ },+ table: {+ display: "flex",+ width: "100%",+ borderStyle: "solid",+ borderWidth: 1,+ borderRightWidth: 0,+ borderBottomWidth: 0,+ borderColor: "gray",+ },+ tableRow: {+ flexDirection: "row",+ width: "100%",+ },+ tableCol: {+ borderStyle: "solid",+ borderWidth: 1,+ borderLeftWidth: 0,+ borderTopWidth: 0,+ borderColor: "gray",+ textAlign: "center",+ },+ tableCell: {+ marginTop: 1.5,+ marginBottom: 1.5,+ fontSize: 8,+ },+ tableCellBold: {+ marginTop: 1,+ marginBottom: 1,+ marginLeft: 2,+ marginRight: 2,+ fontSize: 8,+ fontFamily: fontFamilyBold,+ fontWeight: 600,+ },+ // styles for specific column widths for invoice items table+ colNo: { width: "3%" },+ colName: { width: "36%" },+ colGTU: { width: "6%" },+ colAmount: { width: "7%" },+ colUnit: { width: "6%" },+ colNetPrice: { width: "10%" },+ colVAT: { width: "4%" },+ colNetAmount: { width: "10%" },+ colVATAmount: { width: "8%" },+ colPreTaxAmount: { width: "10%" },+ signatureSection: {+ flexDirection: "row",+ justifyContent: "center",+ marginTop: 70,+ width: "100%",+ },+ signatureColumn: {+ flexDirection: "column",+ alignItems: "center",+ width: "30%",+ marginHorizontal: "5%",+ },+ signatureLine: {+ borderTopWidth: 1,+ borderTopColor: "#000000",+ borderTopStyle: "dashed",+ width: "100%",+ marginBottom: 5,+ },+ signatureText: {+ fontSize: 8,+ textAlign: "center",+ },+ footer: {+ position: "absolute",+ bottom: 30,+ left: 30,+ right: 30,+ flexDirection: "row",+ justifyContent: "space-between",+ borderTop: "1px solid #000",+ paddingTop: 5,+ },+ footerText: {+ fontSize: 8,+ color: "#000",+ },+} as const);++// PDF Document component+export const InvoicePdfTemplate = ({+ invoiceData,+}: {+ invoiceData: InvoiceData;+}) => {+ const formattedInvoiceTotal = invoiceData?.total+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ const language = invoiceData.language;+ const t = translations[language];++ return (+ <Document>+ <Page size="A4" style={styles.page}>+ <InvoiceHeader invoiceData={invoiceData} />+ <InvoiceSellerBuyerInfo invoiceData={invoiceData} />+ <InvoiceItemsTable+ invoiceData={invoiceData}+ formattedInvoiceTotal={formattedInvoiceTotal}+ />++ <View+ style={{+ display: "flex",+ flexDirection: "row",+ justifyContent: "space-between",+ }}+ >+ <InvoicePaymentInfo invoiceData={invoiceData} />+ <InvoiceVATSummaryTable+ invoiceData={invoiceData}+ formattedInvoiceTotal={formattedInvoiceTotal}+ />+ </View>++ <InvoicePaymentTotals+ invoiceData={invoiceData}+ formattedInvoiceTotal={formattedInvoiceTotal}+ />++ {/* Signature section */}+ <View style={styles.signatureSection}>+ <View style={styles.signatureColumn}>+ <View style={styles.signatureLine} />+ <Text style={styles.signatureText}>+ {t.personAuthorizedToReceive}+ </Text>+ </View>+ <View style={styles.signatureColumn}>+ <View style={styles.signatureLine} />+ <Text style={styles.signatureText}>+ {t.personAuthorizedToIssue}+ </Text>+ </View>+ </View>++ {/* Notes */}+ <View style={{ marginTop: 10 }}>+ <Text style={styles.fontSize8}>{invoiceData?.notes}</Text>+ </View>++ {/* Footer */}+ <View style={styles.footer}>+ {/* Created with */}+ <Text style={[styles.fontSize7]}>+ {/* TODO: change this later to our prod website */}+ Created by OUR PROJECT NAME+ </Text>+ {/* Page number */}+ <Text+ style={styles.footerText}+ render={({ pageNumber, totalPages }) =>+ `${pageNumber}/${totalPages}`+ }+ />+ </View>+ </Page>+ </Document>+ );+};diff --git a/src/app/components/invoice-pdf-template/invoice-header.tsx b/src/app/components/invoice-pdf-template/invoice-header.tsxnew file mode 100644index 0000000..d09a679--- /dev/null+++ b/src/app/components/invoice-pdf-template/invoice-header.tsx@@ -0,0 +1,53 @@+import { Text, View } from "@react-pdf/renderer";+import { styles } from ".";+import { type InvoiceData } from "@/app/schema";+import { translations } from "./translations";++export function InvoiceHeader({ invoiceData }: { invoiceData: InvoiceData }) {+ const language = invoiceData.language;+ const t = translations[language];++ return (+ <View+ style={{+ display: "flex",+ flexDirection: "row",+ justifyContent: "space-between",+ alignItems: "flex-start",+ marginBottom: 7,+ }}+ >+ <View>+ <Text style={[styles.header]}>+ {t.invoiceNumber}: {invoiceData?.invoiceNumber}+ </Text>++ {invoiceData?.invoiceType && (+ <Text style={[styles.fontBold, styles.fontSize8]}>+ {invoiceData?.invoiceType}+ </Text>+ )}+ </View>+ <View+ style={{+ display: "flex",+ flexDirection: "column",+ alignItems: "flex-end",+ }}+ >+ <Text style={styles.fontSize7}>+ {t.dateOfIssue}:{" "}+ <Text style={[styles.fontBold, styles.fontSize8]}>+ {invoiceData?.dateOfIssue}+ </Text>+ </Text>+ <Text style={styles.fontSize7}>+ {t.dateOfService}:{" "}+ <Text style={[styles.fontBold, styles.fontSize8]}>+ {invoiceData?.dateOfService}+ </Text>+ </Text>+ </View>+ </View>+ );+}diff --git a/src/app/components/invoice-pdf-template/invoice-items-table.tsx b/src/app/components/invoice-pdf-template/invoice-items-table.tsxnew file mode 100644index 0000000..c92369c--- /dev/null+++ b/src/app/components/invoice-pdf-template/invoice-items-table.tsx@@ -0,0 +1,259 @@+import { Text, View } from "@react-pdf/renderer";+import { styles } from ".";+import type { InvoiceData } from "@/app/schema";+import { translations } from "./translations";++export function InvoiceItemsTable({+ invoiceData,+ formattedInvoiceTotal,+}: {+ invoiceData: InvoiceData;+ formattedInvoiceTotal: string;+}) {+ const language = invoiceData.language;+ const t = translations[language];++ return (+ <View style={{ marginBottom: 5, marginTop: 14 }}>+ <View style={styles.table}>+ {/* Table header */}+ <View style={styles.tableRow}>+ <View style={[styles.tableCol, styles.colNo]}>+ <Text style={styles.tableCellBold}>{t.invoiceItemsTable.no}</Text>+ </View>+ <View style={[styles.tableCol, styles.colName]}>+ <Text style={styles.tableCellBold}>+ {t.invoiceItemsTable.nameOfGoodsService}+ </Text>+ </View>+ <View style={[styles.tableCol, styles.colGTU]}>+ <Text style={styles.tableCellBold}>+ {t.invoiceItemsTable.typeOfGTU}+ </Text>+ </View>+ <View style={[styles.tableCol, styles.colAmount]}>+ <Text style={[styles.tableCellBold, {}]}>+ {t.invoiceItemsTable.amount}+ </Text>+ </View>+ <View style={[styles.tableCol, styles.colUnit]}>+ <Text style={styles.tableCellBold}>{t.invoiceItemsTable.unit}</Text>+ </View>+ <View style={[styles.tableCol, styles.colNetPrice]}>+ <Text style={styles.tableCellBold}>+ {t.invoiceItemsTable.netPrice}+ </Text>+ </View>+ <View style={[styles.tableCol, styles.colVAT]}>+ <Text style={styles.tableCellBold}>{t.invoiceItemsTable.vat}</Text>+ </View>+ <View style={[styles.tableCol, styles.colNetAmount]}>+ <Text style={styles.tableCellBold}>+ {t.invoiceItemsTable.netAmount}+ </Text>+ </View>+ <View style={[styles.tableCol, styles.colVATAmount]}>+ <Text style={styles.tableCellBold}>+ {t.invoiceItemsTable.vatAmount}+ </Text>+ </View>+ <View style={[styles.tableCol, styles.colPreTaxAmount]}>+ <Text style={[styles.tableCellBold]}>+ {t.invoiceItemsTable.preTaxAmount}+ </Text>+ </View>+ </View>++ {/* Table rows */}+ {invoiceData?.items.map((item, index) => {+ const formattedNetPrice = item.netPrice+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ const formattedNetAmount = item.netAmount+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ const formattedVATAmount = item.vatAmount+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ const formattedPreTaxAmount = item.preTaxAmount+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ return (+ <View style={styles.tableRow} key={index}>+ {/* No */}+ <View style={[styles.tableCol, styles.colNo]}>+ <Text style={styles.tableCell}>{index + 1}.</Text>+ </View>++ {/* Name of goods/service */}+ <View style={[styles.tableCol, styles.colName]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "left", marginLeft: 2, marginRight: 2 },+ ]}+ >+ {item.name}+ </Text>+ </View>++ {/* Type of GTU */}+ <View style={[styles.tableCol, styles.colGTU]}>+ <Text style={styles.tableCell}></Text>+ </View>++ <View style={[styles.tableCol, styles.colAmount]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {typeof item?.amount === "number"+ ? item.amount.toFixed(2)+ : "0.00"}+ </Text>+ </View>++ {/* Unit */}+ <View style={[styles.tableCol, styles.colUnit]}>+ <Text style={[styles.tableCell, { textAlign: "center" }]}>+ {item.unit}+ </Text>+ </View>++ {/* Net price */}+ <View style={[styles.tableCol, styles.colNetPrice]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {typeof item?.netPrice === "number"+ ? formattedNetPrice+ : "0.00"}+ </Text>+ </View>++ {/* VAT */}+ <View+ style={[+ styles.tableCol,+ styles.colVAT,+ { textAlign: "center" },+ ]}+ >+ <Text style={styles.tableCell}>+ {isNaN(Number(item.vat)) ? item.vat : `${item.vat}%`}+ </Text>+ </View>++ {/* Net amount */}+ <View style={[styles.tableCol, styles.colNetAmount]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {typeof item?.netAmount === "number"+ ? formattedNetAmount+ : "0.00"}+ </Text>+ </View>++ {/* VAT amount */}+ <View style={[styles.tableCol, styles.colVATAmount]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {typeof item?.vatAmount === "number"+ ? formattedVATAmount+ : "0.00"}+ </Text>+ </View>++ {/* Pre-tax amount */}+ <View style={[styles.tableCol, styles.colPreTaxAmount]}>+ <Text+ style={[+ styles.tableCell,+ {+ textAlign: "right",+ marginRight: 2,+ },+ ]}+ >+ {typeof item?.preTaxAmount === "number"+ ? formattedPreTaxAmount+ : "0.00"}+ </Text>+ </View>+ </View>+ );+ })}++ {/* Table footer */}+ <View style={styles.tableRow}>+ {/* Empty cells */}+ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { borderRight: 0 }]}></View>++ <View style={[styles.tableCol, { width: "100%" }]}>+ <Text+ style={[+ styles.tableCell,+ {+ marginTop: 2,+ marginBottom: 2,+ textAlign: "right",+ marginRight: 5,+ },+ ]}+ >+ {t.invoiceItemsTable.sum}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {formattedInvoiceTotal}+ </Text>+ </Text>+ </View>+ </View>+ </View>+ </View>+ );+}diff --git a/src/app/components/invoice-pdf-template/invoice-payment-info.tsx b/src/app/components/invoice-pdf-template/invoice-payment-info.tsxnew file mode 100644index 0000000..99b78ca--- /dev/null+++ b/src/app/components/invoice-pdf-template/invoice-payment-info.tsx@@ -0,0 +1,30 @@+import { Text, View } from "@react-pdf/renderer";+import { styles } from ".";+import type { InvoiceData } from "@/app/schema";+import { translations } from "./translations";++export function InvoicePaymentInfo({+ invoiceData,+}: {+ invoiceData: InvoiceData;+}) {+ const language = invoiceData.language;+ const t = translations[language];++ return (+ <View>+ <Text style={styles.fontSize7}>+ {t.paymentInfo.paymentMethod}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.paymentMethod}+ </Text>+ </Text>+ <Text style={[styles.fontSize7, { marginLeft: 9.75 }]}>+ {t.paymentInfo.paymentDate}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.paymentDue}+ </Text>+ </Text>+ </View>+ );+}diff --git a/src/app/components/invoice-pdf-template/invoice-payment-totals.tsx b/src/app/components/invoice-pdf-template/invoice-payment-totals.tsxnew file mode 100644index 0000000..3714375--- /dev/null+++ b/src/app/components/invoice-pdf-template/invoice-payment-totals.tsx@@ -0,0 +1,69 @@+import { View, Text } from "@react-pdf/renderer";+import { styles } from ".";+import type { InvoiceData } from "@/app/schema";+import n2words from "n2words";+import { translations } from "./translations";++// Get the fractional part of the total+const getFractionalPart = (total: number = 0) => {+ return Math.round((total % 1) * 100)+ .toString()+ .padStart(2, "0");+};++export function InvoicePaymentTotals({+ invoiceData,+ formattedInvoiceTotal,+}: {+ invoiceData: InvoiceData;+ formattedInvoiceTotal: string;+}) {+ const language = invoiceData.language;+ const t = translations[language];++ const invoiceTotalInWords = n2words(Math.floor(invoiceData?.total ?? 0), {+ lang: language,+ });++ const fractionalPart = getFractionalPart(invoiceData?.total ?? 0);++ const currency = invoiceData.currency;++ return (+ <View style={{ maxWidth: "55%" }}>+ <View style={{ width: "auto", alignSelf: "flex-start", marginTop: 0 }}>+ <Text+ style={[+ styles.subheader,+ {+ borderBottom: "1px solid black",+ },+ styles.fontSize11,+ styles.fontBold,+ ]}+ >+ {t.paymentTotals.toPay}: {formattedInvoiceTotal} {currency}+ </Text>+ </View>++ <Text style={styles.fontSize7}>+ {t.paymentTotals.paid}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>0.00 {currency}</Text>+ </Text>++ <Text style={[styles.boldText, styles.fontSize7]}>+ {t.paymentTotals.leftToPay}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {formattedInvoiceTotal} {currency}+ </Text>+ </Text>++ <Text style={styles.fontSize7}>+ {t.paymentTotals.amountInWords}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceTotalInWords} {currency} {fractionalPart}/100+ </Text>+ </Text>+ </View>+ );+}diff --git a/src/app/components/invoice-pdf-template/invoice-seller-buyer-info.tsx b/src/app/components/invoice-pdf-template/invoice-seller-buyer-info.tsxnew file mode 100644index 0000000..55b605b--- /dev/null+++ b/src/app/components/invoice-pdf-template/invoice-seller-buyer-info.tsx@@ -0,0 +1,96 @@+import { Text, View } from "@react-pdf/renderer";+import { styles } from ".";+import type { InvoiceData } from "@/app/schema";+import { translations } from "./translations";++export function InvoiceSellerBuyerInfo({+ invoiceData,+}: {+ invoiceData: InvoiceData;+}) {+ const language = invoiceData.language;+ const t = translations[language];++ return (+ <View+ style={{+ display: "flex",+ flexDirection: "row",+ justifyContent: "space-between",+ alignItems: "flex-start",+ maxWidth: "512px",+ }}+ >+ {/* Seller info */}+ <View style={{ width: "280px", marginRight: 25 }}>+ <Text style={styles.subheader}>{t.seller.name}</Text>+ <View>+ <Text style={[styles.fontBold, styles.fontSize10]}>+ {invoiceData?.seller.name}+ </Text>+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.seller.address}+ </Text>++ <View style={{ marginTop: 2 }}>+ <Text style={[styles.fontSize7]}>+ {t.seller.vatNo}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.seller.vatNo}+ </Text>+ </Text>+ <Text style={styles.fontSize7}>+ {t.seller.email}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.seller.email}+ </Text>+ </Text>+ </View>+ </View>++ <View style={{ marginTop: 10 }}>+ <Text style={styles.fontSize8}>+ {t.seller.accountNumber} -{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.seller.accountNumber}+ </Text>+ </Text>+ <Text style={styles.fontSize7}>+ {t.seller.swiftBic}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.seller.swiftBic}+ </Text>+ </Text>+ </View>+ </View>++ {/* Buyer info */}+ <View style={{ width: "280px" }}>+ <Text style={styles.subheader}>{t.buyer.name}</Text>+ <Text style={[styles.fontBold, styles.fontSize10]}>+ {invoiceData?.buyer.name}+ </Text>+ <Text+ style={[styles.boldText, styles.fontSize8, { maxWidth: "280px" }]}+ >+ {invoiceData?.buyer.address}+ </Text>++ <View style={{ marginTop: 2 }}>+ <Text style={styles.fontSize7}>+ {t.buyer.vatNo}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.buyer.vatNo}+ </Text>+ </Text>+ <Text style={styles.fontSize7}>+ {t.buyer.email}:{" "}+ <Text style={[styles.boldText, styles.fontSize8]}>+ {invoiceData?.buyer.email}+ </Text>+ </Text>+ </View>+ </View>+ </View>+ );+}diff --git a/src/app/components/invoice-pdf-template/invoice-vat-summary-table.tsx b/src/app/components/invoice-pdf-template/invoice-vat-summary-table.tsxnew file mode 100644index 0000000..2c36222--- /dev/null+++ b/src/app/components/invoice-pdf-template/invoice-vat-summary-table.tsx@@ -0,0 +1,177 @@+import { Text, View } from "@react-pdf/renderer";+import { styles } from ".";+import type { InvoiceData } from "@/app/schema";+import { translations } from "./translations";++export function InvoiceVATSummaryTable({+ invoiceData,+ formattedInvoiceTotal,+}: {+ invoiceData: InvoiceData;+ formattedInvoiceTotal: string;+}) {+ const language = invoiceData.language;+ const t = translations[language];++ const sortedItems = [...invoiceData?.items].sort((a, b) => {+ // Handle cases where either value is a string (NP or OO)+ const isAString = isNaN(Number(a.vat));+ const isBString = isNaN(Number(b.vat));++ if (isAString && isBString) {+ if (typeof a.vat === "string" && typeof b.vat === "string") {+ return a.vat.localeCompare(b.vat);+ }+ }++ if (isAString) return 1; // Strings go last+ if (isBString) return -1; // Strings go last++ // Both are numbers, sort descending+ return Number(b.vat) - Number(a.vat);+ });++ const totalNetAmount = sortedItems.reduce(+ (acc, item) => acc + item.netAmount,+ 0+ );+ const formattedTotalNetAmount = totalNetAmount+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ const totalVATAmount = sortedItems.reduce(+ (acc, item) => acc + item.vatAmount,+ 0+ );+ const formattedTotalVATAmount = totalVATAmount+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ return (+ <View style={[styles.table, { width: "50%" }]}>+ {/* Header row */}+ <View style={styles.tableRow}>+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text style={styles.tableCellBold}>{t.vatSummaryTable.vatRate}</Text>+ </View>+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text style={styles.tableCellBold}>{t.vatSummaryTable.net}</Text>+ </View>+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text style={styles.tableCellBold}>{t.vatSummaryTable.vat}</Text>+ </View>+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text style={styles.tableCellBold}>{t.vatSummaryTable.preTax}</Text>+ </View>+ </View>++ {sortedItems?.map((item, index) => {+ const formattedNetAmount = item.netAmount+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ const formattedPreTaxAmount = item.preTaxAmount+ .toLocaleString("en-US", {+ minimumFractionDigits: 2,+ maximumFractionDigits: 2,+ })+ .replaceAll(",", " ");++ return (+ <View style={styles.tableRow} key={index}>+ {/* VAT rate */}+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {isNaN(Number(item.vat)) ? item.vat : `${item.vat}%`}+ </Text>+ </View>+ {/* Net */}+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {formattedNetAmount}+ </Text>+ </View>+ {/* VAT */}+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {typeof item.vatAmount === "number"+ ? item.vatAmount.toFixed(2)+ : "0.00"}+ </Text>+ </View>+ {/* Pre-tax */}+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[+ styles.tableCell,+ { textAlign: "right", marginRight: 2 },+ ]}+ >+ {formattedPreTaxAmount}+ </Text>+ </View>+ </View>+ );+ })}++ {/* Total row */}+ <View style={styles.tableRow}>+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[styles.tableCell, { textAlign: "right", marginRight: 2 }]}+ >+ {t.vatSummaryTable.total}+ </Text>+ </View>+ {/* Net */}+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[styles.tableCell, { textAlign: "right", marginRight: 2 }]}+ >+ {formattedTotalNetAmount}+ </Text>+ </View>+ {/* VAT */}+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[styles.tableCell, { textAlign: "right", marginRight: 2 }]}+ >+ {formattedTotalVATAmount}+ </Text>+ </View>+ {/* Pre-tax */}+ <View style={[styles.tableCol, { width: "25%" }]}>+ <Text+ style={[styles.tableCell, { textAlign: "right", marginRight: 2 }]}+ >+ {formattedInvoiceTotal}+ </Text>+ </View>+ </View>+ </View>+ );+}diff --git a/src/app/components/invoice-pdf-template/translations/index.ts b/src/app/components/invoice-pdf-template/translations/index.tsnew file mode 100644index 0000000..adbeb46--- /dev/null+++ b/src/app/components/invoice-pdf-template/translations/index.ts@@ -0,0 +1,157 @@+import type { SupportedLanguages } from "@/app/schema/index";++// Add this interface before the translations object+interface TranslationSchema {+ invoiceNumber: string;+ dateOfIssue: string;+ dateOfService: string;+ invoiceType: string;+ seller: {+ name: string;+ vatNo: string;+ email: string;+ accountNumber: string;+ swiftBic: string;+ };+ buyer: {+ name: string;+ vatNo: string;+ email: string;+ };+ invoiceItemsTable: {+ no: string;+ nameOfGoodsService: string;+ typeOfGTU: string;+ amount: string;+ unit: string;+ netPrice: string;+ vat: string;+ netAmount: string;+ vatAmount: string;+ preTaxAmount: string;+ sum: string;+ };+ paymentInfo: {+ paymentMethod: string;+ paymentDate: string;+ };+ vatSummaryTable: {+ vatRate: string;+ net: string;+ vat: string;+ preTax: string;+ total: string;+ };+ paymentTotals: {+ toPay: string;+ paid: string;+ leftToPay: string;+ amountInWords: string;+ };+ personAuthorizedToReceive: string;+ personAuthorizedToIssue: string;+}++// Update the type assertion+export const translations = {+ en: {+ invoiceNumber: "Invoice No. of",+ dateOfIssue: "Date of issue",+ dateOfService: "Date of sales/of executing the service",+ invoiceType: "Invoice Type",+ seller: {+ name: "Seller",+ vatNo: "VAT no:",+ email: "e-mail",+ accountNumber: "Account Number",+ swiftBic: "SWIFT/BIC number",+ },+ buyer: {+ name: "Buyer",+ vatNo: "VAT no:",+ email: "e-mail",+ },+ invoiceItemsTable: {+ no: "No",+ nameOfGoodsService: "Name of goods/service",+ typeOfGTU: "Type of GTU",+ amount: "Amount",+ unit: "Unit",+ netPrice: "Net price",+ vat: "VAT",+ netAmount: "Net Amount",+ vatAmount: "VAT Amount",+ preTaxAmount: "Pre-tax amount",+ sum: "SUM",+ },+ paymentInfo: {+ paymentMethod: "Payment method",+ paymentDate: "Payment date",+ },+ vatSummaryTable: {+ vatRate: "VAT rate",+ net: "Net",+ vat: "VAT",+ preTax: "Pre-tax",+ total: "Total",+ },+ paymentTotals: {+ toPay: "To pay",+ paid: "Paid",+ leftToPay: "Left to pay",+ amountInWords: "Amount in words",+ },+ personAuthorizedToReceive: "Person authorized to receive",+ personAuthorizedToIssue: "Person authorized to issue",+ },+ pl: {+ invoiceNumber: "Faktura nr",+ dateOfIssue: "Data wystawienia",+ dateOfService: "Data sprzedaży / wykonania usługi",+ invoiceType: "Typ faktury",+ seller: {+ name: "Sprzedawca",+ vatNo: "NIP",+ email: "E-mail",+ accountNumber: "Nr konta",+ swiftBic: "Nr SWIFT/BIC",+ },+ buyer: {+ name: "Nabywca",+ vatNo: "NIP",+ email: "E-mail",+ },+ invoiceItemsTable: {+ no: "lp.",+ nameOfGoodsService: "Nazwa towaru/usługi",+ typeOfGTU: "Typ GTU",+ amount: "Ilość",+ unit: "Jm",+ netPrice: "Cena netto",+ vat: "VAT",+ netAmount: "Kwota netto",+ vatAmount: "Kwota VAT",+ preTaxAmount: "Kwota brutto",+ sum: "SUMA",+ },+ paymentInfo: {+ paymentMethod: "Sposób wpłaty",+ paymentDate: "Termin zapłaty",+ },+ vatSummaryTable: {+ vatRate: "Stawka VAT",+ net: "Netto",+ vat: "VAT",+ preTax: "Brutto",+ total: "Razem",+ },+ paymentTotals: {+ toPay: "Razem do zapłaty",+ paid: "Wpłacono",+ leftToPay: "Pozostało do zapłaty",+ amountInWords: "Kwota słownie",+ },+ personAuthorizedToReceive: "Osoba upoważniona do odbioru",+ personAuthorizedToIssue: "Osoba upoważniona do wystawienia",+ },+} as const satisfies Record<SupportedLanguages, TranslationSchema>;diff --git a/src/app/components/invoice-pdf-viewer.tsx b/src/app/components/invoice-pdf-viewer.tsxnew file mode 100644index 0000000..9b3b7e3--- /dev/null+++ b/src/app/components/invoice-pdf-viewer.tsx@@ -0,0 +1,14 @@+import { PDFViewer } from "@react-pdf/renderer";++export function InvoicePDFViewer({ children }: { children: React.ReactNode }) {+ return (+ <PDFViewer+ width="100%"+ height="650px"+ className="mb-4 h-[600px] lg:h-[650px]"+ >+ {/* @ts-expect-error PR with fix?: https://github.com/diegomura/react-pdf/pull/2888 */}+ {children}+ </PDFViewer>+ );+}diff --git a/src/app/fonts/GeistMonoVF.woff b/src/app/fonts/GeistMonoVF.woffdeleted file mode 100644index f2ae185..0000000Binary files a/src/app/fonts/GeistMonoVF.woff and /dev/null differdiff --git a/src/app/fonts/GeistVF.woff b/src/app/fonts/GeistVF.woffdeleted file mode 100644index 1b62daa..0000000Binary files a/src/app/fonts/GeistVF.woff and /dev/null differdiff --git a/src/app/layout.tsx b/src/app/layout.tsxindex a36cde0..82d4b88 100644--- a/src/app/layout.tsx+++ b/src/app/layout.tsx@@ -1,17 +1,7 @@import type { Metadata } from "next";-import localFont from "next/font/local";-import "./globals.css";+import { NuqsAdapter } from "nuqs/adapters/next/app";-const geistSans = localFont({- src: "./fonts/GeistVF.woff",- variable: "--font-geist-sans",- weight: "100 900",-});-const geistMono = localFont({- src: "./fonts/GeistMonoVF.woff",- variable: "--font-geist-mono",- weight: "100 900",-});+import "./globals.css";export const metadata: Metadata = {title: "Create Next App",@@ -25,10 +15,8 @@ export default function RootLayout({}>) {return (<html lang="en">- <body- className={`${geistSans.variable} ${geistMono.variable} antialiased`}- >- {children}+ <body className={`antialiased`}>+ <NuqsAdapter>{children}</NuqsAdapter></body></html>);diff --git a/src/app/page.tsx b/src/app/page.tsxindex 6fe62d1..ab7cad2 100644--- a/src/app/page.tsx+++ b/src/app/page.tsx@@ -1,101 +1,217 @@-import Image from "next/image";+"use client";++import {+ invoiceSchema,+ SUPPORTED_LANGUAGES,+ type InvoiceData,+} from "@/app/schema";+import { startTransition, useEffect } from "react";+import {+ InvoiceForm,+ PDF_DATA_LOCAL_STORAGE_KEY,+} from "./components/invoice-form";+import { SUPPORTED_CURRENCIES } from "@/app/schema";+import dayjs from "dayjs";+import { useQueryState } from "nuqs";+import dynamic from "next/dynamic";+import { InvoicePdfTemplate } from "./components/invoice-pdf-template";+import {+ compressToEncodedURIComponent,+ decompressFromEncodedURIComponent,+} from "lz-string";++const InvoicePDFDownloadLink = dynamic(+ () =>+ import("./components/invoice-pdf-download-link").then(+ (mod) => mod.InvoicePDFDownloadLink+ ),++ {+ ssr: false,+ loading: () => (+ <div className="mb-4 lg:mb-0 w-full lg:w-[180px] text-center px-4 py-2 text-white bg-blue-500 rounded hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-50">+ Loading document...+ </div>+ ),+ }+);++const InvoicePDFViewer = dynamic(+ () =>+ import("./components/invoice-pdf-viewer").then(+ (mod) => mod.InvoicePDFViewer+ ),++ {+ ssr: false,+ loading: () => <div className="">Loading pdf viewer...</div>,+ }+);++const today = dayjs().format("YYYY-MM-DD");+const lastDayOfMonth = dayjs().endOf("month").format("YYYY-MM-DD");+const invoiceCurrentMonthAndYear = dayjs().format("MM-YYYY");+const paymentDue = dayjs(today).add(14, "days").format("YYYY-MM-DD");++const EUR = SUPPORTED_CURRENCIES[0];+const EN = SUPPORTED_LANGUAGES[0];++const initialInvoiceData = {+ language: EN,+ currency: EUR,+ invoiceNumber: `1/${invoiceCurrentMonthAndYear}`,+ dateOfIssue: today,+ dateOfService: lastDayOfMonth,+ invoiceType: "Reverse Charge",+ seller: {+ name: "Seller name",+ address: "Seller address",+ vatNo: "Seller vat number",+ email: "[email protected]",+ accountNumber: "Seller account number",+ swiftBic: "Seller swift bic",+ },+ buyer: {+ name: "Buyer name",+ address: "Buyer address",+ vatNo: "Buyer vat number",+ email: "[email protected]",+ },+ items: [+ {+ name: "Item name",+ amount: 1,+ unit: "service",+ netPrice: 0,+ vat: "NP",+ netAmount: 0,+ vatAmount: 0.0,+ preTaxAmount: 0,+ },+ ],+ total: 0,+ paymentMethod: "wire transfer",+ paymentDue: paymentDue,+ notes: "Reverse charge",+} as const satisfies InvoiceData;export default function Home() {+ const [invoiceDataParam, setInvoiceDataParam] = useQueryState("data", {+ parse: (value: string) => {+ try {+ // Decompress the URL parameter before parsing+ const decompressed = decompressFromEncodedURIComponent(value);++ const parsed = JSON.parse(decompressed);+ const validated = invoiceSchema.parse(parsed);++ return validated;+ } catch {+ return null;+ }+ },+ serialize: (value: InvoiceData | null) => {+ if (!value) return "";++ const stringified = JSON.stringify(value);++ // Compress the data before adding to URL+ const compressed = compressToEncodedURIComponent(stringified);++ return compressed;+ },+ defaultValue: null,+ });++ // Initialize data from localStorage only if URL param is not present+ useEffect(() => {+ if (!invoiceDataParam) {+ try {+ const savedData = localStorage.getItem(PDF_DATA_LOCAL_STORAGE_KEY);+ if (savedData) {+ const parsedData = invoiceSchema.parse(JSON.parse(savedData));+ setInvoiceDataParam(parsedData);+ } else {+ setInvoiceDataParam(initialInvoiceData);+ }+ } catch (error) {+ console.error("Failed to load saved invoice data:", error);+ alert("Failed to load saved invoice data");+ setInvoiceDataParam(initialInvoiceData);+ }+ }+ }, [invoiceDataParam, setInvoiceDataParam]); // Only run on mount++ // Sync URL data to localStorage whenever URL params change+ useEffect(() => {+ if (invoiceDataParam) {+ try {+ localStorage.setItem(+ PDF_DATA_LOCAL_STORAGE_KEY,+ JSON.stringify(invoiceDataParam)+ );+ } catch (error) {+ console.error("Failed to save invoice data:", error);+ alert("Failed to save invoice data");+ }+ }+ }, [invoiceDataParam]);++ const handleInvoiceDataChange = (updatedData: InvoiceData) => {+ startTransition(() => {+ setInvoiceDataParam(updatedData);+ });+ };++ if (!invoiceDataParam) {+ return null;+ }+return (- <div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">- <main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">- <Image- className="dark:invert"- src="https://nextjs.org/icons/next.svg"- alt="Next.js logo"- width={180}- height={38}- priority- />- <ol className="list-inside list-decimal text-sm text-center sm:text-left font-[family-name:var(--font-geist-mono)]">- <li className="mb-2">- Get started by editing{" "}- <code className="bg-black/[.05] dark:bg-white/[.06] px-1 py-0.5 rounded font-semibold">- src/app/page.tsx- </code>- .- </li>- <li>Save and see your changes instantly.</li>- </ol>-- <div className="flex gap-4 items-center flex-col sm:flex-row">- <a- className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"- href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"- target="_blank"- rel="noopener noreferrer"- >- <Image- className="dark:invert"- src="https://nextjs.org/icons/vercel.svg"- alt="Vercel logomark"- width={20}- height={20}- />- Deploy now- </a>- <a- className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 sm:min-w-44"- href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"- target="_blank"- rel="noopener noreferrer"- >- Read our docs- </a>+ <div className="flex flex-col items-center justify-center min-h-screen bg-gray-100 p-4">+ <div className="bg-white p-6 rounded-lg shadow-lg w-full max-w-7xl">+ <div className="flex flex-row flex-wrap lg:flex-nowrap items-center justify-between w-full">+ <h1 className="text-2xl font-bold mb-4 w-full text-center lg:text-left">+ Free PDF Invoice Generator+ </h1>++ <div className="w-full flex justify-center flex-wrap lg:flex-nowrap lg:justify-end gap-3 mb-1">+ <button+ onClick={() => {+ navigator.clipboard+ .writeText(window.location.href)+ .then(() => {+ alert("URL copied to clipboard!");+ })+ .catch((err) => {+ console.error("Failed to copy URL:", err);+ alert("Failed to copy URL to clipboard");+ });+ }}+ className="inline-flex w-full lg:w-auto justify-center items-center px-4 py-2 bg-gray-100 hover:bg-gray-200 text-gray-800 rounded-md"+ >+ Copy link to invoice+ </button>+ <InvoicePDFDownloadLink invoiceData={invoiceDataParam} />+ </div>+ </div>++ <div className="grid grid-cols-1 lg:grid-cols-12 gap-4">+ <div className="lg:col-span-4">+ <div className="h-[400px] lg:h-[600px] overflow-auto p-3">+ <InvoiceForm+ invoiceData={invoiceDataParam}+ onInvoiceDataChange={handleInvoiceDataChange}+ />+ </div>+ </div>+ <div className="lg:col-span-8 h-[600px] lg:h-[630px]">+ <InvoicePDFViewer>+ <InvoicePdfTemplate invoiceData={invoiceDataParam} />+ </InvoicePDFViewer>+ </div></div>- </main>- <footer className="row-start-3 flex gap-6 flex-wrap items-center justify-center">- <a- className="flex items-center gap-2 hover:underline hover:underline-offset-4"- href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"- target="_blank"- rel="noopener noreferrer"- >- <Image- aria-hidden- src="https://nextjs.org/icons/file.svg"- alt="File icon"- width={16}- height={16}- />- Learn- </a>- <a- className="flex items-center gap-2 hover:underline hover:underline-offset-4"- href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"- target="_blank"- rel="noopener noreferrer"- >- <Image- aria-hidden- src="https://nextjs.org/icons/window.svg"- alt="Window icon"- width={16}- height={16}- />- Examples- </a>- <a- className="flex items-center gap-2 hover:underline hover:underline-offset-4"- href="https://nextjs.org?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"- target="_blank"- rel="noopener noreferrer"- >- <Image- aria-hidden- src="https://nextjs.org/icons/globe.svg"- alt="Globe icon"- width={16}- height={16}- />- Go to nextjs.org →- </a>- </footer>+ </div></div>);}diff --git a/src/app/schema/index.ts b/src/app/schema/index.tsnew file mode 100644index 0000000..308d69e--- /dev/null+++ b/src/app/schema/index.ts@@ -0,0 +1,95 @@+import { z } from "zod";++export const SUPPORTED_CURRENCIES = ["EUR", "USD", "GBP", "PLN"] as const;++export const SUPPORTED_LANGUAGES = ["en", "pl"] as const;+export type SupportedLanguages = (typeof SUPPORTED_LANGUAGES)[number];++export const invoiceItemSchema = z+ .object({+ name: z.string().min(1, "Item name is required").trim(),+ amount: z+ .any()+ .refine((val) => val !== "", {+ message: "Amount is required",+ })+ .transform(Number)+ .refine((val) => val > 0, {+ message: "Amount must be positive",+ }),+ unit: z.string().min(1, "Unit is required").trim(),+ netPrice: z+ .any()+ .refine((val) => val !== "", {+ message: "Net price is required",+ })+ .transform(Number)+ .refine((val) => val >= 0, {+ message: "Net price must be non-negative",+ }),+ vat: z.union([+ z.enum(["NP", "OO"]),+ z+ .any()+ .refine((val) => val !== "", {+ message: "VAT is required",+ })+ .refine((val) => !isNaN(Number(val)), {+ message: "Must be a valid number or `NP`/`OO`",+ })+ .transform(Number)+ .refine((val) => val >= 0 && val <= 100, {+ message: "VAT must be between 0 and 100",+ }),+ ]),+ netAmount: z.coerce.number().nonnegative("Net amount must be non-negative"),+ vatAmount: z.coerce.number().nonnegative("VAT amount must be non-negative"),+ preTaxAmount: z.coerce+ .number()+ .nonnegative("Pre-tax amount must be non-negative"),+ })+ .strict();++export type InvoiceItemData = z.infer<typeof invoiceItemSchema>;++export const invoiceSchema = z.object({+ language: z.enum(SUPPORTED_LANGUAGES).default("en"),+ invoiceNumber: z.string().min(1, "Invoice number is required").trim(),+ dateOfIssue: z.string().min(1, "Date of issue is required").trim(),+ dateOfService: z.string().min(1, "Date of service is required").trim(),+ invoiceType: z.string().trim().optional(),+ seller: z.object({+ name: z.string().min(1, "Seller name is required").trim(),+ address: z.string().min(1, "Seller address is required").trim(),+ vatNo: z.string().min(1, "VAT number is required").trim(),+ email: z.string().email("Invalid email address").trim(),+ accountNumber: z.string().min(1, "Account number is required").trim(),+ swiftBic: z.string().min(1, "SWIFT/BIC is required").trim(),+ }),+ buyer: z.object({+ name: z.string().min(1, "Buyer name is required").trim(),+ address: z.string().min(1, "Buyer address is required").trim(),+ vatNo: z.string().min(1, "VAT number is required").trim(),+ email: z.string().email("Invalid email address").trim(),+ }),+ items: z.array(invoiceItemSchema).min(1, "At least one item is required"),+ total: z.coerce.number().nonnegative("Total must be non-negative"),+ paymentMethod: z.string().min(1, "Payment method is required").trim(),+ paymentDue: z.string().min(1, "Payment due is required").trim(),+ currency: z.enum(SUPPORTED_CURRENCIES).default("EUR"),+ notes: z.string().trim().optional(),+});++export type InvoiceData = z.infer<typeof invoiceSchema>;++// https://github.com/colinhacks/zod/discussions/2814#discussioncomment-7121769+// const zodInputStringPipe = (zodPipe: ZodTypeAny) =>+// z+// .string()+// .transform((value) => (value === "" ? null : value))+// .nullable()+// .refine((value) => value === null || !isNaN(Number(value)), {+// message: "Nombre Invalide",+// })+// .transform((value) => (value === null ? 0 : Number(value)))+// .pipe(zodPipe);