chore: remove all unicode emojis project-wide and sanitize pdf text
This commit is contained in:
@@ -94,6 +94,14 @@ const styles = StyleSheet.create({
|
||||
}
|
||||
});
|
||||
|
||||
export const stripEmojis = (text?: string | null): string => {
|
||||
if (!text) return '';
|
||||
return text
|
||||
.replace(/[\p{Emoji_Presentation}\p{Extended_Pictographic}\uFE0F\u200D]/gu, '')
|
||||
.replace(/\s{2,}/g, ' ')
|
||||
.trim();
|
||||
};
|
||||
|
||||
export const InvoicePDF = ({
|
||||
order,
|
||||
orderSnapshot,
|
||||
@@ -105,7 +113,7 @@ export const InvoicePDF = ({
|
||||
const items = orderSnapshot?.items ?? [];
|
||||
const taxRate = orderSnapshot?.tax_rate ?? 19;
|
||||
const isSubscription = order?.type === 'subscription' || orderSnapshot?.billing_cycle === 'monthly';
|
||||
const formattedOrderNumber = (order.order_number || order.id || '').replace(/^BE-/, 'AE-');
|
||||
const formattedOrderNumber = stripEmojis((order.order_number || order.id || '').replace(/^BE-/, 'AE-'));
|
||||
const isUpgrade = !!orderSnapshot?.last_license_date;
|
||||
|
||||
let oneTimeNet = 0;
|
||||
@@ -136,16 +144,16 @@ export const InvoicePDF = ({
|
||||
|
||||
const groupedItems: { [key: string]: any[] } = {};
|
||||
items.forEach((item: any) => {
|
||||
const devName = item.device_name || 'Kasse 1';
|
||||
const devName = stripEmojis(item.device_name || 'Kasse 1');
|
||||
if (!groupedItems[devName]) {
|
||||
groupedItems[devName] = [];
|
||||
}
|
||||
groupedItems[devName].push(item);
|
||||
});
|
||||
|
||||
const displayPartnerName = partnerCompanyName || order?.partner_company_name;
|
||||
const displayUserName = partnerUserName || order?.partner_user_name;
|
||||
const displayUserEmail = partnerUserEmail || order?.partner_user_email;
|
||||
const displayPartnerName = stripEmojis(partnerCompanyName || order?.partner_company_name);
|
||||
const displayUserName = stripEmojis(partnerUserName || order?.partner_user_name);
|
||||
const displayUserEmail = stripEmojis(partnerUserEmail || order?.partner_user_email);
|
||||
|
||||
return (
|
||||
<Document>
|
||||
@@ -170,11 +178,11 @@ export const InvoicePDF = ({
|
||||
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginBottom: 15 }}>
|
||||
<View style={{ width: '48%' }}>
|
||||
<Text style={styles.label}>Endkunde</Text>
|
||||
<Text style={{ fontWeight: 'bold' }}>{customer.company_name}</Text>
|
||||
{customer.first_name || customer.last_name ? <Text>{customer.first_name} {customer.last_name}</Text> : null}
|
||||
{customer.address ? <Text>{customer.address}</Text> : null}
|
||||
{customer.zip_code || customer.city ? <Text>{customer.zip_code} {customer.city}</Text> : null}
|
||||
{customer.vat_id ? <Text>USt-IdNr: {customer.vat_id}</Text> : null}
|
||||
<Text style={{ fontWeight: 'bold' }}>{stripEmojis(customer?.company_name)}</Text>
|
||||
{(customer?.first_name || customer?.last_name) ? <Text>{stripEmojis(`${customer?.first_name || ''} ${customer?.last_name || ''}`)}</Text> : null}
|
||||
{customer?.address ? <Text>{stripEmojis(customer.address)}</Text> : null}
|
||||
{(customer?.zip_code || customer?.city) ? <Text>{stripEmojis(`${customer?.zip_code || ''} ${customer?.city || ''}`)}</Text> : null}
|
||||
{customer?.vat_id ? <Text>USt-IdNr: {stripEmojis(customer.vat_id)}</Text> : null}
|
||||
</View>
|
||||
|
||||
<View style={{ width: '48%' }}>
|
||||
@@ -205,8 +213,8 @@ export const InvoicePDF = ({
|
||||
{devItems.map((item: any, idx: number) => (
|
||||
<View key={idx} style={{ marginBottom: 6 }}>
|
||||
<View style={{ flexDirection: 'row', justifyContent: 'space-between', marginBottom: 2 }}>
|
||||
<Text style={{ fontSize: 9, fontWeight: 'bold', color: '#334155' }}>
|
||||
{item.product_name} ({item.category_name})
|
||||
<Text style={{ fontSize: 9, fontWeight: 'bold', color: '#344155' }}>
|
||||
{stripEmojis(item.product_name)} ({stripEmojis(item.category_name)})
|
||||
</Text>
|
||||
<Text style={{ fontSize: 9, fontWeight: 'bold', color: '#0f172a' }}>
|
||||
{formattedPrice(item.base_price)} {item.billing_interval === 'one_time' ? 'einmalig' : 'mtl.'}
|
||||
@@ -218,7 +226,7 @@ export const InvoicePDF = ({
|
||||
return (
|
||||
<View key={mIdx} style={{ flexDirection: 'row', justifyContent: 'space-between', paddingLeft: 12, marginBottom: 1 }}>
|
||||
<Text style={{ fontSize: 8, color: '#64748b' }}>
|
||||
+ {mod.module_name} {qty > 1 ? `(x${qty})` : ''}
|
||||
+ {stripEmojis(mod.module_name)} {qty > 1 ? `(x${qty})` : ''}
|
||||
</Text>
|
||||
<Text style={{ fontSize: 8, color: '#64748b' }}>
|
||||
+{formattedPrice(price)} mtl.
|
||||
|
||||
Reference in New Issue
Block a user