mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat : allocate landed cost.
This commit is contained in:
@@ -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} />
|
||||
|
||||
Reference in New Issue
Block a user