feat(pdf): make footer email and website clickable
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import {
|
||||
Document,
|
||||
Image,
|
||||
Link,
|
||||
Page,
|
||||
StyleSheet,
|
||||
Text,
|
||||
@@ -479,8 +480,16 @@ function Footer({ issuer, language }: { issuer: IssuerData; language: InvoiceLan
|
||||
<View style={styles.footerCol}>
|
||||
<Text style={styles.footerHeading}>{t.contactHeading}</Text>
|
||||
{issuer.phone ? <Text>{t.phoneLabel}: {issuer.phone}</Text> : null}
|
||||
{issuer.email ? <Text>{t.emailLabel}: {issuer.email}</Text> : null}
|
||||
{issuer.website ? <Text>{t.webLabel}: {issuer.website}</Text> : null}
|
||||
{issuer.email ? (
|
||||
<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 style={styles.footerCol}>
|
||||
<Text style={styles.footerHeading}>{t.legalHeading}</Text>
|
||||
@@ -514,3 +523,14 @@ function pickFooterNote(issuer: { footerNote: string; footerNoteEn: string }, la
|
||||
}
|
||||
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