mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
re-structure to monorepo.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import { useCustomer } from '@/hooks/query';
|
||||
import { DrawerHeaderContent, DrawerLoading } from '@/components';
|
||||
|
||||
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 (
|
||||
<DrawerLoading loading={isCustomerLoading}>
|
||||
<DrawerHeaderContent
|
||||
name="customer-detail-drawer"
|
||||
title={customer?.display_name}
|
||||
/>
|
||||
<ContactDetailDrawerContext.Provider value={provider} {...props} />
|
||||
</DrawerLoading>
|
||||
);
|
||||
}
|
||||
|
||||
const useCustomerDetailsDrawerContext = () =>
|
||||
React.useContext(ContactDetailDrawerContext);
|
||||
|
||||
export { CustomerDetailsDrawerProvider, useCustomerDetailsDrawerContext };
|
||||
Reference in New Issue
Block a user