diff --git a/.gitignore b/.gitignore index fd3dbb5..51657db 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +.vscode \ No newline at end of file diff --git a/src/app/api/projects/actions.ts b/src/app/api/projects/actions.ts index 47efb34..467d897 100644 --- a/src/app/api/projects/actions.ts +++ b/src/app/api/projects/actions.ts @@ -23,7 +23,7 @@ export interface CreateProjectInputs { tasks: { [taskId: Task["id"]]: { manhourAllocation: { - [grade: string]: number; + [gradeId: number]: number; }; }; }; diff --git a/src/components/CreateProject/MilestoneSection.tsx b/src/components/CreateProject/MilestoneSection.tsx new file mode 100644 index 0000000..f68309b --- /dev/null +++ b/src/components/CreateProject/MilestoneSection.tsx @@ -0,0 +1,154 @@ +import { CreateProjectInputs } from "@/app/api/projects/actions"; +import { TaskGroup } from "@/app/api/tasks"; +import { Add, Delete } from "@mui/icons-material"; +import { + Stack, + Typography, + Grid, + FormControl, + Box, + Button, +} from "@mui/material"; +import { + GridColDef, + GridActionsCellItem, + GridToolbarContainer, +} from "@mui/x-data-grid"; +import { LocalizationProvider, DatePicker } from "@mui/x-date-pickers"; +import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; +import dayjs from "dayjs"; +import "dayjs/locale/zh-hk"; +import React, { useMemo } from "react"; +import { useFormContext } from "react-hook-form"; +import { useTranslation } from "react-i18next"; +import StyledDataGrid from "../StyledDataGrid"; + +interface Props { + taskGroupId: TaskGroup["id"]; +} + +interface FooterToolbarProps { + onAdd: () => void; +} + +const MilestoneSection: React.FC = ({ taskGroupId }) => { + const { t } = useTranslation(); + const {} = useFormContext(); + const columns = useMemo( + () => [ + { + type: "actions", + field: "actions", + headerName: t("Actions"), + getActions: () => [ + } + label={t("Remove")} + onClick={() => {}} + />, + ], + }, + { + field: "description", + headerName: t("Payment Milestone Description"), + width: 300, + editable: true, + }, + { + field: "date", + headerName: t("Payment Milestone Date"), + width: 200, + type: "date", + editable: true, + }, + { + field: "amount", + headerName: t("Payment Milestone Amount"), + width: 300, + editable: true, + type: "number", + }, + ], + [t], + ); + + return ( + + + {t("Milestone")} + + + + + + + + + + + + + + + + ({ + marginBlockStart: 1, + marginInline: -3, + borderBottom: `1px solid ${theme.palette.divider}`, + })} + > + + + + ); +}; + +const NoRowsOverlay: React.FC = () => { + const { t } = useTranslation(); + return ( + + {t("Add some milestones!")} + + ); +}; + +const FooterToolbar: React.FC = ({ onAdd }) => { + const { t } = useTranslation(); + return ( + + + + ); +}; + +export default MilestoneSection; diff --git a/src/components/CreateProject/ResourceMilestone.tsx b/src/components/CreateProject/ResourceMilestone.tsx index d2bfbf1..aa12789 100644 --- a/src/components/CreateProject/ResourceMilestone.tsx +++ b/src/components/CreateProject/ResourceMilestone.tsx @@ -5,43 +5,29 @@ 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, useEffect, useMemo, useState } from "react"; +import React, { useCallback, useMemo, useState } from "react"; import CardActions from "@mui/material/CardActions"; import RestartAlt from "@mui/icons-material/RestartAlt"; import { Alert, - Box, FormControl, - Grid, InputLabel, - List, - ListItemButton, - ListItemText, MenuItem, - Paper, Select, SelectChangeEvent, Stack, - TextField, } from "@mui/material"; import { Task, TaskGroup } from "@/app/api/tasks"; import uniqBy from "lodash/uniqBy"; import { moneyFormatter } from "@/app/utils/formatUtil"; -import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers"; -import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs"; -import dayjs from "dayjs"; import { useFormContext } from "react-hook-form"; import { CreateProjectInputs } from "@/app/api/projects/actions"; +import MilestoneSection from "./MilestoneSection"; +import ResourceSection from "./ResourceSection"; -interface Props { +export interface Props { allTasks: Task[]; -} - -interface ResourceSectionProps { - tasks: Task[]; - defaultManhourBreakdownByGrade: { [grade: string]: number }; - onSetManhours: (hours: number, taskId: Task["id"]) => void; - onAllocateManhours: () => void; + defaultManhourBreakdownByGrade?: { [gradeId: number]: number }; } const ResourceMilestone: React.FC = ({ allTasks }) => { @@ -97,7 +83,7 @@ const ResourceMilestone: React.FC = ({ allTasks }) => { onSetManhours={() => {}} onAllocateManhours={() => {}} /> - +