feat(pdf): make footer email and website clickable
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
import {
|
import {
|
||||||
Document,
|
Document,
|
||||||
Image,
|
Image,
|
||||||
|
Link,
|
||||||
Page,
|
Page,
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Text,
|
Text,
|
||||||
@@ -479,8 +480,16 @@ function Footer({ issuer, language }: { issuer: IssuerData; language: InvoiceLan
|
|||||||
<View style={styles.footerCol}>
|
<View style={styles.footerCol}>
|
||||||
<Text style={styles.footerHeading}>{t.contactHeading}</Text>
|
<Text style={styles.footerHeading}>{t.contactHeading}</Text>
|
||||||
{issuer.phone ? <Text>{t.phoneLabel}: {issuer.phone}</Text> : null}
|
{issuer.phone ? <Text>{t.phoneLabel}: {issuer.phone}</Text> : null}
|
||||||
{issuer.email ? <Text>{t.emailLabel}: {issuer.email}</Text> : null}
|
{issuer.email ? (
|
||||||
{issuer.website ? <Text>{t.webLabel}: {issuer.website}</Text> : null}
|
<Text>
|
||||||
|
{t.emailLabel}: <Link src={`mailto:${issuer.email}`}>{issuer.email}</Link>
|
||||||
|
</Text>
|
||||||
|
) : null}
|
||||||
|
{issuer.website ? (
|
||||||
|
<Text>
|
||||||
|
{t.webLabel}: <Link src={normaliseWebUrl(issuer.website)}>{issuer.website}</Link>
|
||||||
|
</Text>
|
||||||
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.footerCol}>
|
<View style={styles.footerCol}>
|
||||||
<Text style={styles.footerHeading}>{t.legalHeading}</Text>
|
<Text style={styles.footerHeading}>{t.legalHeading}</Text>
|
||||||
@@ -514,3 +523,14 @@ function pickFooterNote(issuer: { footerNote: string; footerNoteEn: string }, la
|
|||||||
}
|
}
|
||||||
return issuer.footerNote || "";
|
return issuer.footerNote || "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a website URL safe for `<Link src="...">` — adds an `https://` scheme
|
||||||
|
* when the user typed something like `linumiq.com` or `www.linumiq.com`.
|
||||||
|
*/
|
||||||
|
function normaliseWebUrl(url: string): string {
|
||||||
|
const trimmed = url.trim();
|
||||||
|
if (!trimmed) return trimmed;
|
||||||
|
if (/^https?:\/\//i.test(trimmed)) return trimmed;
|
||||||
|
return `https://${trimmed.replace(/^\/\//, "")}`;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user