fix: Pdf branding template initial values

This commit is contained in:
Ahmed Bouhuolia
2024-10-07 16:08:25 +02:00
parent 9edfb83221
commit e76d3b15ce
5 changed files with 17 additions and 17 deletions

View File

@@ -16,19 +16,17 @@ export const initialValues = {
showInvoiceNumber: true,
invoiceNumberLabel: 'Invoice number',
// Issue date
showDateIssue: true,
dateIssueLabel: 'Date of Issue',
// Due date.
showDueDate: true,
dueDateLabel: 'Due Date',
// Company name
companyName: 'Bigcapital Technology, Inc.',
// Addresses
showCustomerAddress: true,
showCompanyAddress: true,
companyAddress: '',
billedToLabel: 'Billed To',
// Entries
@@ -41,6 +39,7 @@ export const initialValues = {
showSubtotal: true,
subtotalLabel: 'Subtotal',
// Discount
showDiscount: true,
discountLabel: 'Discount',
@@ -52,6 +51,7 @@ export const initialValues = {
paymentMadeLabel: 'Payment Made',
showPaymentMade: true,
// Due amount
dueAmountLabel: 'Due Amount',
showDueAmount: true,
@@ -59,6 +59,7 @@ export const initialValues = {
termsConditionsLabel: 'Terms & Conditions',
showTermsConditions: true,
// Statement
statementLabel: 'Statement',
showStatement: true,
};

View File

@@ -1,6 +1,8 @@
import { BrandingTemplateValues } from "@/containers/BrandingTemplates/types";
import { BrandingState, BrandingTemplateValues } from '@/containers/BrandingTemplates/types';
export interface InvoiceCustomizeValues extends BrandingTemplateValues {
export interface InvoiceCustomizeState extends BrandingState {}
export interface InvoiceCustomizeFormValues extends BrandingTemplateValues {
// Colors
primaryColor?: string;
secondaryColor?: string;
@@ -14,15 +16,14 @@ export interface InvoiceCustomizeValues extends BrandingTemplateValues {
showInvoiceNumber?: boolean;
invoiceNumberLabel?: string;
// Date issue
showDateIssue?: boolean;
dateIssueLabel?: string;
// Due date
showDueDate?: boolean;
dueDateLabel?: string;
// Company name
companyName?: string;
// Addresses
showBilledFromAddress?: boolean;
showBillingToAddress?: boolean;
@@ -38,6 +39,7 @@ export interface InvoiceCustomizeValues extends BrandingTemplateValues {
showSubtotal?: boolean;
subtotalLabel?: string;
// Discount
showDiscount?: boolean;
discountLabel?: string;

View File

@@ -1,6 +1,5 @@
import { omit } from 'lodash';
import { useFormikContext } from 'formik';
import { InvoiceCustomizeValues } from './types';
import { InvoiceCustomizeFormValues } from './types';
import {
CreatePdfTemplateValues,
EditPdfTemplateValues,
@@ -10,7 +9,7 @@ import { initialValues } from './constants';
import { useBrandingTemplateBoot } from '@/containers/BrandingTemplates/BrandingTemplateBoot';
export const transformToEditRequest = (
values: InvoiceCustomizeValues,
values: InvoiceCustomizeFormValues,
): EditPdfTemplateValues => {
return {
templateName: values.templateName,
@@ -19,7 +18,7 @@ export const transformToEditRequest = (
};
export const transformToNewRequest = (
values: InvoiceCustomizeValues,
values: InvoiceCustomizeFormValues,
): CreatePdfTemplateValues => {
return {
resource: 'SaleInvoice',
@@ -28,7 +27,7 @@ export const transformToNewRequest = (
};
};
export const useInvoiceCustomizeInitialValues = (): InvoiceCustomizeValues => {
export const useInvoiceCustomizeInitialValues = (): InvoiceCustomizeFormValues => {
const { pdfTemplate } = useBrandingTemplateBoot();
const defaultPdfTemplate = {
@@ -40,6 +39,6 @@ export const useInvoiceCustomizeInitialValues = (): InvoiceCustomizeValues => {
...(transformToForm(
defaultPdfTemplate,
initialValues,
) as InvoiceCustomizeValues),
) as InvoiceCustomizeFormValues),
};
};

View File

@@ -20,7 +20,6 @@ export const initialValues = {
// Customer address
showCompanyAddress: true,
companyAddress: '',
// Company address
showCustomerAddress: true,

View File

@@ -22,7 +22,6 @@ export const initialValues = {
showCustomerAddress: true,
// Company address
companyAddress: '',
showCompanyAddress: true,
billedToLabel: 'Billed To',