mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
fix: Pdf branding templates request data
This commit is contained in:
@@ -9,17 +9,21 @@ import { ElementCustomizeTabsControllerProvider } from './ElementCustomizeTabsCo
|
||||
import { ElementCustomizeFields } from './ElementCustomizeFields';
|
||||
import { ElementCustomizePreview } from './ElementCustomizePreview';
|
||||
import { extractChildren } from '@/utils/extract-children';
|
||||
import { ElementPreviewState } from '../BrandingTemplates/types';
|
||||
|
||||
export interface ElementCustomizeProps<T> extends ElementCustomizeFormProps<T> {
|
||||
export interface ElementCustomizeProps<T, Y>
|
||||
extends ElementCustomizeFormProps<T, Y> {
|
||||
brandingState?: Y;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function ElementCustomize<T>({
|
||||
export function ElementCustomize<T, Y extends ElementPreviewState>({
|
||||
initialValues,
|
||||
validationSchema,
|
||||
brandingState,
|
||||
onSubmit,
|
||||
children,
|
||||
}: ElementCustomizeProps<T>) {
|
||||
}: ElementCustomizeProps<T, Y>) {
|
||||
const PaperTemplate = React.useMemo(
|
||||
() => extractChildren(children, ElementCustomize.PaperTemplate),
|
||||
[children],
|
||||
@@ -29,7 +33,7 @@ export function ElementCustomize<T>({
|
||||
[children],
|
||||
);
|
||||
|
||||
const value = { PaperTemplate, CustomizeTabs };
|
||||
const value = { PaperTemplate, CustomizeTabs, brandingState };
|
||||
|
||||
return (
|
||||
<ElementCustomizeForm
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { ElementPreviewState } from '../BrandingTemplates/types';
|
||||
|
||||
interface ElementCustomizeValue {
|
||||
PaperTemplate?: React.ReactNode;
|
||||
CustomizeTabs: React.ReactNode;
|
||||
brandingState?: ElementPreviewState;
|
||||
}
|
||||
|
||||
const ElementCustomizeContext = createContext<ElementCustomizeValue>(
|
||||
{} as ElementCustomizeValue,
|
||||
);
|
||||
|
||||
export const ElementCustomizeProvider: React.FC<{
|
||||
interface ElementCustomizeProviderProps {
|
||||
value: ElementCustomizeValue;
|
||||
children: React.ReactNode;
|
||||
}> = ({ value, children }) => {
|
||||
}
|
||||
|
||||
export const ElementCustomizeProvider = ({ value, children }: ElementCustomizeProviderProps) => {
|
||||
return (
|
||||
<ElementCustomizeContext.Provider value={{ ...value }}>
|
||||
{children}
|
||||
@@ -29,4 +33,4 @@ export const useElementCustomizeContext = (): ElementCustomizeValue => {
|
||||
);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
};
|
||||
@@ -2,7 +2,7 @@
|
||||
import React from 'react';
|
||||
import { Formik, Form, FormikHelpers } from 'formik';
|
||||
|
||||
export interface ElementCustomizeFormProps<T> {
|
||||
export interface ElementCustomizeFormProps<T, Y> {
|
||||
initialValues?: T;
|
||||
validationSchema?: any;
|
||||
onSubmit?: (values: T, formikHelpers: FormikHelpers<T>) => void;
|
||||
|
||||
Reference in New Issue
Block a user