From d5ffa81292c5ce22b828b59c5a126a1c29a7e7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Rame=CC=81?= Date: Thu, 2 Jan 2025 23:39:56 +0100 Subject: [PATCH] feat: implement the pdf declaration generation for sacem --- .storybook/document.tsx | 35 + .storybook/main.ts | 4 + next.config.js | 4 + package-lock.json | 854 +++++++++++++++++- package.json | 4 + .../assets/images/declaration/sacem_logo.png | Bin 0 -> 12907 bytes .../sacem/SacemDeclarationPage.stories.tsx | 4 + .../sacem/SacemDeclarationPage.tsx | 58 +- src/assets/fonts/index.css | 14 + .../layouts/StandardLayout.stories.tsx | 91 ++ .../documents/layouts/StandardLayout.tsx | 295 ++++++ src/components/documents/partials/.gitkeep | 0 .../templates/SacemDeclaration.stories.tsx | 41 + .../documents/templates/SacemDeclaration.tsx | 198 ++++ 14 files changed, 1554 insertions(+), 48 deletions(-) create mode 100644 .storybook/document.tsx create mode 100644 public/assets/images/declaration/sacem_logo.png create mode 100644 src/components/documents/layouts/StandardLayout.stories.tsx create mode 100644 src/components/documents/layouts/StandardLayout.tsx create mode 100644 src/components/documents/partials/.gitkeep create mode 100644 src/components/documents/templates/SacemDeclaration.stories.tsx create mode 100644 src/components/documents/templates/SacemDeclaration.tsx diff --git a/.storybook/document.tsx b/.storybook/document.tsx new file mode 100644 index 0000000..98de361 --- /dev/null +++ b/.storybook/document.tsx @@ -0,0 +1,35 @@ +import { usePDF } from '@react-pdf/renderer'; +import { StoryFn } from '@storybook/react'; +import React from 'react'; + +export const commonDocumentsParameters = { + layout: 'fullscreen', +}; + +export function WithDocumentRenderer(Story: StoryFn) { + const [instance, updateInstance] = usePDF({ + document: ( + <> + + + ), + }); + + if (instance.loading) { + return
Rendering the PDF...
; + } else if (instance.error) { + return
Something went wrong: {instance.error}
; + } else if (!instance.url) { + return
Initializing the renderer
; + } + + return ( +