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