From 61ec4efa3f7d6a61e7d2597a5eb6cf522fb8e476 Mon Sep 17 00:00:00 2001 From: Wayne Date: Tue, 26 Mar 2024 23:16:45 +0900 Subject: [PATCH] Move sections around in project creation --- .../CreateProject/CreateProject.tsx | 10 ++-- .../{ResourceMilestone.tsx => Milestone.tsx} | 28 ++-------- .../CreateProject/MilestoneSection.tsx | 2 +- ...urceSection.tsx => ResourceAllocation.tsx} | 21 +++++--- .../CreateProject/StaffAllocation.tsx | 51 ++++++++++++++----- 5 files changed, 64 insertions(+), 48 deletions(-) rename src/components/CreateProject/{ResourceMilestone.tsx => Milestone.tsx} (77%) rename src/components/CreateProject/{ResourceSection.tsx => ResourceAllocation.tsx} (92%) diff --git a/src/components/CreateProject/CreateProject.tsx b/src/components/CreateProject/CreateProject.tsx index e6c8e21..3fb6c4a 100644 --- a/src/components/CreateProject/CreateProject.tsx +++ b/src/components/CreateProject/CreateProject.tsx @@ -12,7 +12,7 @@ import { useTranslation } from "react-i18next"; import ProjectClientDetails from "./ProjectClientDetails"; import TaskSetup from "./TaskSetup"; import StaffAllocation from "./StaffAllocation"; -import ResourceMilestone from "./ResourceMilestone"; +import Milestone from "./Milestone"; import { Task, TaskTemplate } from "@/app/api/tasks"; import { FieldErrors, @@ -122,8 +122,8 @@ const CreateProject: React.FC = ({ iconPosition="end" /> - - + + { = ({ isActive={tabIndex === 1} /> } - {} - {} + {} + {} {serverError && ( {serverError} diff --git a/src/components/CreateProject/ResourceMilestone.tsx b/src/components/CreateProject/Milestone.tsx similarity index 77% rename from src/components/CreateProject/ResourceMilestone.tsx rename to src/components/CreateProject/Milestone.tsx index 7ba5d55..9d61e32 100644 --- a/src/components/CreateProject/ResourceMilestone.tsx +++ b/src/components/CreateProject/Milestone.tsx @@ -2,7 +2,6 @@ import Card from "@mui/material/Card"; import CardContent from "@mui/material/CardContent"; -import Typography from "@mui/material/Typography"; import { useTranslation } from "react-i18next"; import Button from "@mui/material/Button"; import React, { useCallback, useMemo, useState } from "react"; @@ -21,20 +20,14 @@ import uniqBy from "lodash/uniqBy"; import { useFormContext } from "react-hook-form"; import { CreateProjectInputs } from "@/app/api/projects/actions"; import MilestoneSection from "./MilestoneSection"; -import ResourceSection from "./ResourceSection"; import ProjectTotalFee from "./ProjectTotalFee"; export interface Props { allTasks: Task[]; - defaultManhourBreakdownByGrade?: { [gradeId: number]: number }; isActive: boolean; } -const ResourceMilestone: React.FC = ({ - allTasks, - defaultManhourBreakdownByGrade, - isActive, -}) => { +const Milestone: React.FC = ({ allTasks, isActive }) => { const { t } = useTranslation(); const { watch } = useFormContext(); @@ -49,17 +42,13 @@ const ResourceMilestone: React.FC = ({ const [currentTaskGroupId, setCurrentTaskGroupId] = useState( taskGroups[0].id, ); - const [currentTasks, setCurrentTasks] = useState( - tasks.filter((t) => t.taskGroup.id === currentTaskGroupId), - ); const onSelectTaskGroup = useCallback( (event: SelectChangeEvent) => { const id = event.target.value; const newTaksGroupId = typeof id === "string" ? parseInt(id) : id; setCurrentTaskGroupId(newTaksGroupId); - setCurrentTasks(tasks.filter((t) => t.taskGroup.id === newTaksGroupId)); }, - [tasks], + [], ); return ( @@ -81,13 +70,6 @@ const ResourceMilestone: React.FC = ({ {/* MUI X-Grid will throw an error if it is rendered without any dimensions; so not rendering when not active */} - {isActive && ( - - )} - {/* MUI X-Grid will throw an error if it is rendered without any dimensions; so not rendering when not active */} {isActive && }