mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix: project tasks.
This commit is contained in:
@@ -37,7 +37,7 @@ function ProjectTaskDeleteAlert({
|
||||
deleteProjectTaskMutate(taskId)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('projects.alert.delete_message'),
|
||||
message: intl.get('project_task.alert.delete_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
})
|
||||
@@ -65,7 +65,7 @@ function ProjectTaskDeleteAlert({
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage id={'projects.alert.once_delete_this_project'} />
|
||||
<FormattedHTMLMessage id={'project_task.alert.once_delete_this_project'} />
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useProjectTasks } from '../../../hooks';
|
||||
import { useProjectTasks, useProject } from '../../../hooks';
|
||||
|
||||
const ProjectTaskContext = React.createContext();
|
||||
|
||||
@@ -12,6 +12,7 @@ function ProjectTaskProvider({ ...props }) {
|
||||
const { id } = useParams();
|
||||
const projectId = parseInt(id, 10);
|
||||
|
||||
// Handle fetch project tasks.
|
||||
const {
|
||||
data: { projectTasks },
|
||||
isFetching: isProjectTasksFetching,
|
||||
@@ -20,8 +21,15 @@ function ProjectTaskProvider({ ...props }) {
|
||||
enabled: !!projectId,
|
||||
});
|
||||
|
||||
// Handle fetch project detail.
|
||||
const { data: project, isLoading: isProjectLoading } = useProject(projectId, {
|
||||
enabled: !!projectId,
|
||||
});
|
||||
|
||||
console.log(project, 'XX');
|
||||
// provider payload.
|
||||
const provider = {
|
||||
project,
|
||||
projectId,
|
||||
projectTasks,
|
||||
isProjectTasksFetching,
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
FinancialProgressBar,
|
||||
FinancialCardText,
|
||||
} from '../components';
|
||||
import { useProjectTaskContext } from './ProjectTaskProvider';
|
||||
import { calculateStatus } from '@/utils';
|
||||
|
||||
/**
|
||||
@@ -14,9 +15,14 @@ import { calculateStatus } from '@/utils';
|
||||
* @returns
|
||||
*/
|
||||
export function ProjectTasksHeader() {
|
||||
const { project } = useProjectTaskContext();
|
||||
|
||||
return (
|
||||
<DetailFinancialSection>
|
||||
<DetailFinancialCard label={'Project estimate'} value={'3.14'} />
|
||||
<DetailFinancialCard
|
||||
label={'Project estimate'}
|
||||
value={project.cost_estimate_formatted}
|
||||
/>
|
||||
<DetailFinancialCard label={'Invoiced'} value={'0.00'}>
|
||||
<FinancialCardText>0% of project estimate</FinancialCardText>
|
||||
<FinancialProgressBar intent={Intent.NONE} value={0} />
|
||||
|
||||
@@ -37,9 +37,16 @@ export function TaskAccessor(row) {
|
||||
</TaskHeader>
|
||||
<TaskContent>
|
||||
{row.charge_type === 'hourly_rate'
|
||||
? row.rate + ' / hour'
|
||||
: row.charge_type}
|
||||
<TaskDescription>{row.estimate_minutes} estimated</TaskDescription>
|
||||
? intl.get('project_task.rate', {
|
||||
rate: row.rate,
|
||||
})
|
||||
: intl.get(row.charge_type)}
|
||||
<TaskDescription>
|
||||
{row.estimate_minutes &&
|
||||
intl.get('project_task.estimate_minutes', {
|
||||
estimate_minutes: row.estimate_minutes,
|
||||
})}
|
||||
</TaskDescription>
|
||||
</TaskContent>
|
||||
</TaskRoot>
|
||||
);
|
||||
@@ -55,7 +62,6 @@ const TaskHeader = styled.div`
|
||||
`;
|
||||
const TaskTitle = styled.span`
|
||||
font-weight: 500;
|
||||
/* margin-right: 12px; */
|
||||
line-height: 1.5rem;
|
||||
`;
|
||||
const TaskContent = styled.div`
|
||||
@@ -67,8 +73,5 @@ const TaskContent = styled.div`
|
||||
line-height: 1.2rem;
|
||||
`;
|
||||
const TaskDescription = styled.span`
|
||||
&::before {
|
||||
content: '•';
|
||||
margin: 0.3rem;
|
||||
}
|
||||
margin: 0.3rem;
|
||||
`;
|
||||
|
||||
@@ -7,14 +7,14 @@ 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';
|
||||
|
||||
const defaultInitialValues = {
|
||||
name: '',
|
||||
charge_type: 'fixed_price',
|
||||
estimate_minutes: '',
|
||||
cost_estimate: '',
|
||||
cost_estimate: 0,
|
||||
rate: '0.00',
|
||||
};
|
||||
|
||||
@@ -45,7 +45,7 @@ function ProjectTaskForm({
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||
const form = { ...values };
|
||||
const form = transformToValue(values);
|
||||
|
||||
// Handle request response success.
|
||||
const onSuccess = (response) => {
|
||||
@@ -67,7 +67,7 @@ function ProjectTaskForm({
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
setSubmitting(false);
|
||||
setSubmitting(false);
|
||||
};
|
||||
if (isNewMode) {
|
||||
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`
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
@@ -2063,9 +2063,9 @@
|
||||
"projects.dialog.edit_project": "Edit Project",
|
||||
"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.empty_status.title":"",
|
||||
"projects.empty_status.description":"",
|
||||
"projects.empty_status.action":"New Project",
|
||||
"projects.empty_status.title": "",
|
||||
"projects.empty_status.description": "",
|
||||
"projects.empty_status.action": "New Project",
|
||||
"project_task.dialog.new_task": "New Task",
|
||||
"project_task.dialog.edit_task": "Edit Task",
|
||||
"project_task.dialog.task_name": "Task Name",
|
||||
@@ -2076,10 +2076,16 @@
|
||||
"project_task.dialog.hourly_rate": "Hourly rate",
|
||||
"project_task.dialog.fixed_price": "Fixed price",
|
||||
"project_task.dialog.non_chargeable": "Non-chargeable",
|
||||
"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.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.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.project_name": "Project name",
|
||||
"project.schema.label.deadline": "Deadline",
|
||||
|
||||
Reference in New Issue
Block a user