BC-17 feat: customer/vendor drawer of readonly details.

This commit is contained in:
a.bouhuolia
2021-09-09 11:56:06 +02:00
parent 6fd47aa884
commit 7b968a43ef
24 changed files with 738 additions and 25 deletions

View File

@@ -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 };