mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-06-01 23:49:00 +00:00
## Summary Converted 905 default exports in src/containers to named exports for improved tree-shaking, better IDE refactoring support, and consistency with modern TypeScript practices. ## Changes - Converted `export default function X` to `export function X` (916 files) - Converted `export default compose(...)(X)` to `export const X = compose(...)(XInner)` with HOC wrapping - Updated 373 import sites from default to named imports - Fixed 136 React.lazy() imports to use .then() pattern for compatibility with named exports - Updated re-export patterns in index files - Fixed edge cases (alert arrays, connector HOCs, type definitions) ## Implementation - Created codemod script: codemod-containers-exports.js (905 files converted) - Created import updater: codemod-update-default-imports.js (373 imports fixed) - Created lazy import fixer: codemod-fix-lazy-imports.js (136 lazy imports fixed) - Manual fixes for 30 edge-case files (arrays, HOC factories, type definitions) ## Testing - TypeScript type check: 0 codemod-related errors - All lazy imports updated with .then() pattern - All import sites updated to use named imports - Zero remaining default exports in containers directory Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
2.0 KiB
TypeScript
81 lines
2.0 KiB
TypeScript
// @ts-nocheck
|
|
import React from 'react';
|
|
import { DataTableEditable } from '@/components';
|
|
import {
|
|
compose,
|
|
saveInvoke,
|
|
updateMinEntriesLines,
|
|
updateRemoveLineByIndex,
|
|
updateAutoAddNewLine,
|
|
updateTableCell,
|
|
} from '@/utils';
|
|
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
|
import { useJournalTableEntriesColumns } from './components';
|
|
import { updateAdjustEntries } from './utils';
|
|
|
|
/**
|
|
* Make journal entries table component.
|
|
*/
|
|
export function MakeJournalEntriesTable({
|
|
// #ownPorps
|
|
onChange,
|
|
entries,
|
|
defaultEntry,
|
|
error,
|
|
initialLinesNumber = 1,
|
|
minLinesNumber = 1,
|
|
currencyCode,
|
|
}) {
|
|
const { accounts, contacts, branches, projects } =
|
|
useMakeJournalFormContext();
|
|
|
|
// Memorized data table columns.
|
|
const columns = useJournalTableEntriesColumns();
|
|
|
|
// Handles update datatable data.
|
|
const handleUpdateData = (rowIndex, columnId, value) => {
|
|
const newRows = compose(
|
|
// Auto-adding new lines.
|
|
updateAutoAddNewLine(defaultEntry, ['account_id', 'credit', 'debit']),
|
|
// Update items entries total.
|
|
updateAdjustEntries(rowIndex, columnId, value),
|
|
// Update entry of the given row index and column id.
|
|
updateTableCell(rowIndex, columnId, value),
|
|
)(entries);
|
|
|
|
saveInvoke(onChange, newRows);
|
|
};
|
|
|
|
// Handle remove datatable row.
|
|
const handleRemoveRow = (rowIndex) => {
|
|
const newRows = compose(
|
|
// Ensure minimum lines count.
|
|
updateMinEntriesLines(minLinesNumber, defaultEntry),
|
|
// Remove the line by the given index.
|
|
updateRemoveLineByIndex(rowIndex),
|
|
)(entries);
|
|
|
|
saveInvoke(onChange, newRows);
|
|
};
|
|
|
|
return (
|
|
<DataTableEditable
|
|
columns={columns}
|
|
data={entries}
|
|
sticky={true}
|
|
totalRow={true}
|
|
payload={{
|
|
accounts,
|
|
errors: error,
|
|
updateData: handleUpdateData,
|
|
removeRow: handleRemoveRow,
|
|
contacts,
|
|
branches,
|
|
projects,
|
|
autoFocus: ['account_id', 0],
|
|
currencyCode,
|
|
}}
|
|
/>
|
|
);
|
|
}
|