feat : allocate landed cost.

This commit is contained in:
elforjani3
2021-07-25 01:16:24 +02:00
parent c72918fb1f
commit cd27864f6d
10 changed files with 161 additions and 115 deletions

View File

@@ -1,27 +1,50 @@
import React from 'react';
import { DialogContent } from 'components';
import { useBill } from 'hooks/query';
import { useBill, useCreateLandedCost } from 'hooks/query';
import { pick } from 'lodash';
import { map, omit, pick } from 'lodash';
import * as R from 'ramda';
const AllocateLandedCostDialogContext = React.createContext();
/**
* Allocate landed cost provider.
*/
function AllocateLandedCostDialogProvider({ billId, dialogName, ...props }) {
function AllocateLandedCostDialogProvider({
billId,
query,
dialogName,
...props
}) {
// Handle fetch bill details.
const { isLoading: isBillLoading, data: bill } = useBill(billId, {
enabled: !!billId,
});
// Create landed cost mutations.
const { mutateAsync: createLandedCostMutate } = useCreateLandedCost();
// const L = [bill].map(({ entries: items }) => ({
// items,
// }));
// let obj = { oldKey: 1, b: 2, c: 3 };
// const { oldKey: newKey, ...rest } = obj;
// obj = { newKey, ...rest };
// const obj = { ...pick(bill, ['entries']).map((index) => index) };
// provider payload.
const provider = {
bill: {
items: {
...pick(bill, ['entries']),
},
dialogName,
query,
createLandedCostMutate,
billId,
};
return (
<DialogContent isLoading={isBillLoading} name={'allocate-landed-cost'}>
<AllocateLandedCostDialogContext.Provider value={provider} {...props} />