mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-27 18:19:48 +00:00
fix(webapp): branch and warehouse select not showing saved values in edit mode
Fixed an issue where branch and warehouse select fields were not displaying saved values when editing existing transactions. The useSetPrimaryBranchToForm and useSetPrimaryWarehouseToForm hooks were overwriting saved values with primary defaults on every form load. Changes: - Added isNewMode check to useSetPrimaryBranchToForm hook - Added isNewMode check to useSetPrimaryWarehouseToForm hook - Updated InvoiceFormProvider to expose isNewMode in context Affected forms: - Sales: Invoice, Estimate, Receipt, CreditNote, PaymentReceived - Purchases: Bill, VendorCredit, PaymentMade - Expense - MakeJournal (Manual Journal) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -213,17 +213,17 @@ export const currenciesFieldShouldUpdate = (newProps, oldProps) => {
|
||||
|
||||
export const useSetPrimaryBranchToForm = () => {
|
||||
const { setFieldValue } = useFormikContext();
|
||||
const { branches, isBranchesSuccess } = useMakeJournalFormContext();
|
||||
const { branches, isBranchesSuccess, isNewMode } = useMakeJournalFormContext();
|
||||
|
||||
React.useEffect(() => {
|
||||
if (isBranchesSuccess) {
|
||||
if (isBranchesSuccess && isNewMode) {
|
||||
const primaryBranch = branches.find((b) => b.primary) || first(branches);
|
||||
|
||||
if (primaryBranch) {
|
||||
setFieldValue('branch_id', primaryBranch.id);
|
||||
}
|
||||
}
|
||||
}, [isBranchesSuccess, setFieldValue, branches]);
|
||||
}, [isBranchesSuccess, setFieldValue, branches, isNewMode]);
|
||||
};
|
||||
|
||||
export const useManualJournalCreditTotal = () => {
|
||||
|
||||
Reference in New Issue
Block a user