This commit is contained in:
Bastien COIGNOUX
2026-05-03 20:18:33 +02:00
parent ffc2e6b895
commit bd325fe456
113 changed files with 29532 additions and 220 deletions

View File

@ -0,0 +1,32 @@
import * as Print from 'expo-print';
import * as Sharing from 'expo-sharing';
import { Platform } from 'react-native';
export async function sharePurchaseOfferPdf(params: {
propertyTitle: string;
address: string;
maxBuyPriceEur: number;
sellerName?: string;
}): Promise<void> {
const html = `<!DOCTYPE html><html lang="fr"><head><meta charset="utf-8"/>
<style>body{font-family:system-ui;padding:32px;color:#111}
h1{font-size:22px} .box{border:1px solid #ccc;padding:16px;border-radius:8px;margin-top:16px}
</style></head><body>
<h1>Offre d'achat — ${escape(params.propertyTitle)}</h1>
<p>${escape(params.address)}</p>
<div class="box">
<p>Montant de l'offre : <strong>${params.maxBuyPriceEur.toLocaleString('fr-FR')} €</strong></p>
<p>(${params.sellerName ? `Destinataire : ${escape(params.sellerName)}` : 'À compléter'})</p>
</div>
<p style="margin-top:24px;font-size:11px;color:#666">MDB-PREDATOR — modèle indicatif, valider avec votre notaire / juriste.</p>
</body></html>`;
const { uri } = await Print.printToFileAsync({ html });
if (Platform.OS === 'web') return;
if (await Sharing.isAvailableAsync()) {
await Sharing.shareAsync(uri, { mimeType: 'application/pdf', dialogTitle: 'Offre dachat' });
}
}
function escape(s: string): string {
return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
}