feat: add currency code to project task form.
This commit is contained in:
@@ -5,10 +5,10 @@ import { Intent } from '@blueprintjs/core';
|
||||
import { AppToaster } from '@/components';
|
||||
import { CreateProjectTaskFormSchema } from './ProjectTaskForm.schema';
|
||||
import { useProjectTaskFormContext } from './ProjectTaskFormProvider';
|
||||
import ProjectTaskFormContent from './ProjectTaskFormContent';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import { transformToValue } from './utils';
|
||||
import { compose, transformToForm } from '@/utils';
|
||||
import ProjectTaskFormContent from './ProjectTaskFormContent';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
|
||||
const defaultInitialValues = {
|
||||
name: '',
|
||||
|
||||
@@ -11,12 +11,17 @@ import {
|
||||
import { EstimateAmount } from './utils';
|
||||
import { taskChargeOptions } from '../common/modalChargeOptions';
|
||||
import { ChangeTypesSelect } from '../../components';
|
||||
import withCurrentOrganization from '@/containers/Organization/withCurrentOrganization';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
/**
|
||||
* Project task form fields.
|
||||
* @returns
|
||||
*/
|
||||
function ProjectTaskFormFields() {
|
||||
function ProjectTaskFormFields({
|
||||
// #withCurrentOrganization
|
||||
organization: { base_currency },
|
||||
}) {
|
||||
// Formik context.
|
||||
const { values } = useFormikContext();
|
||||
|
||||
@@ -62,9 +67,9 @@ function ProjectTaskFormFields() {
|
||||
</Col>
|
||||
</Row>
|
||||
{/*------------ Estimated Amount -----------*/}
|
||||
<EstimateAmount />
|
||||
<EstimateAmount baseCurrency={base_currency} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ProjectTaskFormFields;
|
||||
export default compose(withCurrentOrganization())(ProjectTaskFormFields);
|
||||
|
||||
@@ -2,9 +2,9 @@ import React from 'react';
|
||||
import _ from 'lodash';
|
||||
import { useFormikContext } from 'formik';
|
||||
import styled from 'styled-components';
|
||||
import { Choose, FormattedMessage as T } from '@/components';
|
||||
import { Choose, Money, FormattedMessage as T } from '@/components';
|
||||
|
||||
export function EstimateAmount() {
|
||||
export function EstimateAmount({ baseCurrency }) {
|
||||
const { values } = useFormikContext();
|
||||
|
||||
// Calculate estimate amount.
|
||||
@@ -16,15 +16,21 @@ export function EstimateAmount() {
|
||||
<Choose>
|
||||
<Choose.When condition={values?.charge_type === 'hourly_rate'}>
|
||||
<T id={'project_task.dialog.estimated_amount'} />
|
||||
<EstimatedAmount>{estimatedAmount}</EstimatedAmount>
|
||||
<EstimatedAmount>
|
||||
<Money amount={estimatedAmount} currency={baseCurrency} />
|
||||
</EstimatedAmount>
|
||||
</Choose.When>
|
||||
<Choose.When condition={values?.charge_type === 'fixed_price'}>
|
||||
<T id={'project_task.dialog.total'} />
|
||||
<EstimatedAmount>{values.rate}</EstimatedAmount>
|
||||
<EstimatedAmount>
|
||||
<Money amount={values.rate} currency={baseCurrency} />
|
||||
</EstimatedAmount>
|
||||
</Choose.When>
|
||||
<Choose.Otherwise>
|
||||
<T id={'project_task.dialog.total'} />
|
||||
<EstimatedAmount>0.00</EstimatedAmount>
|
||||
<EstimatedAmount>
|
||||
<Money amount={0.0} currency={baseCurrency} />
|
||||
</EstimatedAmount>
|
||||
</Choose.Otherwise>
|
||||
</Choose>
|
||||
</EstimatedAmountContent>
|
||||
|
||||
Reference in New Issue
Block a user