mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
fix: rename expense form to project expense form.
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Form } from 'formik';
|
||||
import ExpenseFormFields from './ExpenseFormFields';
|
||||
import ExpneseFormFloatingActions from './ExpneseFormFloatingActions';
|
||||
|
||||
/**
|
||||
* Expense form content.
|
||||
* @returns
|
||||
*/
|
||||
export default function ExpenseFormContent() {
|
||||
return (
|
||||
<Form>
|
||||
<ExpenseFormFields />
|
||||
<ExpneseFormFloatingActions />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import React from 'react';
|
||||
import { ExpenseFormProvider } from './ExpenseFormProvider';
|
||||
import ExpenseForm from './ExpenseForm';
|
||||
|
||||
/**
|
||||
* Expense form dialog content.
|
||||
* @returns
|
||||
*/
|
||||
export default function ExpenseFormDialogContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
expense,
|
||||
}) {
|
||||
return (
|
||||
<ExpenseFormProvider dialogName={dialogName} expenseId={expense}>
|
||||
<ExpenseForm />
|
||||
</ExpenseFormProvider>
|
||||
);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//@ts-nocheck
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
|
||||
const ExpenseFormContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Expense form provider.
|
||||
* @returns
|
||||
*/
|
||||
function ExpenseFormProvider({
|
||||
//#OwnProps
|
||||
dialogName,
|
||||
expenseId,
|
||||
...props
|
||||
}) {
|
||||
// state provider.
|
||||
const provider = {
|
||||
dialogName,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent>
|
||||
<ExpenseFormContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
const useExpenseFormContext = () => React.useContext(ExpenseFormContext);
|
||||
export { ExpenseFormProvider, useExpenseFormContext };
|
||||
@@ -4,18 +4,20 @@ import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||
|
||||
const Schema = Yup.object().shape({
|
||||
expenseName: Yup.string().label(
|
||||
intl.get('expense.schema.label.expense_name'),
|
||||
intl.get('project_expense.schema.label.expense_name'),
|
||||
),
|
||||
estimatedExpense: Yup.number().label(
|
||||
intl.get('expense.schema.label.estimated_expense'),
|
||||
intl.get('project_expense.schema.label.estimated_expense'),
|
||||
),
|
||||
expemseDate: Yup.date(),
|
||||
expenseQuantity: Yup.number().label(intl.get('expense.schema.label.quantity')),
|
||||
expenseQuantity: Yup.number().label(
|
||||
intl.get('project_expense.schema.label.quantity'),
|
||||
),
|
||||
expenseUnitPrice: Yup.number().label(
|
||||
intl.get('expense.schema.label.unitPrice'),
|
||||
intl.get('project_expense.schema.label.unitPrice'),
|
||||
),
|
||||
expenseTotal: Yup.number(),
|
||||
expenseCharge: Yup.string(),
|
||||
});
|
||||
|
||||
export const CreateExpenseFormSchema = Schema;
|
||||
export const CreateProjectExpenseFormSchema = Schema;
|
||||
@@ -3,9 +3,9 @@ import moment from 'moment';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Formik } from 'formik';
|
||||
import { AppToaster } from 'components';
|
||||
import { CreateExpenseFormSchema } from './ExpenseForm.schema';
|
||||
import ExpenseFormContent from './ExpenseFormContent';
|
||||
import { useExpenseFormContext } from './ExpenseFormProvider';
|
||||
import { CreateProjectExpenseFormSchema } from './ProjectExpenseForm.schema';
|
||||
import ProjectExpenseFormContent from './ProjectExpenseFormContent';
|
||||
import { useProjectExpenseFormContext } from './ProjectExpenseFormProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
@@ -22,10 +22,10 @@ const defaultInitialValues = {
|
||||
};
|
||||
|
||||
/**
|
||||
* Expense form.
|
||||
* Project expense form.
|
||||
* @returns
|
||||
*/
|
||||
function ExpenseForm({
|
||||
function ProjectExpenseForm({
|
||||
//#withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
@@ -53,12 +53,12 @@ function ExpenseForm({
|
||||
};
|
||||
return (
|
||||
<Formik
|
||||
validationSchema={CreateExpenseFormSchema}
|
||||
validationSchema={CreateProjectExpenseFormSchema}
|
||||
initialValues={initialValues}
|
||||
onSubmit={handleFormSubmit}
|
||||
component={ExpenseFormContent}
|
||||
component={ProjectExpenseFormContent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(ExpenseForm);
|
||||
export default compose(withDialogActions)(ProjectExpenseForm);
|
||||
@@ -44,10 +44,10 @@ export default function ExpenseFormChargeFields() {
|
||||
|
||||
return (
|
||||
<Choose>
|
||||
<Choose.When condition={values.expenseCharge === '% markup'}>
|
||||
<Choose.When condition={values.expenseCharge === 'markup'}>
|
||||
<PercentageFormField />
|
||||
</Choose.When>
|
||||
<Choose.When condition={values.expenseCharge === 'Custom Pirce'}>
|
||||
<Choose.When condition={values.expenseCharge === 'custom_pirce'}>
|
||||
<CustomPirceField />
|
||||
</Choose.When>
|
||||
</Choose>
|
||||
@@ -0,0 +1,17 @@
|
||||
import React from 'react';
|
||||
import { Form } from 'formik';
|
||||
import ProjectExpenseFormFields from './ProjectExpenseFormFields';
|
||||
import ProjectExpneseFormFloatingActions from './ProjectExpneseFormFloatingActions';
|
||||
|
||||
/**
|
||||
* Expense form content.
|
||||
* @returns
|
||||
*/
|
||||
export default function ProjectExpenseFormContent() {
|
||||
return (
|
||||
<Form>
|
||||
<ProjectExpenseFormFields />
|
||||
<ProjectExpneseFormFloatingActions />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
import { ProjectExpenseFormProvider } from './ProjectExpenseFormProvider';
|
||||
import ProjectExpenseForm from './ProjectExpenseForm';
|
||||
|
||||
/**
|
||||
* Project expense form dialog content.
|
||||
* @returns
|
||||
*/
|
||||
export default function ProjectExpenseFormDialogContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
expense,
|
||||
}) {
|
||||
return (
|
||||
<ProjectExpenseFormProvider dialogName={dialogName} expenseId={expense}>
|
||||
<ProjectExpenseForm />
|
||||
</ProjectExpenseFormProvider>
|
||||
);
|
||||
}
|
||||
@@ -12,22 +12,22 @@ import {
|
||||
FormattedMessage as T,
|
||||
} from 'components';
|
||||
import { ExpenseSelect, FInputGroupComponent } from '../../components';
|
||||
import ExpenseFormChargeFields from './ExpenseFormChargeFields';
|
||||
import ExpenseFormChargeFields from './ProjectExpenseFormChargeFields';
|
||||
import { momentFormatter } from 'utils';
|
||||
import { useExpenseFormContext } from './ExpenseFormProvider';
|
||||
import { ChargeSelect } from '../../components';
|
||||
import { expenseChargeOption } from 'common/modalChargeOptions';
|
||||
import { useProjectExpenseFormContext } from './ProjectExpenseFormProvider';
|
||||
import { ChangeTypesSelect } from '../../components';
|
||||
import { expenseChargeOption } from 'containers/Projects/containers/common/modalChargeOptions';
|
||||
|
||||
/**
|
||||
* Expense form fields.
|
||||
* Project expense form fields.
|
||||
* @returns
|
||||
*/
|
||||
export default function ExpenseFormFields() {
|
||||
export default function ProjectExpenseFormFields() {
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
{/*------------ Expense Name -----------*/}
|
||||
<FFormGroup
|
||||
label={intl.get('expenses.dialog.expense_name')}
|
||||
label={intl.get('project_expense.dialog.expense_name')}
|
||||
name={'expenseName'}
|
||||
>
|
||||
<FInputGroup name="expenseName" />
|
||||
@@ -35,7 +35,7 @@ export default function ExpenseFormFields() {
|
||||
{/*------------ Track to Expense -----------*/}
|
||||
<FFormGroup
|
||||
name={'estimatedExpense'}
|
||||
label={intl.get('expenses.dialog.track_expense')}
|
||||
label={intl.get('project_expense.dialog.track_expense')}
|
||||
className={classNames('form-group--select-list', Classes.FILL)}
|
||||
>
|
||||
<ExpenseSelect
|
||||
@@ -47,7 +47,7 @@ export default function ExpenseFormFields() {
|
||||
|
||||
{/*------------ Extimated Date -----------*/}
|
||||
<FFormGroup
|
||||
label={intl.get('expenses.dialog.expense_date')}
|
||||
label={intl.get('project_expense.dialog.expense_date')}
|
||||
name={'expemseDate'}
|
||||
className={classNames(CLASSES.FILL, 'form-group--date')}
|
||||
>
|
||||
@@ -63,41 +63,41 @@ export default function ExpenseFormFields() {
|
||||
</FFormGroup>
|
||||
{/*------------ Quantity -----------*/}
|
||||
<FFormGroup
|
||||
label={intl.get('expenses.dialog.quantity')}
|
||||
label={intl.get('project_expense.dialog.quantity')}
|
||||
name={'expenseQuantity'}
|
||||
>
|
||||
<FInputGroupComponent name="expenseQuantity" />
|
||||
</FFormGroup>
|
||||
|
||||
<MetaLineLabel>
|
||||
<T id={'expenses.dialog.cost_to_you'} />
|
||||
<T id={'project_expense.dialog.cost_to_you'} />
|
||||
</MetaLineLabel>
|
||||
{/*------------ Unit Price -----------*/}
|
||||
<ControlGroup className={Classes.FILL}>
|
||||
<FFormGroup
|
||||
name={'unitPrice'}
|
||||
label={intl.get('expenses.dialog.unit_price')}
|
||||
label={intl.get('project_expense.dialog.unit_price')}
|
||||
>
|
||||
<FInputGroupComponent name="expenseUnitPrice" />
|
||||
</FFormGroup>
|
||||
<FFormGroup
|
||||
name={'expenseTotal'}
|
||||
label={intl.get('expenses.dialog.expense_total')}
|
||||
label={intl.get('project_expense.dialog.expense_total')}
|
||||
>
|
||||
<FInputGroup name="expenseTotal" />
|
||||
</FFormGroup>
|
||||
</ControlGroup>
|
||||
|
||||
<MetaLineLabel>
|
||||
<T id={'expenses.dialog.what_you_ll_charge'} />
|
||||
<T id={'project_expense.dialog.what_you_ll_charge'} />
|
||||
</MetaLineLabel>
|
||||
{/*------------ Charge -----------*/}
|
||||
<FFormGroup
|
||||
name={'expenseCharge'}
|
||||
label={<T id={'expenses.dialog.charge'} />}
|
||||
label={<T id={'project_expense.dialog.charge'} />}
|
||||
className={classNames('form-group--select-list', Classes.FILL)}
|
||||
>
|
||||
<ChargeSelect
|
||||
<ChangeTypesSelect
|
||||
name="expenseCharge"
|
||||
items={expenseChargeOption}
|
||||
popoverProps={{ minimal: true }}
|
||||
@@ -111,7 +111,7 @@ export default function ExpenseFormFields() {
|
||||
{/*------------ Total -----------*/}
|
||||
<ExpenseTotalBase>
|
||||
<ExpenseTotalLabel>
|
||||
<T id={'expenses.dialog.total'} />
|
||||
<T id={'project_expense.dialog.total'} />
|
||||
</ExpenseTotalLabel>
|
||||
<ExpenseTotal>0.00</ExpenseTotal>
|
||||
</ExpenseTotalBase>
|
||||
@@ -0,0 +1,30 @@
|
||||
//@ts-nocheck
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
|
||||
const ProjectExpenseFormContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Project expense form provider.
|
||||
* @returns
|
||||
*/
|
||||
function ProjectExpenseFormProvider({
|
||||
//#OwnProps
|
||||
dialogName,
|
||||
expenseId,
|
||||
...props
|
||||
}) {
|
||||
// state provider.
|
||||
const provider = {
|
||||
dialogName,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent>
|
||||
<ProjectExpenseFormContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
const useProjectExpenseFormContext = () => React.useContext(ProjectExpenseFormContext);
|
||||
export { ProjectExpenseFormProvider, useProjectExpenseFormContext };
|
||||
@@ -3,11 +3,11 @@ import React from 'react';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { Intent, Button, Classes } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { useExpenseFormContext } from './ExpenseFormProvider';
|
||||
import { useProjectExpenseFormContext } from './ProjectExpenseFormProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
function ExpneseFormFloatingActions({
|
||||
function ProjectExpneseFormFloatingActions({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
@@ -15,7 +15,7 @@ function ExpneseFormFloatingActions({
|
||||
const { isSubmitting } = useFormikContext();
|
||||
|
||||
// expense form dialog context.
|
||||
const { dialogName } = useExpenseFormContext();
|
||||
const { dialogName } = useProjectExpenseFormContext();
|
||||
|
||||
// Handle close button click.
|
||||
const handleCancelBtnClick = () => {
|
||||
@@ -41,4 +41,4 @@ function ExpneseFormFloatingActions({
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(ExpneseFormFloatingActions);
|
||||
export default compose(withDialogActions)(ProjectExpneseFormFloatingActions);
|
||||
@@ -4,41 +4,41 @@ import { Dialog, DialogSuspense, FormattedMessage as T } from 'components';
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const ExpenseFormeDialogContent = React.lazy(
|
||||
() => import('./ExpenseFormDialogContent'),
|
||||
const ProjectExpenseFormeDialogContent = React.lazy(
|
||||
() => import('./ProjectExpenseFormDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Expense form dialog.
|
||||
* Project expense form dialog.
|
||||
* @returns
|
||||
*/
|
||||
function ExpenseFormDialog({
|
||||
function ProjectExpenseFormDialog({
|
||||
dialogName,
|
||||
payload: { projectId = null },
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
<ExpenseFormDialogRoot
|
||||
<ProjectExpenseFormDialogRoot
|
||||
name={dialogName}
|
||||
title={<T id={'expenses.dialog.label'} />}
|
||||
title={<T id={'project_expense.dialog.label'} />}
|
||||
isOpen={isOpen}
|
||||
autoFocus={true}
|
||||
canEscapeKeyClose={true}
|
||||
style={{ width: '400px' }}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<ExpenseFormeDialogContent
|
||||
<ProjectExpenseFormeDialogContent
|
||||
dialogName={dialogName}
|
||||
expense={projectId}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</ExpenseFormDialogRoot>
|
||||
</ProjectExpenseFormDialogRoot>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogRedux())(ExpenseFormDialog);
|
||||
export default compose(withDialogRedux())(ProjectExpenseFormDialog);
|
||||
|
||||
const ExpenseFormDialogRoot = styled(Dialog)`
|
||||
const ProjectExpenseFormDialogRoot = styled(Dialog)`
|
||||
.bp3-dialog-body {
|
||||
.bp3-form-group {
|
||||
margin-bottom: 15px;
|
||||
Reference in New Issue
Block a user