feat: wip invoice mail receipt preview

This commit is contained in:
Ahmed Bouhuolia
2024-10-22 11:59:15 +02:00
parent dffd818396
commit b7f316d25a
9 changed files with 290 additions and 98 deletions

View File

@@ -0,0 +1,31 @@
import * as R from 'ramda';
import { useFormikContext } from 'formik';
import {
InvoicePaymentPagePreview,
InvoicePaymentPagePreviewProps,
} from '@/containers/PaymentPortal/InvoicePaymentPagePreview';
import { useElementCustomizeContext } from '@/containers/ElementCustomize/ElementCustomizeProvider';
import { InvoiceCustomizeFormValues } from './types';
const withInvoicePaymentPreviewPageProps = <P extends Object>(
Component: React.ComponentType<P>,
) => {
return (props: Omit<P, keyof InvoicePaymentPagePreviewProps>) => {
const { values } = useFormikContext<InvoiceCustomizeFormValues>();
const { brandingState } = useElementCustomizeContext();
const mergedBrandingState = {
...brandingState,
...values,
};
const mergedProps: InvoicePaymentPagePreviewProps = {
companyLogoUri: mergedBrandingState?.companyLogoUri,
primaryColor: mergedBrandingState?.primaryColor,
};
return <Component {...(props as P)} {...mergedProps} />;
};
};
export const InvoiceCustomizePaymentPreview = R.compose(
withInvoicePaymentPreviewPageProps,
)(InvoicePaymentPagePreview);