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>
143 lines
3.6 KiB
TypeScript
143 lines
3.6 KiB
TypeScript
// @ts-nocheck
|
|
import React from 'react';
|
|
import { Position } from '@blueprintjs/core';
|
|
import { useFormikContext } from 'formik';
|
|
import classNames from 'classnames';
|
|
import { useTheme } from '@emotion/react';
|
|
import { css } from '@emotion/css';
|
|
|
|
import { CLASSES } from '@/constants/classes';
|
|
import {} from '@/utils';
|
|
import {
|
|
Hint,
|
|
FieldRequiredHint,
|
|
Icon,
|
|
FSelect,
|
|
FormattedMessage as T,
|
|
FFormGroup,
|
|
FInputGroup,
|
|
FDateInput,
|
|
Stack,
|
|
} from '@/components';
|
|
import { useMakeJournalFormContext } from './MakeJournalProvider';
|
|
import { JournalExchangeRateInputField } from './components';
|
|
import { MakeJournalTransactionNoField } from './MakeJournalTransactionNoField';
|
|
import intl from 'react-intl-universal';
|
|
|
|
const getFieldsStyle = (theme: Theme) => css`
|
|
.${theme.bpPrefix}-form-group {
|
|
margin-bottom: 0;
|
|
|
|
&.${theme.bpPrefix}-inline {
|
|
max-width: 450px;
|
|
}
|
|
.${theme.bpPrefix}-label {
|
|
min-width: 150px;
|
|
font-weight: 500;
|
|
}
|
|
.${theme.bpPrefix}-form-content {
|
|
width: 100%;
|
|
}
|
|
}
|
|
`;
|
|
|
|
/**
|
|
* Make journal entries header.
|
|
*/
|
|
export function MakeJournalEntriesHeader({}) {
|
|
const { currencies } = useMakeJournalFormContext();
|
|
const form = useFormikContext();
|
|
const theme = useTheme();
|
|
const fieldsClassName = getFieldsStyle(theme);
|
|
|
|
return (
|
|
<Stack spacing={18} flex={1} className={fieldsClassName}>
|
|
{/*------------ Posting date -----------*/}
|
|
<FFormGroup
|
|
name={'date'}
|
|
label={intl.get('posting_date')}
|
|
labelInfo={<FieldRequiredHint />}
|
|
inline
|
|
fastField
|
|
>
|
|
<FDateInput
|
|
name={'date'}
|
|
formatDate={(date) => date.toLocaleDateString()}
|
|
parseDate={(str) => new Date(str)}
|
|
popoverProps={{
|
|
position: Position.BOTTOM_LEFT,
|
|
minimal: true,
|
|
fill: true,
|
|
}}
|
|
inputProps={{
|
|
leftIcon: <Icon icon={'date-range'} />,
|
|
}}
|
|
fill
|
|
fastField
|
|
/>
|
|
</FFormGroup>
|
|
|
|
{/*------------ Journal number -----------*/}
|
|
<MakeJournalTransactionNoField />
|
|
|
|
{/*------------ Reference -----------*/}
|
|
<FFormGroup
|
|
name={'reference'}
|
|
label={intl.get('reference')}
|
|
labelInfo={
|
|
<Hint
|
|
content={<T id={'journal_reference_hint'} />}
|
|
position={Position.RIGHT}
|
|
/>
|
|
}
|
|
inline
|
|
fastField
|
|
>
|
|
<FInputGroup name={'reference'} minimal fill />
|
|
</FFormGroup>
|
|
|
|
{/*------------ Journal type -----------*/}
|
|
<FFormGroup
|
|
name={'journal_type'}
|
|
label={intl.get('journal_type')}
|
|
inline
|
|
fastField
|
|
>
|
|
<FInputGroup name={'journal_type'} minimal fill />
|
|
</FFormGroup>
|
|
|
|
{/*------------ Currency -----------*/}
|
|
<FFormGroup
|
|
name={'currency_code'}
|
|
label={intl.get('currency')}
|
|
inline
|
|
fastField
|
|
>
|
|
<FSelect
|
|
name={'currency_code'}
|
|
items={currencies}
|
|
onItemChange={(currencyItem) => {
|
|
form.setFieldValue('currency_code', currencyItem.currency_code);
|
|
form.setFieldValue('exchange_rate', '');
|
|
}}
|
|
popoverProps={{
|
|
inline: true,
|
|
minimal: true,
|
|
captureDismiss: true,
|
|
}}
|
|
valueAccessor={'currency_code'}
|
|
labelAccessor={'currency_name'}
|
|
textAccessor={'currency_code'}
|
|
fastField
|
|
/>
|
|
</FFormGroup>
|
|
|
|
{/* ----------- Exchange rate ----------- */}
|
|
<JournalExchangeRateInputField
|
|
name={'exchange_rate'}
|
|
formGroupProps={{ label: ' ', inline: true }}
|
|
/>
|
|
</Stack>
|
|
);
|
|
}
|