mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
BC-17 feat: customer/vendor drawer of readonly details.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import React from 'react';
|
||||
import { DrawerHeaderContent, DashboardInsider } from 'components';
|
||||
import { useCustomer } from 'hooks/query';
|
||||
|
||||
const ContactDetailDrawerContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Contact detail provider.
|
||||
*/
|
||||
function CustomerDetailsDrawerProvider({ customerId, ...props }) {
|
||||
// Handle fetch customer details.
|
||||
const { data: customer, isLoading: isCustomerLoading } = useCustomer(
|
||||
customerId,
|
||||
{
|
||||
enabled: !!customerId,
|
||||
},
|
||||
);
|
||||
// Provider.
|
||||
const provider = {
|
||||
customer,
|
||||
customerId,
|
||||
isCustomerLoading,
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardInsider loading={isCustomerLoading}>
|
||||
<DrawerHeaderContent
|
||||
name="customer-details-drawer"
|
||||
title={customer?.display_name}
|
||||
/>
|
||||
<ContactDetailDrawerContext.Provider value={provider} {...props} />
|
||||
</DashboardInsider>
|
||||
);
|
||||
}
|
||||
|
||||
const useCustomerDetailsDrawerContext = () =>
|
||||
React.useContext(ContactDetailDrawerContext);
|
||||
|
||||
export { CustomerDetailsDrawerProvider, useCustomerDetailsDrawerContext };
|
||||
Reference in New Issue
Block a user