mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 14:50:32 +00:00
fix: project tasks.
This commit is contained in:
@@ -37,7 +37,7 @@ function ProjectTaskDeleteAlert({
|
|||||||
deleteProjectTaskMutate(taskId)
|
deleteProjectTaskMutate(taskId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: intl.get('projects.alert.delete_message'),
|
message: intl.get('project_task.alert.delete_message'),
|
||||||
intent: Intent.SUCCESS,
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@@ -65,7 +65,7 @@ function ProjectTaskDeleteAlert({
|
|||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedHTMLMessage id={'projects.alert.once_delete_this_project'} />
|
<FormattedHTMLMessage id={'project_task.alert.once_delete_this_project'} />
|
||||||
</p>
|
</p>
|
||||||
</Alert>
|
</Alert>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useProjectTasks } from '../../../hooks';
|
import { useProjectTasks, useProject } from '../../../hooks';
|
||||||
|
|
||||||
const ProjectTaskContext = React.createContext();
|
const ProjectTaskContext = React.createContext();
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ function ProjectTaskProvider({ ...props }) {
|
|||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const projectId = parseInt(id, 10);
|
const projectId = parseInt(id, 10);
|
||||||
|
|
||||||
|
// Handle fetch project tasks.
|
||||||
const {
|
const {
|
||||||
data: { projectTasks },
|
data: { projectTasks },
|
||||||
isFetching: isProjectTasksFetching,
|
isFetching: isProjectTasksFetching,
|
||||||
@@ -20,8 +21,15 @@ function ProjectTaskProvider({ ...props }) {
|
|||||||
enabled: !!projectId,
|
enabled: !!projectId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Handle fetch project detail.
|
||||||
|
const { data: project, isLoading: isProjectLoading } = useProject(projectId, {
|
||||||
|
enabled: !!projectId,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(project, 'XX');
|
||||||
// provider payload.
|
// provider payload.
|
||||||
const provider = {
|
const provider = {
|
||||||
|
project,
|
||||||
projectId,
|
projectId,
|
||||||
projectTasks,
|
projectTasks,
|
||||||
isProjectTasksFetching,
|
isProjectTasksFetching,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
FinancialProgressBar,
|
FinancialProgressBar,
|
||||||
FinancialCardText,
|
FinancialCardText,
|
||||||
} from '../components';
|
} from '../components';
|
||||||
|
import { useProjectTaskContext } from './ProjectTaskProvider';
|
||||||
import { calculateStatus } from '@/utils';
|
import { calculateStatus } from '@/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,9 +15,14 @@ import { calculateStatus } from '@/utils';
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function ProjectTasksHeader() {
|
export function ProjectTasksHeader() {
|
||||||
|
const { project } = useProjectTaskContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DetailFinancialSection>
|
<DetailFinancialSection>
|
||||||
<DetailFinancialCard label={'Project estimate'} value={'3.14'} />
|
<DetailFinancialCard
|
||||||
|
label={'Project estimate'}
|
||||||
|
value={project.cost_estimate_formatted}
|
||||||
|
/>
|
||||||
<DetailFinancialCard label={'Invoiced'} value={'0.00'}>
|
<DetailFinancialCard label={'Invoiced'} value={'0.00'}>
|
||||||
<FinancialCardText>0% of project estimate</FinancialCardText>
|
<FinancialCardText>0% of project estimate</FinancialCardText>
|
||||||
<FinancialProgressBar intent={Intent.NONE} value={0} />
|
<FinancialProgressBar intent={Intent.NONE} value={0} />
|
||||||
|
|||||||
@@ -37,9 +37,16 @@ export function TaskAccessor(row) {
|
|||||||
</TaskHeader>
|
</TaskHeader>
|
||||||
<TaskContent>
|
<TaskContent>
|
||||||
{row.charge_type === 'hourly_rate'
|
{row.charge_type === 'hourly_rate'
|
||||||
? row.rate + ' / hour'
|
? intl.get('project_task.rate', {
|
||||||
: row.charge_type}
|
rate: row.rate,
|
||||||
<TaskDescription>{row.estimate_minutes} estimated</TaskDescription>
|
})
|
||||||
|
: intl.get(row.charge_type)}
|
||||||
|
<TaskDescription>
|
||||||
|
{row.estimate_minutes &&
|
||||||
|
intl.get('project_task.estimate_minutes', {
|
||||||
|
estimate_minutes: row.estimate_minutes,
|
||||||
|
})}
|
||||||
|
</TaskDescription>
|
||||||
</TaskContent>
|
</TaskContent>
|
||||||
</TaskRoot>
|
</TaskRoot>
|
||||||
);
|
);
|
||||||
@@ -55,7 +62,6 @@ const TaskHeader = styled.div`
|
|||||||
`;
|
`;
|
||||||
const TaskTitle = styled.span`
|
const TaskTitle = styled.span`
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
/* margin-right: 12px; */
|
|
||||||
line-height: 1.5rem;
|
line-height: 1.5rem;
|
||||||
`;
|
`;
|
||||||
const TaskContent = styled.div`
|
const TaskContent = styled.div`
|
||||||
@@ -67,8 +73,5 @@ const TaskContent = styled.div`
|
|||||||
line-height: 1.2rem;
|
line-height: 1.2rem;
|
||||||
`;
|
`;
|
||||||
const TaskDescription = styled.span`
|
const TaskDescription = styled.span`
|
||||||
&::before {
|
margin: 0.3rem;
|
||||||
content: '•';
|
|
||||||
margin: 0.3rem;
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ import { CreateProjectTaskFormSchema } from './ProjectTaskForm.schema';
|
|||||||
import { useProjectTaskFormContext } from './ProjectTaskFormProvider';
|
import { useProjectTaskFormContext } from './ProjectTaskFormProvider';
|
||||||
import ProjectTaskFormContent from './ProjectTaskFormContent';
|
import ProjectTaskFormContent from './ProjectTaskFormContent';
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
|
import { transformToValue } from './utils';
|
||||||
import { compose, transformToForm } from '@/utils';
|
import { compose, transformToForm } from '@/utils';
|
||||||
|
|
||||||
const defaultInitialValues = {
|
const defaultInitialValues = {
|
||||||
name: '',
|
name: '',
|
||||||
charge_type: 'fixed_price',
|
charge_type: 'fixed_price',
|
||||||
estimate_minutes: '',
|
estimate_minutes: '',
|
||||||
cost_estimate: '',
|
cost_estimate: 0,
|
||||||
rate: '0.00',
|
rate: '0.00',
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ function ProjectTaskForm({
|
|||||||
|
|
||||||
// Handles the form submit.
|
// Handles the form submit.
|
||||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||||
const form = { ...values };
|
const form = transformToValue(values);
|
||||||
|
|
||||||
// Handle request response success.
|
// Handle request response success.
|
||||||
const onSuccess = (response) => {
|
const onSuccess = (response) => {
|
||||||
@@ -67,7 +67,7 @@ function ProjectTaskForm({
|
|||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
if (isNewMode) {
|
if (isNewMode) {
|
||||||
createProjectTaskMutate([projectId, form]).then(onSuccess).catch(onError);
|
createProjectTaskMutate([projectId, form]).then(onSuccess).catch(onError);
|
||||||
|
|||||||
@@ -32,6 +32,28 @@ export function EstimateAmount() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function transformToValue(values) {
|
||||||
|
switch (values.charge_type) {
|
||||||
|
case 'hourly_rate': {
|
||||||
|
return {
|
||||||
|
...values,
|
||||||
|
cost_estimate: values.estimate_minutes * values.rate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
case 'fixed_price': {
|
||||||
|
return {
|
||||||
|
...values,
|
||||||
|
cost_estimate: values.rate,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return {
|
||||||
|
...values,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const EstimatedAmountBase = styled.div`
|
const EstimatedAmountBase = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|||||||
@@ -2063,9 +2063,9 @@
|
|||||||
"projects.dialog.edit_project": "Edit Project",
|
"projects.dialog.edit_project": "Edit Project",
|
||||||
"projects.alert.delete_message": "The deleted project has been deleted successfully.",
|
"projects.alert.delete_message": "The deleted project has been deleted successfully.",
|
||||||
"projects.alert.once_delete_this_project": "Once you delete this project, you won't be able to restore it later. Are you sure you want to delete this project?",
|
"projects.alert.once_delete_this_project": "Once you delete this project, you won't be able to restore it later. Are you sure you want to delete this project?",
|
||||||
"projects.empty_status.title":"",
|
"projects.empty_status.title": "",
|
||||||
"projects.empty_status.description":"",
|
"projects.empty_status.description": "",
|
||||||
"projects.empty_status.action":"New Project",
|
"projects.empty_status.action": "New Project",
|
||||||
"project_task.dialog.new_task": "New Task",
|
"project_task.dialog.new_task": "New Task",
|
||||||
"project_task.dialog.edit_task": "Edit Task",
|
"project_task.dialog.edit_task": "Edit Task",
|
||||||
"project_task.dialog.task_name": "Task Name",
|
"project_task.dialog.task_name": "Task Name",
|
||||||
@@ -2076,10 +2076,16 @@
|
|||||||
"project_task.dialog.hourly_rate": "Hourly rate",
|
"project_task.dialog.hourly_rate": "Hourly rate",
|
||||||
"project_task.dialog.fixed_price": "Fixed price",
|
"project_task.dialog.fixed_price": "Fixed price",
|
||||||
"project_task.dialog.non_chargeable": "Non-chargeable",
|
"project_task.dialog.non_chargeable": "Non-chargeable",
|
||||||
"project_task.dialog.success_message":"The task has been created successfully.",
|
"project_task.dialog.success_message": "The task has been created successfully.",
|
||||||
"project_task.dialog.edit_success_message":"The task has been created successfully.",
|
"project_task.dialog.edit_success_message": "The task has been created successfully.",
|
||||||
"project_task.action.edit_task": "Edit Task",
|
"project_task.action.edit_task": "Edit Task",
|
||||||
"project_task.action.delete_task": "Delete Task",
|
"project_task.action.delete_task": "Delete Task",
|
||||||
|
"project_task.rate": "{rate} /hour",
|
||||||
|
"project_task.estimate_minutes": "• {estimate_minutes}h 0m estimated",
|
||||||
|
"project_task.alert.delete_message": "The deleted task has been deleted successfully.",
|
||||||
|
"project_task.alert.once_delete_this_project": "Once you delete this task, you won't be able to restore it later. Are you sure you want to delete this task?",
|
||||||
|
"fixed_price": "Fixed price",
|
||||||
|
"non_chargeable": "Non-chargeable",
|
||||||
"project.schema.label.contact": "Contact",
|
"project.schema.label.contact": "Contact",
|
||||||
"project.schema.label.project_name": "Project name",
|
"project.schema.label.project_name": "Project name",
|
||||||
"project.schema.label.deadline": "Deadline",
|
"project.schema.label.deadline": "Deadline",
|
||||||
|
|||||||
Reference in New Issue
Block a user