mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(ExpenseForm): optimize style fo expense form.
This commit is contained in:
@@ -22,28 +22,7 @@ const ERROR = {
|
||||
'ENTRIES_ALLOCATED_COST_COULD_NOT_DELETED',
|
||||
};
|
||||
|
||||
// Transform API errors in toasts messages.
|
||||
export const transformErrors = (errors, { setErrors }) => {
|
||||
const hasError = (errorType) => errors.some((e) => e.type === errorType);
|
||||
|
||||
if (hasError(ERROR.EXPENSE_ALREADY_PUBLISHED)) {
|
||||
setErrors(
|
||||
AppToaster.show({
|
||||
message: intl.get('the_expense_is_already_published'),
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (hasError(ERROR.ENTRIES_ALLOCATED_COST_COULD_NOT_DELETED)) {
|
||||
setErrors(
|
||||
AppToaster.show({
|
||||
intent: Intent.DANGER,
|
||||
message: 'ENTRIES_ALLOCATED_COST_COULD_NOT_DELETED',
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export const MIN_LINES_NUMBER = 4;
|
||||
export const MIN_LINES_NUMBER = 1;
|
||||
|
||||
export const defaultExpenseEntry = {
|
||||
amount: '',
|
||||
@@ -65,6 +44,29 @@ export const defaultExpense = {
|
||||
categories: [...repeatValue(defaultExpenseEntry, MIN_LINES_NUMBER)],
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform API errors in toasts messages.
|
||||
*/
|
||||
export const transformErrors = (errors, { setErrors }) => {
|
||||
const hasError = (errorType) => errors.some((e) => e.type === errorType);
|
||||
|
||||
if (hasError(ERROR.EXPENSE_ALREADY_PUBLISHED)) {
|
||||
setErrors(
|
||||
AppToaster.show({
|
||||
message: intl.get('the_expense_is_already_published'),
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (hasError(ERROR.ENTRIES_ALLOCATED_COST_COULD_NOT_DELETED)) {
|
||||
setErrors(
|
||||
AppToaster.show({
|
||||
intent: Intent.DANGER,
|
||||
message: 'ENTRIES_ALLOCATED_COST_COULD_NOT_DELETED',
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Transformes the expense to form initial values in edit mode.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user