feat(Sales & Purchases ): add branch & warehouse.

This commit is contained in:
elforjani13
2022-02-20 13:54:31 +02:00
parent 3ed2393cf1
commit b46c3f4843
35 changed files with 1184 additions and 28 deletions

View File

@@ -10,6 +10,8 @@ import {
useEditCreditNote,
useItems,
useCustomers,
useWarehouses,
useBranches,
useSettingsCreditNotes,
useInvoice,
} from 'hooks/query';
@@ -49,6 +51,20 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
enabled: !!invoiceId,
});
// Fetch warehouses list.
const {
data: warehouses,
isLoading: isWarehouesLoading,
isSuccess: isWarehousesSuccess,
} = useWarehouses();
// Fetches the branches list.
const {
data: branches,
isLoading: isBranchesLoading,
isSuccess: isBranchesSuccess,
} = useBranches();
// Handle fetching settings.
useSettingsCreditNotes();
@@ -62,6 +78,9 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
// Determines whether the form in new mode.
const isNewMode = !creditNoteId;
// Determines whether the warehouse and branches are loading.
const isFeatureLoading = isWarehouesLoading || isBranchesLoading;
const newCreditNote = !isEmpty(invoice)
? transformToEditForm({
...pick(invoice, ['customer_id', 'entries']),
@@ -73,13 +92,18 @@ function CreditNoteFormProvider({ creditNoteId, ...props }) {
items,
customers,
creditNote,
branches,
warehouses,
submitPayload,
isNewMode,
newCreditNote,
isItemsLoading,
isCustomersLoading,
isFeatureLoading,
isBranchesSuccess,
isWarehousesSuccess,
createCreditNoteMutate,
editCreditNoteMutate,
setSubmitPayload,