mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 23:30:32 +00:00
chrone: sperate client and server to different repos.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import { DrawerHeaderContent, DrawerLoading } from 'components';
|
||||
import { useVendor } from 'hooks/query';
|
||||
|
||||
const VendorDetailDrawerContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Contact detail provider.
|
||||
*/
|
||||
function VendorDetailsDrawerProvider({ vendorId, ...props }) {
|
||||
// Handle fetch vendor details.
|
||||
const { data: vendor, isLoading: isVendorLoading } = useVendor(vendorId, {
|
||||
enabled: !!vendorId,
|
||||
});
|
||||
// Provider.
|
||||
const provider = {
|
||||
vendor,
|
||||
vendorId,
|
||||
isVendorLoading,
|
||||
};
|
||||
|
||||
return (
|
||||
<DrawerLoading loading={isVendorLoading}>
|
||||
<DrawerHeaderContent
|
||||
name="vendor-details-drawer"
|
||||
title={vendor?.display_name}
|
||||
/>
|
||||
<VendorDetailDrawerContext.Provider value={provider} {...props} />
|
||||
</DrawerLoading>
|
||||
);
|
||||
}
|
||||
|
||||
const useVendorDetailsDrawerContext = () =>
|
||||
React.useContext(VendorDetailDrawerContext);
|
||||
|
||||
export { VendorDetailsDrawerProvider, useVendorDetailsDrawerContext };
|
||||
Reference in New Issue
Block a user