feat: paper template customize

This commit is contained in:
Ahmed Bouhuolia
2024-09-10 21:54:37 +02:00
parent 77a1e35ff4
commit 716dec799a
19 changed files with 269 additions and 293 deletions

View File

@@ -0,0 +1,40 @@
// @ts-nocheck
import { FInputGroup, FSwitch, Group, Stack } from '@/components';
import { CLASSES } from '@/constants';
import { InputGroupProps, SwitchProps } from '@blueprintjs/core';
export function ElementCustomizeFieldsGroup({
label,
children,
}: {
label: string;
children: React.ReactNode;
}) {
return (
<Stack spacing={20}>
<h4 className={CLASSES.TEXT_MUTED} style={{ fontWeight: 600 }}>
{label}
</h4>
<Stack spacing={14}>{children}</Stack>
</Stack>
);
}
export function ElementCustomizeContentItemFieldGroup({
inputGroupProps,
switchProps,
}: {
inputGroupProps: InputGroupProps;
switchProps?: SwitchProps;
}) {
return (
<Group spacing={14} position={'apart'}>
<FSwitch {...inputGroupProps} fastField />
{switchProps?.name && (
<FInputGroup {...switchProps} style={{ maxWidth: 150 }} fastField />
)}
</Group>
);
}

View File

@@ -1,13 +1,12 @@
import React from 'react';
import { Box } from '@/components'; import { Box } from '@/components';
import { Classes } from '@blueprintjs/core'; import { Classes } from '@blueprintjs/core';
// import { InvoicePaperTemplate } from './InvoicePaperTemplate';
import { ElementCustomize } from '../../../ElementCustomize/ElementCustomize'; import { ElementCustomize } from '../../../ElementCustomize/ElementCustomize';
import { CreditNoteCustomizeGeneralField } from './CreditNoteCustomizeGeneralFields'; import { CreditNoteCustomizeGeneralField } from './CreditNoteCustomizeGeneralFields';
import { CreditNoteCustomizeContentFields } from './CreditNoteCutomizeContentFields'; import { CreditNoteCustomizeContentFields } from './CreditNoteCutomizeContentFields';
import { CreditNotePaperTemplate } from './CreditNotePaperTemplate'; import { CreditNotePaperTemplate } from './CreditNotePaperTemplate';
import { CreditNoteCustomizeValues } from './types'; import { CreditNoteCustomizeValues } from './types';
import { initialValues } from './constants'; import { initialValues } from './constants';
import { useFormikContext } from 'formik';
export default function CreditNoteCustomizeContent() { export default function CreditNoteCustomizeContent() {
const handleFormSubmit = (values: CreditNoteCustomizeValues) => {}; const handleFormSubmit = (values: CreditNoteCustomizeValues) => {};
@@ -19,7 +18,7 @@ export default function CreditNoteCustomizeContent() {
onSubmit={handleFormSubmit} onSubmit={handleFormSubmit}
> >
<ElementCustomize.PaperTemplate> <ElementCustomize.PaperTemplate>
<CreditNotePaperTemplate /> <CreditNotePaperTemplateFormConnected />
</ElementCustomize.PaperTemplate> </ElementCustomize.PaperTemplate>
<ElementCustomize.FieldsTab id={'general'} label={'General'}> <ElementCustomize.FieldsTab id={'general'} label={'General'}>
@@ -37,3 +36,9 @@ export default function CreditNoteCustomizeContent() {
</Box> </Box>
); );
} }
function CreditNotePaperTemplateFormConnected() {
const { values } = useFormikContext<CreditNoteCustomizeValues>();
return <CreditNotePaperTemplate {...values} />;
}

View File

@@ -18,7 +18,7 @@ export function CreditNoteCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'primaryColor'} name={'primaryColor'}
label={'Primary Color'} label={'Primary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -32,7 +32,7 @@ export function CreditNoteCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'secondaryColor'} name={'secondaryColor'}
label={'Secondary Color'} label={'Secondary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -47,7 +47,7 @@ export function CreditNoteCustomizeGeneralField() {
<FSwitch <FSwitch
name={'showCompanyLogo'} name={'showCompanyLogo'}
label={'Display company logo in the paper'} label={'Display company logo in the paper'}
// className={styles.showCompanyLogoField} style={{ fontSize: 14 }}
large large
fastField fastField
/> />

View File

@@ -7,6 +7,7 @@ import { EstimateCustomizeContentFields } from './EstimateCustomizeFieldsContent
import { EstimatePaperTemplate } from './EstimatePaperTemplate'; import { EstimatePaperTemplate } from './EstimatePaperTemplate';
import { EstimateCustomizeValues } from './types'; import { EstimateCustomizeValues } from './types';
import { initialValues } from './constants'; import { initialValues } from './constants';
import { useFormikContext } from 'formik';
export default function EstimateCustomizeContent() { export default function EstimateCustomizeContent() {
const handleFormSubmit = (values: EstimateCustomizeValues) => {}; const handleFormSubmit = (values: EstimateCustomizeValues) => {};
@@ -18,7 +19,7 @@ export default function EstimateCustomizeContent() {
onSubmit={handleFormSubmit} onSubmit={handleFormSubmit}
> >
<ElementCustomize.PaperTemplate> <ElementCustomize.PaperTemplate>
<EstimatePaperTemplate /> <EstimatePaperTemplateFormConnected />
</ElementCustomize.PaperTemplate> </ElementCustomize.PaperTemplate>
<ElementCustomize.FieldsTab id={'general'} label={'General'}> <ElementCustomize.FieldsTab id={'general'} label={'General'}>
@@ -36,3 +37,9 @@ export default function EstimateCustomizeContent() {
</Box> </Box>
); );
} }
function EstimatePaperTemplateFormConnected() {
const { values } = useFormikContext<EstimateCustomizeValues>();
return <EstimatePaperTemplate {...values} />;
}

View File

@@ -19,7 +19,7 @@ export function EstimateCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'primaryColor'} name={'primaryColor'}
label={'Primary Color'} label={'Primary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -33,7 +33,7 @@ export function EstimateCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'secondaryColor'} name={'secondaryColor'}
label={'Secondary Color'} label={'Secondary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -48,7 +48,7 @@ export function EstimateCustomizeGeneralField() {
<FSwitch <FSwitch
name={'showCompanyLogo'} name={'showCompanyLogo'}
label={'Display company logo in the paper'} label={'Display company logo in the paper'}
// className={styles.showCompanyLogoField} style={{ fontSize: 14 }}
large large
fastField fastField
/> />

View File

@@ -1,10 +1,32 @@
import { Group, Stack } from '@/components'; import { Group, Stack } from '@/components';
import { PaperTemplate, PaperTemplateProps } from '../../Invoices/InvoiceCustomize/PaperTemplate'; import {
PaperTemplate,
PaperTemplateProps,
} from '../../Invoices/InvoiceCustomize/PaperTemplate';
export interface EstimatePaperTemplateProps extends PaperTemplateProps { export interface EstimatePaperTemplateProps extends PaperTemplateProps {
estimateNumebr?: string;
estimateNumberLabel?: string;
showEstimateNumber?: boolean;
expirationDate?: string;
showExpirationDate?: boolean;
expirationDateLabel?: string;
estimateDateLabel?: string;
showEstimateDate?: boolean;
estimateDate?: string;
companyName?: string;
// Address
showBilledToAddress?: boolean;
billedToAddress?: Array<string>; billedToAddress?: Array<string>;
showBilledFromAddress?: boolean;
billedFromAddress?: Array<string>; billedFromAddress?: Array<string>;
// Totals
total?: string; total?: string;
showTotal?: boolean; showTotal?: boolean;
totalLabel?: string; totalLabel?: string;
@@ -13,6 +35,7 @@ export interface EstimatePaperTemplateProps extends PaperTemplateProps {
showSubtotal?: boolean; showSubtotal?: boolean;
subtotalLabel?: string; subtotalLabel?: string;
// Statements
showCustomerNote?: boolean; showCustomerNote?: boolean;
customerNote?: string; customerNote?: string;
customerNoteLabel?: string; customerNoteLabel?: string;
@@ -28,18 +51,6 @@ export interface EstimatePaperTemplateProps extends PaperTemplateProps {
quantity: string; quantity: string;
total: string; total: string;
}>; }>;
expirationDate?: string;
showExpirationDate?: boolean;
expirationDateLabel?: string;
estimateDateLabel?: string;
showEstimateDate?: boolean;
estimateDate?: string;
estimateNumebr?: string;
estimateNumberLabel?: string;
showEstimateNumber?: boolean;
} }
export function EstimatePaperTemplate({ export function EstimatePaperTemplate({

View File

@@ -1,4 +1,3 @@
export const initialValues = { export const initialValues = {
// Colors // Colors
primaryColor: '#2c3dd8', primaryColor: '#2c3dd8',
@@ -13,8 +12,8 @@ export const initialValues = {
showEstimateNumber: true, showEstimateNumber: true,
estimateNumberLabel: 'Estimate number', estimateNumberLabel: 'Estimate number',
showDateIssue: true, estimateDateLabel: 'Date of Issue',
dateIssueLabel: 'Date of Issue', showEstimateDate: true,
showExpirationDate: true, showExpirationDate: true,
expirationDateLabel: 'Expiration Date', expirationDateLabel: 'Expiration Date',
@@ -37,24 +36,17 @@ export const initialValues = {
showSubtotal: true, showSubtotal: true,
subtotalLabel: 'Subtotal', subtotalLabel: 'Subtotal',
showDiscount: true,
discountLabel: 'Discount',
showTaxes: true,
showTotal: true, showTotal: true,
totalLabel: 'Total', totalLabel: 'Total',
// Footer paragraphs. // Statements
termsConditionsLabel: 'Terms & Conditions', showCustomerNote: true,
customerNoteLabel: 'Customer Note',
showTermsConditions: true, showTermsConditions: true,
termsConditionsLabel: 'Terms & Conditions',
statementLabel: 'Statement',
showStatement: true,
}; };
export const fieldsGroups = [ export const fieldsGroups = [
{ {
label: 'Header', label: 'Header',
@@ -65,8 +57,8 @@ export const fieldsGroups = [
label: 'Estimate No.', label: 'Estimate No.',
}, },
{ {
labelKey: 'dateIssueLabel', labelKey: 'estimateDateLabel',
enableKey: 'showDateIssue', enableKey: 'showEstimateDate',
label: 'Issue Date', label: 'Issue Date',
}, },
{ {
@@ -93,12 +85,6 @@ export const fieldsGroups = [
enableKey: 'showSubtotal', enableKey: 'showSubtotal',
label: 'Subtotal', label: 'Subtotal',
}, },
{
labelKey: 'discountLabel',
enableKey: 'showDiscount',
label: 'Discount',
},
{ enableKey: 'showTaxes', label: 'Taxes' },
{ labelKey: 'totalLabel', enableKey: 'showTotal', label: 'Total' }, { labelKey: 'totalLabel', enableKey: 'showTotal', label: 'Total' },
], ],
}, },
@@ -111,8 +97,8 @@ export const fieldsGroups = [
label: 'Terms & Conditions', label: 'Terms & Conditions',
}, },
{ {
labelKey: 'statementLabel', labelKey: 'customerNoteLabel',
enableKey: 'showStatement', enableKey: 'showCustomerNote',
label: 'Statement', label: 'Statement',
labelPlaceholder: 'Statement', labelPlaceholder: 'Statement',
}, },

View File

@@ -8,14 +8,14 @@ export interface EstimateCustomizeValues {
companyLogo?: string; companyLogo?: string;
// Top details. // Top details.
showInvoiceNumber?: boolean; estimateNumberLabel?: string;
invoiceNumberLabel?: string; showEstimateNumber?: boolean;
showDateIssue?: boolean; showExpirationDate?: boolean;
dateIssueLabel?: string; expirationDateLabel?: string;
showDueDate?: boolean; estimateDateLabel?: string;
dueDateLabel?: string; showEstimateDate?: boolean;
// Company name // Company name
companyName?: string; companyName?: string;
@@ -35,24 +35,13 @@ export interface EstimateCustomizeValues {
showSubtotal?: boolean; showSubtotal?: boolean;
subtotalLabel?: string; subtotalLabel?: string;
showDiscount?: boolean;
discountLabel?: string;
showTaxes?: boolean;
showTotal?: boolean; showTotal?: boolean;
totalLabel?: string; totalLabel?: string;
paymentMadeLabel?: string; // Statements
showPaymentMade?: boolean; showCustomerNote?: boolean;
customerNoteLabel?: string;
dueAmountLabel?: string;
showDueAmount?: boolean;
// Footer paragraphs.
termsConditionsLabel?: string;
showTermsConditions?: boolean; showTermsConditions?: boolean;
termsConditionsLabel?: string;
statementLabel?: string;
showStatement?: boolean;
} }

View File

@@ -3,7 +3,6 @@ import { Classes, Text } from '@blueprintjs/core';
import { FFormGroup, FSwitch, Group, Stack } from '@/components'; import { FFormGroup, FSwitch, Group, Stack } from '@/components';
import { FColorInput } from '@/components/Forms/FColorInput'; import { FColorInput } from '@/components/Forms/FColorInput';
import { CreditCardIcon } from '@/icons/CreditCardIcon'; import { CreditCardIcon } from '@/icons/CreditCardIcon';
import styles from './InvoiceCustomizeFields.module.scss';
export function InvoiceCustomizeGeneralField() { export function InvoiceCustomizeGeneralField() {
return ( return (
@@ -20,7 +19,7 @@ export function InvoiceCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'primaryColor'} name={'primaryColor'}
label={'Primary Color'} label={'Primary Color'}
className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -34,7 +33,7 @@ export function InvoiceCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'secondaryColor'} name={'secondaryColor'}
label={'Secondary Color'} label={'Secondary Color'}
className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -49,7 +48,7 @@ export function InvoiceCustomizeGeneralField() {
<FSwitch <FSwitch
name={'showCompanyLogo'} name={'showCompanyLogo'}
label={'Display company logo in the paper'} label={'Display company logo in the paper'}
className={styles.showCompanyLogoField} style={{ fontSize: 14 }}
large large
fastField fastField
/> />

View File

@@ -1,8 +1,11 @@
// @ts-nocheck // @ts-nocheck
import { FInputGroup, FSwitch, Group, Stack } from '@/components'; import { Stack } from '@/components';
import { CLASSES } from '@/constants';
import { Classes } from '@blueprintjs/core'; import { Classes } from '@blueprintjs/core';
import { fieldsGroups } from './constants'; import { fieldsGroups } from './constants';
import {
ElementCustomizeFieldsGroup,
ElementCustomizeContentItemFieldGroup,
} from '@/containers/ElementCustomize/ElementCustomizeFieldsGroup';
export function InvoiceCustomizeContentFields() { export function InvoiceCustomizeContentFields() {
return ( return (
@@ -20,25 +23,20 @@ export function InvoiceCustomizeContentFields() {
<Stack> <Stack>
{fieldsGroups.map((group) => ( {fieldsGroups.map((group) => (
<> <ElementCustomizeFieldsGroup label={group.label}>
<h4 className={CLASSES.TEXT_MUTED} style={{ fontWeight: 600 }}>
{group.label}
</h4>
<Stack spacing={14}>
{group.fields.map((item, index) => ( {group.fields.map((item, index) => (
<Group spacing={14} position={'apart'} key={index}> <ElementCustomizeContentItemFieldGroup
<FSwitch name={item.enableKey} label={item.label} fastField /> key={index}
{item.labelKey && ( inputGroupProps={{
<FInputGroup name: item.enableKey,
name={item.labelKey} label: item.label,
style={{ maxWidth: 150 }} }}
fastField switchProps={{
name: item.labelKey,
}}
/> />
)}
</Group>
))} ))}
</Stack> </ElementCustomizeFieldsGroup>
</>
))} ))}
</Stack> </Stack>
</Stack> </Stack>

View File

@@ -22,7 +22,6 @@
} }
.details { .details {
margin-bottom: 25px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 4px; gap: 4px;
@@ -40,7 +39,6 @@
.addressRoot{ .addressRoot{
display: flex; display: flex;
flex-direction: row; flex-direction: row;
margin-bottom: 25px;
} }
.addressBillTo{ .addressBillTo{
@@ -101,7 +99,6 @@
.totals{ .totals{
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-bottom: 40px;
margin-left: auto; margin-left: auto;
width: 300px; width: 300px;
} }

View File

@@ -2,6 +2,9 @@ import clsx from 'classnames';
import * as R from 'ramda'; import * as R from 'ramda';
import { useFormikContext } from 'formik'; import { useFormikContext } from 'formik';
import styles from './InvoicePaperTemplate.module.scss'; import styles from './InvoicePaperTemplate.module.scss';
import { PaperTemplate } from './PaperTemplate';
import { Group, Stack } from '@/components';
import React from 'react';
interface PapaerLine { interface PapaerLine {
item?: string; item?: string;
@@ -85,15 +88,14 @@ interface PaperTemplateProps {
lines?: Array<PapaerLine>; lines?: Array<PapaerLine>;
taxes?: Array<PaperTax>; taxes?: Array<PaperTax>;
billedFromAddres?: Array<string>; billedFromAddres?: Array<string | React.ReactNode>;
billedToAddress?: Array<string>; billedToAddress?: Array<string | React.ReactNode>;
} }
function InvoicePaperTemplateRoot({ function InvoicePaperTemplateRoot({
primaryColor, primaryColor,
secondaryColor, secondaryColor,
bigtitle = 'Invoice',
companyName = 'Bigcapital Technology, Inc.', companyName = 'Bigcapital Technology, Inc.',
showCompanyLogo = true, showCompanyLogo = true,
@@ -183,156 +185,109 @@ function InvoicePaperTemplateRoot({
], ],
}: PaperTemplateProps) { }: PaperTemplateProps) {
return ( return (
<div className={styles.root}> <PaperTemplate
<style>{`:root { --invoice-primary-color: ${primaryColor}; --invoice-secondary-color: ${secondaryColor}; }`}</style> primaryColor={primaryColor}
secondaryColor={secondaryColor}
<div> showCompanyLogo={showCompanyLogo}
<h1 className={styles.bigTitle}>{bigtitle}</h1> companyLogo={companyLogo}
bigtitle={'Invoice'}
{showCompanyLogo && ( >
<div className={styles.logoWrap}> <Stack spacing={24}>
<img alt="" src={companyLogo} /> <PaperTemplate.TermsList>
</div>
)}
</div>
<div className={styles.details}>
{showInvoiceNumber && ( {showInvoiceNumber && (
<div className={styles.detail}> <PaperTemplate.TermsItem label={invoiceNumberLabel}>
<div className={styles.detailLabel}>{invoiceNumberLabel}</div> {invoiceNumber}
<div>{invoiceNumber}</div> </PaperTemplate.TermsItem>
</div>
)} )}
{showDateIssue && ( {showDateIssue && (
<div className={styles.detail}> <PaperTemplate.TermsItem label={dateIssueLabel}>
<div className={styles.detailLabel}>{dateIssueLabel}</div> {dateIssue}
<div>{dateIssue}</div> </PaperTemplate.TermsItem>
</div>
)} )}
{showDueDate && ( {showDueDate && (
<div className={styles.detail}> <PaperTemplate.TermsItem label={dueDateLabel}>
<div className={styles.detailLabel}>{dueDateLabel}</div> {dueDate}
<div>{dueDate}</div> </PaperTemplate.TermsItem>
</div>
)} )}
</div> </PaperTemplate.TermsList>
<div className={styles.addressRoot}> <Group spacing={10}>
{showBilledFromAddress && ( {showBilledFromAddress && (
<div className={styles.addressBillTo}> <PaperTemplate.Address
<strong>{companyName}</strong> <br /> items={[<strong>{companyName}</strong>, ...billedFromAddres]}
{billedFromAddres.map((text, index) => ( />
<div key={index}>{text}</div>
))}
</div>
)} )}
{showBillingToAddress && ( {showBillingToAddress && (
<div className={styles.addressFrom}> <PaperTemplate.Address items={billedToAddress} />
<strong>{billedToLabel}</strong> <br />
{billedToAddress.map((text, index) => (
<div key={index}>{text}</div>
))}
</div>
)} )}
</div> </Group>
<table className={styles.table}> <Stack spacing={0}>
<thead> <PaperTemplate.Table
<tr> columns={[
<th>{lineItemLabel}</th> { label: lineItemLabel, accessor: 'item' },
<th>{lineDescriptionLabel}</th> { label: lineDescriptionLabel, accessor: 'description' },
<th className={styles.rate}>{lineRateLabel}</th> { label: lineRateLabel, accessor: 'rate' },
<th className={styles.total}>{lineTotalLabel}</th> { label: lineTotalLabel, accessor: 'total' },
</tr> ]}
</thead> data={lines}
/>
<tbody className={styles.tableBody}> <PaperTemplate.Totals>
{lines.map((line, index) => (
<tr key={index}>
<td>{line.item}</td>
<td>{line.description}</td>
<td className={styles.rate}>
{line.quantity} X {line.rate}
</td>
<td className={styles.total}>{line.total}</td>
</tr>
))}
</tbody>
</table>
<div style={{ display: 'flex' }}>
<div className={styles.totals}>
{showSubtotal && ( {showSubtotal && (
<div <PaperTemplate.TotalLine
className={clsx( label={subtotalLabel}
styles.totalsItem, amount={subtotal}
styles.totalBottomGrayBordered, />
)} )}
>
<div className={styles.totalsItemLabel}>{subtotalLabel}</div>
<div className={styles.totalsItemAmount}>{subtotal}</div>
</div>
)}
{showDiscount && ( {showDiscount && (
<div className={styles.totalsItem}> <PaperTemplate.TotalLine
<div className={styles.totalsItemLabel}>{discountLabel}</div> label={discountLabel}
<div className={styles.totalsItemAmount}>{discount}</div> amount={discount}
</div> />
)} )}
{showTaxes && ( {showTaxes && (
<> <>
{taxes.map((tax, index) => ( {taxes.map((tax, index) => (
<div key={index} className={styles.totalsItem}> <PaperTemplate.TotalLine
<div className={styles.totalsItemLabel}>{tax.label}</div> key={index}
<div className={styles.totalsItemAmount}>{tax.amount}</div> label={tax.label}
</div> amount={tax.amount}
/>
))} ))}
</> </>
)} )}
{showTotal && ( {showTotal && (
<div <PaperTemplate.TotalLine label={totalLabel} amount={total} />
className={clsx(styles.totalsItem, styles.totalBottomBordered)}
>
<div className={styles.totalsItemLabel}>{totalLabel}</div>
<div className={styles.totalsItemAmount}>{total}</div>
</div>
)} )}
{showPaymentMade && ( {showPaymentMade && (
<div className={styles.totalsItem}> <PaperTemplate.TotalLine
<div className={styles.totalsItemLabel}>{paymentMadeLabel}</div> label={paymentMadeLabel}
<div className={styles.totalsItemAmount}>{paymentMade}</div> amount={paymentMade}
</div> />
)} )}
{showBalanceDue && ( {showBalanceDue && (
<div <PaperTemplate.TotalLine
className={clsx(styles.totalsItem, styles.totalBottomBordered)} label={balanceDueLabel}
> amount={balanceDue}
<div className={styles.totalsItemLabel}>{balanceDueLabel}</div> />
<div className={styles.totalsItemAmount}>{balanceDue}</div>
</div>
)} )}
</div> </PaperTemplate.Totals>
</div> </Stack>
<Stack spacing={0}>
{showTermsConditions && ( {showTermsConditions && (
<div className={styles.paragraph}> <PaperTemplate.Statement label={termsConditionsLabel}>
<div className={styles.paragraphLabel}>{termsConditionsLabel}</div> {termsConditions}
<div>{termsConditions}</div> </PaperTemplate.Statement>
</div>
)} )}
{showStatement && ( {showStatement && (
<div className={styles.paragraph}> <PaperTemplate.Statement label={statementLabel}>
<div className={styles.paragraphLabel}>{statementLabel}</div> {statement}
<div>{statement}</div> </PaperTemplate.Statement>
</div>
)} )}
</div> </Stack>
</Stack>
</PaperTemplate>
); );
} }

View File

@@ -94,7 +94,11 @@ PaperTemplate.MutedText = () => {};
PaperTemplate.Text = () => {}; PaperTemplate.Text = () => {};
PaperTemplate.Address = ({ items }: { items: Array<string> }) => { PaperTemplate.Address = ({
items,
}: {
items: Array<string | React.ReactNode>;
}) => {
return ( return (
<Stack spacing={0}> <Stack spacing={0}>
{items.map((item, index) => ( {items.map((item, index) => (

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { Box } from '@/components'; import { useFormikContext } from 'formik';
import { Classes } from '@blueprintjs/core'; import { Classes } from '@blueprintjs/core';
import { Box } from '@/components';
import { ElementCustomize } from '../../../ElementCustomize/ElementCustomize'; import { ElementCustomize } from '../../../ElementCustomize/ElementCustomize';
import { PaymentReceivedCustomizeGeneralField } from './PaymentReceivedCustomizeFieldsGeneral'; import { PaymentReceivedCustomizeGeneralField } from './PaymentReceivedCustomizeFieldsGeneral';
import { PaymentReceivedCustomizeContentFields } from './PaymentReceivedCustomizeFieldsContent'; import { PaymentReceivedCustomizeContentFields } from './PaymentReceivedCustomizeFieldsContent';
@@ -18,7 +19,7 @@ export default function PaymentReceivedCustomizeContent() {
onSubmit={handleFormSubmit} onSubmit={handleFormSubmit}
> >
<ElementCustomize.PaperTemplate> <ElementCustomize.PaperTemplate>
<PaymentReceivedPaperTemplate /> <PaymentReceivedPaperTemplateFormConnected />
</ElementCustomize.PaperTemplate> </ElementCustomize.PaperTemplate>
<ElementCustomize.FieldsTab id={'general'} label={'General'}> <ElementCustomize.FieldsTab id={'general'} label={'General'}>
@@ -36,3 +37,9 @@ export default function PaymentReceivedCustomizeContent() {
</Box> </Box>
); );
} }
function PaymentReceivedPaperTemplateFormConnected() {
const { values } = useFormikContext<PaymentReceivedCustomizeValues>();
return <PaymentReceivedPaperTemplate {...values} />;
}

View File

@@ -19,7 +19,7 @@ export function PaymentReceivedCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'primaryColor'} name={'primaryColor'}
label={'Primary Color'} label={'Primary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -33,7 +33,7 @@ export function PaymentReceivedCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'secondaryColor'} name={'secondaryColor'}
label={'Secondary Color'} label={'Secondary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -48,7 +48,7 @@ export function PaymentReceivedCustomizeGeneralField() {
<FSwitch <FSwitch
name={'showCompanyLogo'} name={'showCompanyLogo'}
label={'Display company logo in the paper'} label={'Display company logo in the paper'}
// className={styles.showCompanyLogoField} style={{ fontSize: 14 }}
large large
fastField fastField
/> />

View File

@@ -6,6 +6,7 @@ import { ReceiptCustomizeFieldsContent } from './ReceiptCustomizeFieldsContent';
import { ReceiptPaperTemplate } from './ReceiptPaperTemplate'; import { ReceiptPaperTemplate } from './ReceiptPaperTemplate';
import { ReceiptCustomizeValues } from './types'; import { ReceiptCustomizeValues } from './types';
import { initialValues } from './constants'; import { initialValues } from './constants';
import { useFormikContext } from 'formik';
export default function ReceiptCustomizeContent() { export default function ReceiptCustomizeContent() {
const handleFormSubmit = (values: ReceiptCustomizeValues) => {}; const handleFormSubmit = (values: ReceiptCustomizeValues) => {};
@@ -17,7 +18,7 @@ export default function ReceiptCustomizeContent() {
onSubmit={handleFormSubmit} onSubmit={handleFormSubmit}
> >
<ElementCustomize.PaperTemplate> <ElementCustomize.PaperTemplate>
<ReceiptPaperTemplate /> <ReceiptPaperTemplateFormConnected />
</ElementCustomize.PaperTemplate> </ElementCustomize.PaperTemplate>
<ElementCustomize.FieldsTab id={'general'} label={'General'}> <ElementCustomize.FieldsTab id={'general'} label={'General'}>
@@ -35,3 +36,9 @@ export default function ReceiptCustomizeContent() {
</Box> </Box>
); );
} }
function ReceiptPaperTemplateFormConnected() {
const { values } = useFormikContext<ReceiptCustomizeValues>();
return <ReceiptPaperTemplate {...values} />;
}

View File

@@ -2,7 +2,6 @@
import { Classes } from '@blueprintjs/core'; import { Classes } from '@blueprintjs/core';
import { FFormGroup, FSwitch, Stack } from '@/components'; import { FFormGroup, FSwitch, Stack } from '@/components';
import { FColorInput } from '@/components/Forms/FColorInput'; import { FColorInput } from '@/components/Forms/FColorInput';
// import styles from './InvoiceCustomizeFields.module.scss';
export function ReceiptCustomizeGeneralField() { export function ReceiptCustomizeGeneralField() {
return ( return (
@@ -19,7 +18,7 @@ export function ReceiptCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'primaryColor'} name={'primaryColor'}
label={'Primary Color'} label={'Primary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -33,7 +32,7 @@ export function ReceiptCustomizeGeneralField() {
<FFormGroup <FFormGroup
name={'secondaryColor'} name={'secondaryColor'}
label={'Secondary Color'} label={'Secondary Color'}
// className={styles.fieldGroup} style={{ justifyContent: 'space-between' }}
inline inline
fastField fastField
> >
@@ -48,7 +47,7 @@ export function ReceiptCustomizeGeneralField() {
<FSwitch <FSwitch
name={'showCompanyLogo'} name={'showCompanyLogo'}
label={'Display company logo in the paper'} label={'Display company logo in the paper'}
// className={styles.showCompanyLogoField} style={{ fontSize: 14 }}
large large
fastField fastField
/> />

View File

@@ -10,13 +10,10 @@ export const initialValues = {
// Top details. // Top details.
showReceiptNumber: true, showReceiptNumber: true,
receiptNumberLabel: 'Invoice number', receiptNumberLabel: 'Receipt number',
showDateIssue: true, showReceiptDate: true,
dateIssueLabel: 'Date of Issue', receiptDateLabel: 'Date of Issue',
showDueDate: true,
dueDateLabel: 'Due Date',
// Company name // Company name
companyName: 'Bigcapital Technology, Inc.', companyName: 'Bigcapital Technology, Inc.',
@@ -36,24 +33,13 @@ export const initialValues = {
showSubtotal: true, showSubtotal: true,
subtotalLabel: 'Subtotal', subtotalLabel: 'Subtotal',
showDiscount: true,
discountLabel: 'Discount',
showTaxes: true,
showTotal: true, showTotal: true,
totalLabel: 'Total', totalLabel: 'Total',
paymentMadeLabel: 'Payment Made',
showPaymentMade: true,
dueAmountLabel: 'Due Amount',
showDueAmount: true,
// Footer paragraphs. // Footer paragraphs.
termsConditionsLabel: 'Terms & Conditions', termsConditionsLabel: 'Terms & Conditions',
showTermsConditions: true, showTermsConditions: true,
statementLabel: 'Statement', customerNoteLabel: 'Customer Note',
showStatement: true, showCustomerNote: true,
}; };

View File

@@ -8,14 +8,11 @@ export interface ReceiptCustomizeValues {
companyLogo?: string; companyLogo?: string;
// Top details. // Top details.
showInvoiceNumber?: boolean; showReceiptNumber?: boolean;
invoiceNumberLabel?: string; receiptNumberLabel?: string;
showDateIssue?: boolean; showReceiptDate?: boolean;
dateIssueLabel?: string; receiptDateLabel?: string;
showDueDate?: boolean;
dueDateLabel?: string;
// Company name // Company name
companyName?: string; companyName?: string;
@@ -35,24 +32,13 @@ export interface ReceiptCustomizeValues {
showSubtotal?: boolean; showSubtotal?: boolean;
subtotalLabel?: string; subtotalLabel?: string;
showDiscount?: boolean;
discountLabel?: string;
showTaxes?: boolean;
showTotal?: boolean; showTotal?: boolean;
totalLabel?: string; totalLabel?: string;
paymentMadeLabel?: string; // Statements
showPaymentMade?: boolean;
dueAmountLabel?: string;
showDueAmount?: boolean;
// Footer paragraphs.
termsConditionsLabel?: string; termsConditionsLabel?: string;
showTermsConditions?: boolean; showTermsConditions?: boolean;
statementLabel?: string; customerNoteLabel?: string;
showStatement?: boolean; showCustomerNote?: boolean;
} }