import Markdown from 'markdown-to-jsx'; import { Document, Image, Page, Text, StyleSheet, View, Link } from '@react-pdf/renderer'; import { Order, OrderConfirmationContent } from 'lib/shopify/types'; import { toPrintDate } from 'lib/utils'; const PDFPrice = ({ style, amount, currencyCode = 'USD' }: { style?: any; amount: string; currencyCode: string; }) => { const price = parseFloat(amount); // Return 'Included' if price is 0 if (price === 0) { return Free; } return ( {new Intl.NumberFormat(undefined, { style: 'currency', currency: currencyCode, currencyDisplay: 'narrowSymbol' }).format(price)} ); }; export default function OrderConfirmationPdf({ content, order, signature1, signature2, date }: { content: OrderConfirmationContent; order: Order; signature1: string; signature2: string; date: string; }) { const styles = StyleSheet.create({ logo: { width: 300, marginHorizontal: 'auto', marginBottom: 24 }, page: { padding: 48, paddingVertical: 64 }, h1: { fontSize: 18, fontWeight: 700, marginBottom: 12, color: content.color }, h2: { fontSize: 14, fontWeight: 700, marginBottom: 12, color: content.color }, h3: { fontSize: 12, fontWeight: 700, marginBottom: 12, color: content.color }, p: { fontSize: 10, marginBottom: 12 }, span: { fontSize: 10 }, strong: { fontWeight: 700, fontSize: 10 }, a: { color: content.color, fontSize: 10, textDecoration: 'underline' }, label: { fontSize: 10, fontWeight: 'bold', color: '#555' }, tableRow: { display: 'flex', flexDirection: 'row', gap: 8 }, tableCell: { textAlign: 'left', fontSize: 10, paddingVertical: 12 } }); return ( {/* eslint-disable-next-line jsx-a11y/alt-text */} ORDER INFORMATION: Order number: {order.name} Email: {order.customer?.emailAddress} Date: {toPrintDate(order.processedAt)} Shipping Address {order.shippingAddress!.firstName} {order.shippingAddress!.lastName} {order.shippingAddress!.address1} {order.shippingAddress!.address2 && ( {order.shippingAddress!.address2} )} {order.shippingAddress!.city} {order.shippingAddress!.provinceCode}{' '} {order.shippingAddress!.zip} {order.shippingAddress!.country} Billing Address {order.billingAddress!.firstName} {order.billingAddress!.lastName} {order.billingAddress!.address1} {order.billingAddress!.address2 && ( {order.billingAddress!.address2} )} {order.billingAddress!.city} {order.billingAddress!.provinceCode}{' '} {order.billingAddress!.zip} {order.billingAddress!.country} Payment Ending with {order.transactions[0]!.paymentDetails.last4} - Products Quantity Price {order.lineItems.map((lineItem, index) => ( {lineItem.title} {lineItem.quantity} ))} Subtotal Shipping Total {content.body} Date: {toPrintDate(date)} Print your name to sign: {signature1} Credit card holder's electronic signature {signature2} ); }