mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-23 00:00:31 +00:00
feat: pdf template customize
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import React, { createContext } from 'react';
|
||||
import { useGetPdfTemplates } from '@/hooks/query/pdf-templates';
|
||||
import { useDrawerContext } from '@/components/Drawer/DrawerProvider';
|
||||
|
||||
interface BrandingTemplatesBootValues {
|
||||
pdfTemplates: any;
|
||||
isPdfTemplatesLoading: boolean;
|
||||
}
|
||||
|
||||
const BrandingTemplatesBootContext = createContext<BrandingTemplatesBootValues>(
|
||||
{} as BrandingTemplatesBootValues,
|
||||
);
|
||||
|
||||
interface BrandingTemplatesBootProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
function BrandingTemplatesBoot({ ...props }: BrandingTemplatesBootProps) {
|
||||
const { payload } = useDrawerContext();
|
||||
const resource = payload?.resource || null;
|
||||
|
||||
const { data: pdfTemplates, isLoading: isPdfTemplatesLoading } =
|
||||
useGetPdfTemplates({ resource });
|
||||
|
||||
const provider = {
|
||||
pdfTemplates,
|
||||
isPdfTemplatesLoading,
|
||||
} as BrandingTemplatesBootValues;
|
||||
|
||||
return <BrandingTemplatesBootContext.Provider value={provider} {...props} />;
|
||||
}
|
||||
|
||||
const useBrandingTemplatesBoot = () =>
|
||||
React.useContext<BrandingTemplatesBootValues>(BrandingTemplatesBootContext);
|
||||
|
||||
export { BrandingTemplatesBoot, useBrandingTemplatesBoot };
|
||||
Reference in New Issue
Block a user