feat: wip preview mail receipt

This commit is contained in:
Ahmed Bouhuolia
2024-11-25 16:18:29 +02:00
parent df41de7239
commit ca44d6346d
4 changed files with 143 additions and 70 deletions

View File

@@ -24,7 +24,7 @@ EmailTemplate.CompanyLogo = ({ src }: { src: string }) => {
const containerStyle: CSSProperties = { const containerStyle: CSSProperties = {
backgroundColor: '#fff', backgroundColor: '#fff',
width: '100%', width: '100%',
maxWidth: '400px', maxWidth: '500px',
padding: '30px 20px', padding: '30px 20px',
color: '#000', color: '#000',
}; };

View File

@@ -26,6 +26,10 @@ export interface EstimatePaymentEmailProps {
total: string; total: string;
totalLabel?: string; totalLabel?: string;
// # Subtotal
subtotal: string;
subtotalLabel?: string;
// # Estimate No# // # Estimate No#
estimateNumber?: string; estimateNumber?: string;
estimateNumberLabel?: string; estimateNumberLabel?: string;
@@ -57,10 +61,14 @@ export const EstimatePaymentEmail: React.FC<
// # Colors // # Colors
primaryColor = 'rgb(0, 82, 204)', primaryColor = 'rgb(0, 82, 204)',
// # invoice total // # Total
total, total,
totalLabel = 'Total', totalLabel = 'Total',
// # Subtotal
subtotal,
subtotalLabel = 'Subtotal',
// # Estimate No# // # Estimate No#
estimateNumberLabel = 'Estimate No: {estimateNumber}', estimateNumberLabel = 'Estimate No: {estimateNumber}',
estimateNumber = 'EST-00001', estimateNumber = 'EST-00001',
@@ -129,6 +137,16 @@ export const EstimatePaymentEmail: React.FC<
</Row> </Row>
))} ))}
<Row style={totalLineRowStyle}>
<Column width={'50%'}>
<Text style={totalLineItemLabelStyle}>{subtotalLabel}</Text>
</Column>
<Column width={'50%'}>
<Text style={totalLineItemAmountStyle}>{subtotal}</Text>
</Column>
</Row>
<Row style={totalLineRowStyle}> <Row style={totalLineRowStyle}>
<Column width={'50%'}> <Column width={'50%'}>
<Text style={totalLineItemLabelStyle}>{totalLabel}</Text> <Text style={totalLineItemLabelStyle}>{totalLabel}</Text>

View File

@@ -15,6 +15,10 @@ const Template: StoryFn<PaymentReceivedEmailTemplateProps> = (args) => (
export const Default: StoryFn<PaymentReceivedEmailTemplateProps> = export const Default: StoryFn<PaymentReceivedEmailTemplateProps> =
Template.bind({ Template.bind({
});
Default.args = {
message: `Hi Ahmed Bouhuolia, message: `Hi Ahmed Bouhuolia,
Here's invoice # INV-00005 for $1,000.00 Here's invoice # INV-00005 for $1,000.00
@@ -27,6 +31,5 @@ If you have any questions, please let us know.
Thanks, Thanks,
Bigcapital`, Bigcapital`,
}); items: [{ label: 'INV-00001', total: '$1000.00' }]
};
Default.args = {};

View File

@@ -1,5 +1,6 @@
import { import {
Button, Button,
Column,
Container, Container,
Heading, Heading,
render, render,
@@ -24,13 +25,14 @@ export interface PaymentReceivedEmailTemplateProps {
total: string; total: string;
totalLabel?: string; totalLabel?: string;
// # Subtotal
subtotal: string;
subtotalLabel?: string;
// # Items // # Items
items: Array<{ label: string; quantity: string; rate: string }>; items: Array<{ label: string; total: string }>;
// # View payment button
viewPaymentButtonLabel?: string;
viewPaymentButtonUrl?: string;
// # Payment #
paymentNumberLabel?: string; paymentNumberLabel?: string;
paymentNumber?: string; paymentNumber?: string;
@@ -57,14 +59,15 @@ export const PaymentReceivedEmailTemplate: React.FC<
total = '$1,000.00', total = '$1,000.00',
totalLabel = 'Total', totalLabel = 'Total',
// # Subtotal
subtotal,
subtotalLabel = 'Subtotal',
// # Items // # Items
items, items,
message = '', // # Message
message,
// # View invoice button
viewPaymentButtonLabel = 'View Payment',
viewPaymentButtonUrl,
}) => { }) => {
return ( return (
<EmailTemplateLayout preview={preview}> <EmailTemplateLayout preview={preview}>
@@ -81,7 +84,7 @@ export const PaymentReceivedEmailTemplate: React.FC<
)} )}
<Section style={headerInfoStyle}> <Section style={headerInfoStyle}>
<Row> <Row>
<Heading style={invoiceCompanyNameStyle}>{companyName}</Heading> <Heading style={paymentCompanyNameStyle}>{companyName}</Heading>
</Row> </Row>
<Row> <Row>
<Text style={paymentAmountStyle}>{total}</Text> <Text style={paymentAmountStyle}>{total}</Text>
@@ -93,20 +96,47 @@ export const PaymentReceivedEmailTemplate: React.FC<
</Row> </Row>
</Section> </Section>
<Text style={invoiceMessageStyle}>{message}</Text> <Text style={paymentMessageStyle}>{message}</Text>
<Button
href={viewPaymentButtonUrl} <Section style={totalsSectionStyle}>
style={{ {items.map((item, index) => (
...viewInvoiceButtonStyle, <Row key={index} style={itemLineRowStyle}>
backgroundColor: primaryColor, <Column width={'50%'}>
}} <Text style={listItemLabelStyle}>{item.label}</Text>
> </Column>
{viewPaymentButtonLabel}
</Button> <Column width={'50%'}>
<Text style={listItemAmountStyle}>
{item.total}
</Text>
</Column>
</Row>
))}
<Row style={totalLineRowStyle}>
<Column width={'50%'}>
<Text style={totalLineItemLabelStyle}>{subtotalLabel}</Text>
</Column>
<Column width={'50%'}>
<Text style={totalLineItemAmountStyle}>{subtotal}</Text>
</Column>
</Row>
<Row style={totalLineRowStyle}>
<Column width={'50%'}>
<Text style={totalLineItemLabelStyle}>{totalLabel}</Text>
</Column>
<Column width={'50%'}>
<Text style={totalLineItemAmountStyle}>{total}</Text>
</Column>
</Row>
</Section>
</Container> </Container>
</EmailTemplateLayout> </EmailTemplateLayout>
); );
}; };
/** /**
* Renders the payment received mail template to string * Renders the payment received mail template to string
@@ -132,7 +162,6 @@ const headerInfoStyle: CSSProperties = {
textAlign: 'center', textAlign: 'center',
marginBottom: 20, marginBottom: 20,
}; };
const mainSectionStyle: CSSProperties = {};
const paymentAmountStyle: CSSProperties = { const paymentAmountStyle: CSSProperties = {
margin: 0, margin: 0,
@@ -145,26 +174,14 @@ const paymentNumberStyle: CSSProperties = {
color: '#404854', color: '#404854',
}; };
const invoiceCompanyNameStyle: CSSProperties = { const paymentCompanyNameStyle: CSSProperties = {
margin: 0, margin: 0,
fontSize: '18px', fontSize: '18px',
fontWeight: 500, fontWeight: 500,
color: '#404854', color: '#404854',
}; };
const viewInvoiceButtonStyle: CSSProperties = { const paymentMessageStyle: CSSProperties = {
display: 'block',
cursor: 'pointer',
textAlign: 'center',
fontSize: 16,
padding: '10px 15px',
lineHeight: '1',
backgroundColor: 'rgb(0, 82, 204)',
color: '#fff',
borderRadius: '5px',
};
const invoiceMessageStyle: CSSProperties = {
whiteSpace: 'pre-line', whiteSpace: 'pre-line',
margin: '0 0 20px 0', margin: '0 0 20px 0',
lineHeight: '20px', lineHeight: '20px',
@@ -186,3 +203,38 @@ const companyLogoStyle = {
backgroundPosition: 'center center', backgroundPosition: 'center center',
backgroundSize: 'contain', backgroundSize: 'contain',
}; };
const totalLineRowStyle: CSSProperties = {
borderBottom: '1px solid #000',
height: 40,
};
const listItemLabelStyle: CSSProperties = {
margin: 0,
};
const totalLineItemLabelStyle: CSSProperties = {
...listItemLabelStyle,
fontWeight: 500,
};
const listItemAmountStyle: CSSProperties = {
margin: 0,
textAlign: 'right',
};
const totalLineItemAmountStyle: CSSProperties = {
...listItemAmountStyle,
fontWeight: 600,
};
const itemLineRowStyle: CSSProperties = {
borderBottom: '1px solid #D9D9D9',
height: 40,
};
const totalsSectionStyle = {
marginTop: '20px',
borderTop: '1px solid #D9D9D9',
};