re-structure to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 01:02:31 +02:00
parent 8242ec64ba
commit 7a0a13f9d5
10400 changed files with 46966 additions and 17223 deletions

View File

@@ -0,0 +1,52 @@
// @ts-nocheck
import React from 'react';
import intl from 'react-intl-universal';
import { Features } from '@/constants';
import { useEstimate } from '@/hooks/query';
import { useFeatureCan } from '@/hooks/state';
import { DrawerHeaderContent, DrawerLoading } from '@/components';
const EstimateDetailDrawerContext = React.createContext();
/**
* Estimate detail provider.
*/
function EstimateDetailDrawerProvider({ estimateId, ...props }) {
// Features guard.
const { featureCan } = useFeatureCan();
// Fetches the estimate by the given id.
const { data: estimate, isLoading: isEstimateLoading } = useEstimate(
estimateId,
{ enabled: !!estimateId },
);
const provider = {
estimateId,
estimate,
};
return (
<DrawerLoading loading={isEstimateLoading}>
<DrawerHeaderContent
name="estimate-detail-drawer"
title={intl.get('estimate.drawer.title', {
number: estimate.estimate_number,
})}
subTitle={
featureCan(Features.Branches)
? intl.get('estimate.drawer.subtitle', {
value: estimate.branch?.name,
})
: null
}
/>
<EstimateDetailDrawerContext.Provider value={provider} {...props} />
</DrawerLoading>
);
}
const useEstimateDetailDrawerContext = () =>
React.useContext(EstimateDetailDrawerContext);
export { EstimateDetailDrawerProvider, useEstimateDetailDrawerContext };