mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-03 06:27:19 +01:00
always consider empty strings as no value given
This commit is contained in:
@@ -11,10 +11,23 @@ import { IDocProps } from '../interfaces/IDocProps'
|
|||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [options, setOptions] = useState<IDocProps>({
|
const [options, setOptions] = useState<IDocProps>({
|
||||||
|
address: 'Max Mustermann\\\\Musterstrasse\\\\12345 Musterstadt',
|
||||||
|
body: 'Inhalt des Briefs',
|
||||||
|
closing: 'Mit freundlichen Grüßen',
|
||||||
|
customer: '',
|
||||||
|
date: new Date().toLocaleDateString('de-DE'),
|
||||||
|
enclosing: '',
|
||||||
|
invoice: '',
|
||||||
|
myRef: '',
|
||||||
|
opening: 'Sehr geehrte Damen und Herren',
|
||||||
|
ps: '',
|
||||||
|
signature: '',
|
||||||
|
specialMail: '',
|
||||||
|
subject: 'Betreffzeile',
|
||||||
template: 'brief-fam',
|
template: 'brief-fam',
|
||||||
subject: '',
|
yourMail: '',
|
||||||
body: '',
|
yourRef: '',
|
||||||
address: '',
|
yourRefName: '',
|
||||||
})
|
})
|
||||||
const [latest, setLatest] = useState<ILatest[]>([])
|
const [latest, setLatest] = useState<ILatest[]>([])
|
||||||
const [pdfUrl, setPdfUrl] = useState<string | null>(null)
|
const [pdfUrl, setPdfUrl] = useState<string | null>(null)
|
||||||
@@ -32,7 +45,7 @@ export default function App() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const value = event && event.target && event.target.value
|
const value = event && event.target && event.target.value
|
||||||
setOptions({ ...options, [name]: value || undefined })
|
setOptions({ ...options, [name]: value })
|
||||||
}
|
}
|
||||||
|
|
||||||
const _onSelectLatest = (selectedOption: ILatest) => {
|
const _onSelectLatest = (selectedOption: ILatest) => {
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
export interface IDocProps {
|
export interface IDocProps {
|
||||||
template: string
|
|
||||||
subject: string
|
|
||||||
body: string
|
|
||||||
address: string
|
address: string
|
||||||
date?: string
|
body: string
|
||||||
opening?: string
|
closing: string
|
||||||
closing?: string
|
customer: string
|
||||||
yourRef?: string
|
date: string
|
||||||
yourMail?: string
|
enclosing: string
|
||||||
myRef?: string
|
invoice: string
|
||||||
customer?: string
|
myRef: string
|
||||||
invoice?: string
|
opening: string
|
||||||
specialMail?: string
|
ps: string
|
||||||
|
signature: string
|
||||||
|
specialMail: string
|
||||||
|
subject: string
|
||||||
|
template: string
|
||||||
|
yourMail: string
|
||||||
|
yourRef: string
|
||||||
|
yourRefName: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,23 +6,23 @@ function convertLineBreaks(lines: string) {
|
|||||||
|
|
||||||
export function brief(options: IDocProps) {
|
export function brief(options: IDocProps) {
|
||||||
const {
|
const {
|
||||||
template = 'brief-fam',
|
template,
|
||||||
subject = '',
|
subject,
|
||||||
yourRef = '',
|
yourRef,
|
||||||
yourRefName = 'Ihr Zeichen',
|
yourRefName,
|
||||||
yourMail = '',
|
yourMail,
|
||||||
myRef = '',
|
myRef,
|
||||||
customer = '',
|
customer,
|
||||||
invoice = '',
|
invoice,
|
||||||
date = '\\today',
|
date,
|
||||||
signature = '',
|
signature,
|
||||||
specialMail = '',
|
specialMail,
|
||||||
address = 'Max Mustermann\\\\Musterstrasse\\\\12345 Musterstadt',
|
address,
|
||||||
opening = 'Sehr geehrte Damen und Herren',
|
opening,
|
||||||
body = '',
|
body,
|
||||||
closing = 'Mit freundlichen Grüßen',
|
closing,
|
||||||
ps = '',
|
ps,
|
||||||
enclosing = '',
|
enclosing,
|
||||||
} = { ...options }
|
} = { ...options }
|
||||||
|
|
||||||
return `% brief document
|
return `% brief document
|
||||||
@@ -31,17 +31,15 @@ export function brief(options: IDocProps) {
|
|||||||
|
|
||||||
\\setkomavar{subject}{${subject}}
|
\\setkomavar{subject}{${subject}}
|
||||||
|
|
||||||
\\setkomavar{yourref}[${yourRefName}]{${yourRef}}
|
${yourRef ? `\\setkomavar{yourref}[${yourRefName}]{${yourRef}}` : ''}
|
||||||
\\setkomavar{yourmail}{${yourMail}}
|
${yourMail ? `\\setkomavar{yourmail}{${yourMail}}` : ''}
|
||||||
\\setkomavar{myref}{${myRef}}
|
${myRef ? `\\setkomavar{myref}{${myRef}}` : ''}
|
||||||
\\setkomavar{customer}{${customer}}
|
${customer ? `\\setkomavar{customer}{${customer}}` : ''}
|
||||||
\\setkomavar{invoice}{${invoice}}
|
${invoice ? `\\setkomavar{invoice}{${invoice}}` : ''}
|
||||||
|
${signature ? `\\setkomavar{signature}{${signature}}` : ''}
|
||||||
|
${specialMail ? `\\setkomavar{specialmail}{${specialMail}}` : ''}
|
||||||
|
|
||||||
\\setkomavar{date}{${date}}
|
${date ? `\\setkomavar{date}{${date}}` : ''}
|
||||||
|
|
||||||
%\\setkomavar{signature}{${signature}}
|
|
||||||
|
|
||||||
\\setkomavar{specialmail}{${specialMail}}
|
|
||||||
|
|
||||||
\\begin{document}
|
\\begin{document}
|
||||||
\\begin{letter}{${convertLineBreaks(address)}}
|
\\begin{letter}{${convertLineBreaks(address)}}
|
||||||
@@ -52,9 +50,9 @@ export function brief(options: IDocProps) {
|
|||||||
|
|
||||||
\\closing{${closing}}
|
\\closing{${closing}}
|
||||||
|
|
||||||
\\ps{${ps}}
|
${ps ? `\\ps{${ps}}` : ''}
|
||||||
|
|
||||||
%\\encl{${enclosing}}
|
${enclosing ? `\\encl{${enclosing}}` : ''}
|
||||||
|
|
||||||
\\end{letter}
|
\\end{letter}
|
||||||
\\end{document}`
|
\\end{document}`
|
||||||
|
|||||||
Reference in New Issue
Block a user