chore: bump version to 0.8.95 and update legal documents features
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 15s
Test Suite / playwright-tests (push) Successful in 56s
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 15s
Test Suite / playwright-tests (push) Successful in 56s
- Updated app version to 0.8.95 with a new build date of 2026-05-12. - Enhanced legal documents functionality to support section numbering and Markdown formatting in the output. - Updated dependencies in package.json to include 'marked' and 'react-markdown'. - Added new CSS styles for legal document presentation. - Refactored PDF generation logic to incorporate new metadata and improved document structure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
04663e090a
commit
81b9e8f601
7 files changed
+533
-163
No files matched your search
@@ -1,76 +1,9 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { jsPDF } from 'jspdf'
|
||||
import LegalDocumentBody from '../components/LegalDocumentBody'
|
||||
import { generateLegalPdf, legalSectionNumber } from '../utils/legalPdfExport'
|
||||
import api from '../utils/api'
|
||||
|
||||
function generateLegalPdf(doc) {
|
||||
const pdf = new jsPDF({ format: 'a4', unit: 'mm' })
|
||||
const marginL = 22, marginR = 22, marginTop = 28, pageW = 210
|
||||
const contentW = pageW - marginL - marginR
|
||||
const bottomLimit = 277
|
||||
let y = marginTop
|
||||
|
||||
const checkBreak = (need) => {
|
||||
if (y + need > bottomLimit) { pdf.addPage(); y = marginTop }
|
||||
}
|
||||
|
||||
pdf.setFont('helvetica', 'bold')
|
||||
pdf.setFontSize(20)
|
||||
pdf.text(doc.title, marginL, y)
|
||||
y += 10
|
||||
|
||||
const dateStr = doc.published_at
|
||||
? new Date(doc.published_at).toLocaleDateString('de-DE')
|
||||
: new Date(doc.updated_at || doc.created_at).toLocaleDateString('de-DE')
|
||||
const metaLine = `Version ${doc.version} | Gueltig seit ${dateStr}`
|
||||
|
||||
pdf.setFont('helvetica', 'normal')
|
||||
pdf.setFontSize(10)
|
||||
pdf.setTextColor(90, 90, 90)
|
||||
pdf.text(metaLine, marginL, y)
|
||||
y += 3
|
||||
pdf.setDrawColor(0, 0, 0)
|
||||
pdf.setLineWidth(0.4)
|
||||
pdf.line(marginL, y, pageW - marginR, y)
|
||||
y += 8
|
||||
pdf.setTextColor(0, 0, 0)
|
||||
|
||||
for (const section of (doc.content_sections || [])) {
|
||||
checkBreak(14)
|
||||
pdf.setFont('helvetica', 'bold')
|
||||
pdf.setFontSize(11)
|
||||
pdf.text(section.heading || '', marginL, y)
|
||||
y += 6
|
||||
if (section.content) {
|
||||
pdf.setFont('helvetica', 'normal')
|
||||
pdf.setFontSize(10)
|
||||
const lines = pdf.splitTextToSize(section.content, contentW)
|
||||
for (const line of lines) {
|
||||
checkBreak(5)
|
||||
pdf.text(line, marginL, y)
|
||||
y += 5
|
||||
}
|
||||
}
|
||||
y += 5
|
||||
}
|
||||
|
||||
const total = pdf.getNumberOfPages()
|
||||
for (let i = 1; i <= total; i++) {
|
||||
pdf.setPage(i)
|
||||
pdf.setFont('helvetica', 'normal')
|
||||
pdf.setFontSize(8)
|
||||
pdf.setTextColor(150, 150, 150)
|
||||
const fy = 289
|
||||
pdf.text(
|
||||
`Shinkan Jinkendo | Exportiert am ${new Date().toLocaleDateString('de-DE')}`,
|
||||
marginL, fy
|
||||
)
|
||||
pdf.text(`Seite ${i} von ${total}`, pageW - marginR, fy, { align: 'right' })
|
||||
}
|
||||
|
||||
pdf.save(`${doc.document_type}_v${doc.version}.pdf`)
|
||||
}
|
||||
|
||||
// document_type values used in the DB / API
|
||||
const TYPE_MAP = {
|
||||
impressum: 'impressum',
|
||||
@@ -283,7 +216,13 @@ function LegalPage({ type }) {
|
||||
<h1 style={{ margin: 0, color: 'var(--text1)' }}>{title}</h1>
|
||||
{apiDoc && (
|
||||
<button
|
||||
onClick={() => generateLegalPdf(apiDoc)}
|
||||
onClick={() => {
|
||||
const dateStr = apiDoc.published_at
|
||||
? new Date(apiDoc.published_at).toLocaleDateString('de-DE')
|
||||
: new Date(apiDoc.updated_at || apiDoc.created_at).toLocaleDateString('de-DE')
|
||||
const metaLine = `Version ${apiDoc.version} | Gueltig seit ${dateStr}`
|
||||
generateLegalPdf(apiDoc, metaLine)
|
||||
}}
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '0.82rem', padding: '4px 12px', flexShrink: 0 }}
|
||||
>
|
||||
@@ -295,11 +234,11 @@ function LegalPage({ type }) {
|
||||
{sections.map((section, i) => (
|
||||
<div key={i} style={{ marginBottom: '1.75rem' }}>
|
||||
<h2 style={{ fontSize: '1.05rem', marginBottom: '0.4rem', color: 'var(--text1)' }}>
|
||||
{section.heading}
|
||||
{section.heading
|
||||
? `${legalSectionNumber(i)} ${section.heading}`
|
||||
: legalSectionNumber(i)}
|
||||
</h2>
|
||||
<p style={{ color: isPlaceholder ? 'var(--text3)' : 'var(--text1)', fontStyle: isPlaceholder ? 'italic' : 'normal', margin: 0, whiteSpace: 'pre-wrap' }}>
|
||||
{section.content}
|
||||
</p>
|
||||
<LegalDocumentBody content={section.content} muted={isPlaceholder} />
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
|
||||
Reference in new issue
Block a user