mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-14 20:00:33 +00:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
import React from 'react';
|
|
import { DialogContent } from 'components';
|
|
import {
|
|
useEstimateSMSDetail,
|
|
useCreateNotifyEstimateBySMS,
|
|
} from 'hooks/query';
|
|
|
|
const NotifyEstimateViaSMSContext = React.createContext();
|
|
|
|
function NotifyEstimateViaSMSFormProvider({
|
|
estimateId,
|
|
dialogName,
|
|
...props
|
|
}) {
|
|
const { data: estimateSMSDetail, isLoading: isEstimateSMSDetailLoading } =
|
|
useEstimateSMSDetail(estimateId, {
|
|
enabled: !!estimateId,
|
|
});
|
|
|
|
// Create notfiy estimate by sms mutations.
|
|
const { mutateAsync: createNotifyEstimateBySMSMutate } =
|
|
useCreateNotifyEstimateBySMS();
|
|
|
|
// State provider.
|
|
const provider = {
|
|
estimateId,
|
|
dialogName,
|
|
estimateSMSDetail,
|
|
createNotifyEstimateBySMSMutate,
|
|
};
|
|
|
|
return (
|
|
<DialogContent isLoading={isEstimateSMSDetailLoading}>
|
|
<NotifyEstimateViaSMSContext.Provider value={provider} {...props} />
|
|
</DialogContent>
|
|
);
|
|
}
|
|
|
|
const useEstimateViaSMSContext = () =>
|
|
React.useContext(NotifyEstimateViaSMSContext);
|
|
|
|
export { NotifyEstimateViaSMSFormProvider, useEstimateViaSMSContext };
|