fix: Pdf branding templates request data

This commit is contained in:
Ahmed Bouhuolia
2024-10-07 16:03:56 +02:00
parent bbdfe00c7a
commit 9edfb83221
20 changed files with 142 additions and 72 deletions

View File

@@ -2,12 +2,13 @@ import { useFormikContext } from 'formik';
import { ElementCustomize } from '../../../ElementCustomize/ElementCustomize';
import { PaymentReceivedCustomizeGeneralField } from './PaymentReceivedCustomizeFieldsGeneral';
import { PaymentReceivedCustomizeContentFields } from './PaymentReceivedCustomizeFieldsContent';
import { PaymentReceivedCustomizeValues } from './types';
import { PaymentReceivedPaperTemplate } from './PaymentReceivedPaperTemplate';
import { PaymentReceivedCustomizeValues, PaymentReceivedPreviewState } from './types';
import { PaymentReceivedPaperTemplate, PaymentReceivedPaperTemplateProps } from './PaymentReceivedPaperTemplate';
import { initialValues } from './constants';
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
import { useDrawerActions } from '@/hooks/state';
import { BrandingTemplateForm } from '@/containers/BrandingTemplates/BrandingTemplateForm';
import { useElementCustomizeContext } from '@/containers/ElementCustomize/ElementCustomizeProvider';
export function PaymentReceivedCustomizeContent() {
const { payload, name } = useDrawerContext();
@@ -20,7 +21,7 @@ export function PaymentReceivedCustomizeContent() {
};
return (
<BrandingTemplateForm<PaymentReceivedCustomizeValues>
<BrandingTemplateForm<PaymentReceivedCustomizeValues, PaymentReceivedPreviewState>
templateId={templateId}
defaultValues={initialValues}
onSuccess={handleSuccess}
@@ -43,6 +44,9 @@ export function PaymentReceivedCustomizeContent() {
function PaymentReceivedPaperTemplateFormConnected() {
const { values } = useFormikContext<PaymentReceivedCustomizeValues>();
const { brandingState } = useElementCustomizeContext();
return <PaymentReceivedPaperTemplate {...values} />;
const paperTemplateProps: PaymentReceivedPaperTemplateProps = { ...brandingState, ...values };
return <PaymentReceivedPaperTemplate {...paperTemplateProps} />;
}

View File

@@ -18,9 +18,6 @@ export const initialValues = {
showPaymentReceivedDate: true,
paymentReceivedDateLabel: 'Date of Issue',
// Company name
companyName: 'Bigcapital Technology, Inc.',
// Customer address
showCompanyAddress: true,
companyAddress: '',

View File

@@ -1,4 +1,6 @@
import { BrandingTemplateValues } from '@/containers/BrandingTemplates/types';
import { BrandingState, BrandingTemplateValues } from '@/containers/BrandingTemplates/types';
export interface PaymentReceivedPreviewState extends BrandingState {}
export interface PaymentReceivedCustomizeValues extends BrandingTemplateValues {
// Colors
@@ -20,15 +22,11 @@ export interface PaymentReceivedCustomizeValues extends BrandingTemplateValues {
showDueDate?: boolean;
dueDateLabel?: string;
// # Company name
companyName?: string;
// # Customer address
showCustomerAddress?: boolean;
// # Company address
showCompanyAddress?: boolean;
companyAddress?: string;
billedToLabel?: string;
// Entries